Commit Graph

1271 Commits (dfdfb44ebfafd3cac1ab5b41b47ab9d55a3f46c9)

Author SHA1 Message Date
Burak Yucesoy dfdfb44ebf Acquire shard resource locks on parent tables while operating on partitions 2017-08-14 14:44:30 +03:00
Burak Yucesoy a321e750c0 Acquire relation locks on partitions while operation on parent table 2017-08-14 14:44:30 +03:00
Burak Yucesoy 52b9e35d50 Add relationIdList field to the Job struct 2017-08-14 14:06:22 +03:00
Önder Kalacı 45957e5688 Merge pull request #1529 from citusdata/deadlock_detection_main
Distributed Deadlock detection
2017-08-12 14:02:27 +03:00
Onder Kalaci 4f668ad38b Make the test outputs consistent
by using VACUUM ANALYZE on the tables.
2017-08-12 13:29:25 +03:00
Onder Kalaci 0ba2f9e4e4 Add regression tests for distributed deadlock detection 2017-08-12 13:29:25 +03:00
Onder Kalaci 5b48de7430 Improve deadlock detection for MX
We added a new field to the transaction id that is set to true only
for the transactions initialized on the coordinator. This is only
useful for MX in order to distinguish the transaction that started
the distributed transaction on the coordinator where we could
 have the same transactions' worker queries on the same node.
2017-08-12 13:28:37 +03:00
Onder Kalaci 59133415b0 Add logging infrasture for distributed deadlock detection
We added a new GUC citus.log_distributed_deadlock_detection
which is off by default. When set to on, we log some debug messages
related to the distributed deadlock to the server logs.
2017-08-12 13:28:37 +03:00
Onder Kalaci e5d5bdff51 Enable distributed deadlock detection on the maintenance deamon
With this commit, the maintenance deamon starts to check for
distributed deadlocks.

We also introduced a GUC variable (distributed_deadlock_detection_factor)
whose value is multiplied with Postgres' deadlock_timeout. Setting
it to -1 disables the distributed deadlock detection.
2017-08-12 13:28:37 +03:00
Onder Kalaci 66936053a0 Improve error messages when a backend is cancelled by deadlock detection
We send SIGINT to a backend that is cancelled due to a deadlock. That
approach ends up being a very confusing error message.

With this commit we intercept the error messages and show a more
meaningful error message to the user.
2017-08-12 13:28:37 +03:00
Onder Kalaci be4fc45c03 Deprecate enable_deadlock_prevention flag
Now that we already have the necessary infrastructure for detecting
distributed deadlocks. Thus, we don't need enable_deadlock_prevention
which is purely intended for preventing some forms of distributed
deadlocks.
2017-08-12 13:28:37 +03:00
Onder Kalaci a333c9f16c Add infrastructure for distributed deadlock detection
This commit adds all the necessary pieces to do the distributed
deadlock detection.

Each distributed transaction is already assigned with distributed
transaction ids introduced with
3369f3486f. The dependency among the
distributed transactions are gathered with
80ea233ec1.

With this commit, we implement a DFS (depth first seach) on the
dependency graph and search for cycles. Finding a cycle reveals
a distributed deadlock.

Once we find the deadlock, we examine the path that the cycle exists
and cancel the youngest distributed transaction.

Note that, we're not yet enabling the deadlock detection by default
with this commit.
2017-08-12 13:28:37 +03:00
Marco Slot d19818de21 Merge pull request #1543 from citusdata/test-follower-cluster
Add make target for testing follower clusters
2017-08-12 12:18:56 +02:00
Marco Slot 59e626d158 Add regression tests for follower clusters 2017-08-12 12:05:56 +02:00
Marco Slot 55992d4bc0 Disallow task-tracker queries on follower clusters 2017-08-12 11:47:31 +02:00
Marco Slot c097bc9a01 Merge pull request #1503 from citusdata/fix_drop_create_deadlock
Fix drop table - create_distributed_table deadlock
2017-08-11 12:46:51 +02:00
velioglu 100739f62a Change citus subversion 2017-08-11 11:57:57 +03:00
Marco Slot 53584affa8 Fix locking in create_distributed_table 2017-08-11 11:34:33 +03:00
velioglu 7c65001e23 Do not delete row from colocation table within drop table 2017-08-11 11:34:33 +03:00
Burak Velioglu c4eb6c5153 Merge pull request #1532 from citusdata/subquery_pushdown_on_reference_tables
Subquery pushdown on reference tables
2017-08-11 10:32:22 +03:00
velioglu b0efffae1c Correct planner and add more tests 2017-08-11 10:16:13 +03:00
velioglu 7550b8ad52 Fix anchor shard id selection when reference table exists 2017-08-11 10:09:47 +03:00
velioglu ceba81ce35 Move physical planner checks to logical planner 2017-08-11 10:09:47 +03:00
velioglu 0359d03530 Add set operation check for reference tables 2017-08-11 10:09:47 +03:00
velioglu c4e3b8b5e1 Add planner changes and tests for subquery on reference tables 2017-08-11 10:09:47 +03:00
velioglu 45717dd013 Check equivalence on reference tables for subquery pushdown 2017-08-11 10:09:47 +03:00
Marco Slot a6d40b8bc5 Merge pull request #1452 from citusdata/citus_create_restore_point
Add citus_create_restore_point for taking distributed snapshots
2017-08-11 08:22:22 +02:00
Marco Slot 0ae265c436 Add citus_create_restore_point for distributed snapshots 2017-08-11 07:36:20 +02:00
Marco Slot c4cd3a6e06 Merge pull request #1481 from citusdata/async_commit
Wait for commit/abort/prepare results asynchronously
2017-08-11 00:17:14 +02:00
Marco Slot fdff210ef7 Wait for commit/abort/prepare results asynchronously 2017-08-11 00:03:06 +02:00
Marco Slot fca986f214 Add API for waiting for multiple connections 2017-08-11 00:03:06 +02:00
Brian Cloutier 9d93fb5551 Create citus.use_secondary_nodes GUC
This GUC has two settings, 'always' and 'never'. When it's set to
'never' all behavior stays exactly as it was prior to this commit. When
it's set to 'always' only SELECT queries are allowed to run, and only
secondary nodes are used when processing those queries.

Add some helper functions:
- WorkerNodeIsSecondary(), checks the noderole of the worker node
- WorkerNodeIsReadable(), returns whether we're currently allowed to
  read from this node
- ActiveReadableNodeList(), some functions (namely, the ones on the
  SELECT path) don't require working with Primary Nodes. They should call
  this function instead of ActivePrimaryNodeList(), because the latter
  will error out in contexts where we're not allowed to write to nodes.
- ActiveReadableNodeCount(), like the above, replaces
  ActivePrimaryNodeCount().
- EnsureModificationsCanRun(), error out if we're not currently allowed
  to run queries which modify data. (Either we're in read-only mode or
  use_secondary_nodes is set)

Some parts of the code were switched over to use readable nodes instead
of primary nodes:
- Deadlock detection
- DistributedTableSize,
- the router, real-time, and task tracker executors
- ShardPlacement resolution
2017-08-10 17:37:17 +03:00
Brian Cloutier c854d51cd8 make multi_reference_table test more stable 2017-08-10 17:37:17 +03:00
Brian Cloutier 3fc87a7a29 Metadata sync also syncs nodes in other clusters 2017-08-10 16:55:55 +03:00
Brian Cloutier 0dee4f8418 Metadata sync syncs all nodes, not just primaries 2017-08-10 16:55:55 +03:00
Eren Başak 353d2db913 Merge pull request #1545 from citusdata/create_table_utility_udfs
Define Utility Functions
2017-08-10 15:20:36 +03:00
Eren Başak deb89cb9ce Delete tesh_helper_functions.h 2017-08-10 14:00:44 +03:00
Eren Başak f9470329e5 Remove test_helper_functions.h inclusions 2017-08-10 12:42:46 +03:00
Eren Başak 3061737712 Define Some Utility Functions
This change declares two new functions:

`master_update_table_statistics` updates the statistics of shards belong
to the given table as well as its colocated tables.

`get_colocated_shard_array` returns the ids of colocated shards of a
given shard.
2017-08-10 12:42:46 +03:00
Brian Cloutier 1961add6f9 Improve error message when there are no nodes for a placement 2017-08-10 12:38:51 +03:00
Jason Petersen 4e8d07c672 Merge pull request #1517 from citusdata/feature/multi_row_insert
Enable multi-row INSERTs

cr: @marcocitus
2017-08-10 01:25:13 -07:00
Jason Petersen dee66e3959
Final review feedback 2017-08-10 01:10:09 -07:00
Jason Petersen a578506718
Add multi-row isolation tests 2017-08-10 01:10:09 -07:00
Jason Petersen addde54464
Add some tests 2017-08-10 00:32:46 -07:00
Jason Petersen 6a35c2937c
Enable multi-row INSERTs
This is a pretty substantial refactoring of the existing modify path
within the router executor and planner. In particular, we now hunt for
all VALUES range table entries in INSERT statements and group the rows
contained therein by shard identifier. These rows are stashed away for
later in "ModifyRoute" elements. During deparse, the appropriate RTE
is extracted from the Query and its values list is replaced by these
rows before any SQL is generated.

In this way, we can create multiple Tasks, but only one per shard, to
piecemeal execute a multi-row INSERT. The execution of jobs containing
such tasks now exclusively go through the "multi-router executor" which
was previously used for e.g. INSERT INTO ... SELECT.

By piggybacking onto that executor, we participate in ongoing trans-
actions, get rollback-ability, etc. In short order, the only remaining
use of the "single modify" router executor will be for bare single-
row INSERT statements (i.e. those not in a transaction).

This change appropriately handles deferred pruning as well as master-
evaluated functions.
2017-08-10 00:32:46 -07:00
Burak Velioglu c66c62cd14 Merge pull request #1475 from citusdata/in-any-pruning-v2
Support for IN/=ANY pruning
2017-08-10 09:08:59 +03:00
velioglu 7e436c0277 Add bool expression to pruning instance with a function 2017-08-10 08:56:36 +03:00
Andres Freund e8b793c454 Support for IN (const, list) and = ANY(const, b, c) pruning. 2017-08-10 08:56:36 +03:00
Önder Kalacı 4a09bb4948 Merge pull request #1516 from citusdata/improve_lw_locks
Improve locking semantics for the backend management
2017-08-09 17:33:15 +03:00
Onder Kalaci b5ea3ab6a3 Improve locking semantics for backend management
We use the backend shared memory lock for preventing
new backends to be part of a new distributed transaction
or an existing backend to leave a distributed transaction
while we're reading the all backends' data.

The primary goal is to provide consistent view of the
current distributed transactions while doing the
deadlock detection.
2017-08-09 17:17:12 +03:00