Commit Graph

864 Commits (support-6.1-cancellation-fix)

Author SHA1 Message Date
Metin Doslu e0e856a902 Drop missing isolation tests 2017-09-14 12:39:43 -07:00
Andres Freund 37d4c36683 Add tests for statement cancellation. 2017-09-13 16:39:06 -07:00
Andres Freund 17946b4ea6 Don't wait for statement completion when aborting coordinated transaction.
Previously we used ForgetResults() in StartRemoteTransactionAbort() -
that's problematic because there might still be an ongoing statement,
and this causes us to wait for its completion.  That e.g. happens when
a statement running on the coordinator is cancelled.
2017-09-13 16:38:52 -07:00
Andres Freund 992f2d907d Cancel statements when closing connection at transaction end.
That's important because the currently running statement on a worker
might continue to hold locks and consume resources, even after the
connection is closed.  Unfortunately postgres will only notice closed
connections when reading from / writing to the network. That might
only happen much later.
2017-09-13 16:38:41 -07:00
Andres Freund 25cabe634e Add NonblockingForgetResults().
This is very similar to ForgetResults() except that no network IO is
performed. Primarily useful in error handling cases.
2017-09-13 16:38:27 -07:00
Andres Freund c8f7c7fc59 Add ShutdownConnection() which cancels statement before closing connection.
That's primarily useful in error cases, where we want to make sure
locks etc held by commands running on workers are released promptly.
2017-09-13 16:38:11 -07:00
Andres Freund f4e87bb717 Always use connections in non-blocking mode.
Now that there's no blocking libpq callers left, default to using
non-blocking mode in connection_management.c.  This has two
advantages:
1) Blockiness doesn't have to frequently be reset, simplifying code
2) Prevents accidental use of blocking libpq functions, since they'll
   frequently return 'need IO'
2017-09-13 16:38:00 -07:00
Andres Freund a66ece75a0 Move multi_copy.c to interrupt aware libpq wrappers. 2017-09-13 16:37:44 -07:00
Andres Freund 0722b3f003 Move multi_client_executor to interrupt aware libpq wrappers. 2017-09-13 16:37:25 -07:00
Andres Freund 1e5a8970db Move citus tools to interrupt aware libpq wrappers. 2017-09-13 16:37:03 -07:00
Andres Freund 734921eca6 Add interrupt aware PQputCopy{End,Data} wrappers. 2017-09-13 16:36:46 -07:00
Andres Freund 02fa8cee0e Move interrupt handling code from GetRemoteCommandResult to FinishConnectionIO.
Nearby commits will add additional interrupt handling functions, this
way we don't have to duplicate the code.
2017-09-13 16:36:17 -07:00
Andres Freund 7db61f148b Fix copy & pasto in WARNING message. 2017-09-13 16:33:53 -07:00
Andres Freund 4f78e4432d Fix memory leak in RemoteFinalizedShardPlacementList(). 2017-09-13 16:33:40 -07:00
Andres Freund 57c529c3b0 Fix some trailing whitespace. 2017-09-13 16:33:23 -07:00
Andres Freund 9794d6da64
Regression tests adjustments for backport.
This is a smaller version of b7dfeb0bec
/ #1351.
2017-06-06 15:58:05 -06:00
Andres Freund 3ca7dd13be
Perform range based pruning if equality pruning has survivor.
We previously dismissed this as unimportant, but it turns out to be
very useful for the upcoming subquery pushdown, where a user might
specify an equality constraint in a subquery, and the subquery
pushdown machinery adds >= and <= restrictions on the shard boundary.
Previously the latter restriction was ignored.
2017-06-06 15:58:05 -06:00
Andres Freund 7a0f02f186
Use stricter qual for pruning if both >/< and >=/<= are present.
Previously, if both =< and < (>= and < respectively) were specified,
we always used the latter restriction.  Instead use the stricter one.
2017-06-06 15:58:05 -06:00
Andres Freund bb456d4002
Faster shard pruning.
So far citus used postgres' predicate proofing logic for shard
pruning, except for INSERT and COPY which were already optimized for
speed.  That turns out to be too slow:
* Shard pruning for SELECTs is currently O(#shards), because
  PruneShardList calls predicate_refuted_by() for every
  shard. Obviously using an O(N) type algorithm for general pruning
  isn't good.
* predicate_refuted_by() is quite expensive on its own right. That's
  primarily because it's optimized for doing a single refutation
  proof, rather than performing the same proof over and over.
* predicate_refuted_by() does not keep persistent state (see 2.) for
  function calls, which means that a lot of syscache lookups will be
  performed. That's particularly bad if the partitioning key is a
  composite key, because without a persistent FunctionCallInfo
  record_cmp() has to repeatedly look-up the type definition of the
  composite key. That's quite expensive.

Thus replace this with custom-code that works in two phases:
1) Search restrictions for constraints that can be pruned upon
2) Use those restrictions to search for matching shards in the most
   efficient manner available:
   a) Binary search / Hash Lookup in case of hash partitioned tables
   b) Binary search for equal clauses in case of range or append
      tables without overlapping shards.
   c) Binary search for inequality clauses, searching for both lower
      and upper boundaries, again in case of range or append
      tables without overlapping shards.
   d) exhaustive search testing each ShardInterval

My measurements suggest that we are considerably, often orders of
magnitude, faster than the previous solution, even if we have to fall
back to exhaustive pruning.
2017-06-06 15:58:05 -06:00
Andres Freund 096a1e3200
Add DistTableCacheEntry->hasOverlappingShardInterval.
This determines whether it's possible to perform binary search on
sortedShardIntervalArray or not.  If e.g. two shards have overlapping
ranges, that'd be prohibitive.

That'll be useful in later commit introducing faster shard pruning.
2017-06-06 15:58:05 -06:00
Andres Freund 3268ffae48
Add DistTableCacheEntry->shardValueCompareFunction.
That's useful when comparing values a hash-partitioned table is
filtered by.  The existing shardIntervalCompareFunction is about
comparing hashed values, not unhashed ones.

The added btree opclass function is so we can get a comparator
back. This should be changed much more widely, but is not necessary so
far.
2017-06-06 15:58:05 -06:00
Andres Freund 2fa2862be5
Build DistTableCacheEntry->shardIntervalCompareFunction even for 0 shards.
Previously we, unnecessarily, used a the first shard's type
information to to look up the comparison function.  But that
information is already available, so use it.  That's helpful because
we sometimes want to access the comparator function even if there's no
shards.
2017-06-06 15:58:04 -06:00
Jason Petersen 118fd6c504
Add 6.1.2 CHANGELOG entry 2017-05-31 17:04:19 -06:00
Marco Slot 0e2c52b531 Don't take a table lock in ForeignConstraintGetReferencedTableId 2017-05-31 15:33:42 -07:00
Jason Petersen 20612e3c6e
Update CHANGELOG for v6.1.1 2017-05-04 18:00:38 -07:00
Marco Slot a81ac8713c
Don't change query tree of DDL commands
Based on 853f07dd33
2017-05-04 15:05:47 -07:00
Jason Petersen fd05951c86
Fix CREATE SEQUENCE generation bug
Apparently we've had a typo all this time causing us to pass the cache
value for the start value.
2017-05-04 13:03:51 -07:00
Andres Freund 5b6dd0812d
Fix: Make FindShardIntervalIndex robust against 0 shards. 2017-05-04 13:03:35 -07:00
Jason Petersen 6dbd434f81
Remove FastShardPruning method
With the other simplifications, it doesn't make sense to keep around.

Based on 93e3afc25c
2017-05-04 11:31:11 -07:00
Jason Petersen 8afb4b9f33
Refactor FindShardInterval to use cacheEntry
All callers fetch a cache entry and extract/compute arguments for the
eventual FindShardInterval call, so it makes more sense to refactor
into that function itself; this solves the use-after-free bug, too.

Based on 42ee7c05f5
2017-05-04 11:31:11 -07:00
Marco Slot 9a2a9664ca
Only process error if not NULL in StoreErrorMessage 2017-05-04 11:30:39 -07:00
Marco Slot 75392c0774
Use right sizeof in UpdateRelationColocationGroup 2017-05-04 11:30:31 -07:00
velioglu e57aa3f2a7
Check whether binary output function is defined for type of each column. 2017-05-04 11:19:01 -07:00
Onder Kalaci 03083ea59f Fix pushing down wrong INSERT ... SELECT queries
Before this commit, in certain cases router planner allowed pushing
down JOINs that are not on the partition keys.

With @anarazel's suggestion, we change the logic to use uninstantiated
parameter. Previously, the planner was traversing on the restriction
information and once it finds the parameter, it was replacing it with
the shard range. With this commit, instead of traversing the restrict
infos, the planner explicitly checks for the equivalence of the relation
partition key with the uninstantiated parameter. If finds an equivalence,
it adds the restrictions. In this way, we have more control over the
queries that are pushed down.

Based on 11665dbe3c
2017-05-04 11:17:22 -07:00
Marco Slot b8aa47e58f Support UPDATE/DELETE with parameterised partition column qual 2017-04-29 00:58:13 +02:00
Andres Freund 09c42481bb Fix SendRemoteCommandParams() handling of a NULL MultiConnection->pgConn. (#1271)
Previously we'd segfault in PQisnonblocking() which, contrary to other
libpq calls, doesn't handle a NULL PQconn (because there'd be no
appropriate return value for that).

cr: @jasonmp85
2017-04-27 14:51:01 -07:00
Jason Petersen 2d6915c82a
Add 6.1.0 CHANGELOG entries (#1219)
This is probably missing some stuff, but is my edit of the initial list
compiled by Burak.

cr: @craigkerstiens
2017-02-09 17:07:05 -07:00
Jason Petersen d9e3405745
Fix tests broken by new PostgreSQL patch releases (#1220)
PostgreSQL 9.5.6 and 9.6.2 were released today and broke several tests
by adding TABLESPACE pg_default output to some DDL commands. Fixed all
occurrences.

cr: @anarazel
2017-02-09 17:07:04 -07:00
Önder Kalacı 1875f86d3b Merge pull request #1213 from citusdata/fix_fkey_crash
Bugfix for creating foreign key
2017-02-07 10:26:11 +02:00
Onder Kalaci 95f8382ca2 Bugfix for creating foreign key
This commit fixes crash for adding foreign keys without
specifying the referenced column crashes the backend.
2017-02-07 09:34:24 +02:00
Brian Cloutier e6e5f63d9d Utility hook does nothing if the extension is not loaded 2017-02-02 17:48:31 +02:00
Brian Cloutier a30b9b93a4 Set a memory context when throwing deferred errors 2017-02-02 15:14:21 +02:00
Brian Cloutier e3c763c3f7 Start remote transactions in master_append_table_to_shard
Add a call to RemoteTransactionBeginIfNecessary so that BEGIN is
actually sent to the remote connections. This means that ROLLBACK and
Ctrl-C are respected and don't leave the table in a partial state.
2017-02-01 18:12:19 +02:00
Jason Petersen 1ff9d68e68 Merge pull request #1182 from citusdata/fix_random_travis_failure
Fix Random Fails on Travis

cr: @jasonmp85
2017-01-31 16:42:19 -07:00
Eren Basak 005c533ee8 Fix Random Fails on Travis
This change fixes the random failures on Travis, which is a bug introduced
with citus/#1124. Before this fix, travis was failing randomly on `check_multi_mx`
test schedule, specifically in the parallel group of `multi_mx_metadata`,
'multi_mx_modifications` and `multi_mx_modifying_xacts` tests. This change fixes this
by serializing these three test cases.
2017-01-31 15:23:06 -08:00
Eren Başak 20139b9b1a Merge pull request #1183 from citusdata/allow_drop_sequence_on_worker
Allow dropping sequences on mx workers
2017-01-31 14:59:29 -08:00
Eren Basak ae0bfb1394 Allow dropping sequences on mx workers
This change allows users to drop sequences on MX workers. Previously, Citus didn't allow dropping
sequences on MX workers because it could cause shards to be dropped if `DROP SEQUENCE ... CASCADE`
is used. We now allow that since allowing sequence creation but not dropping hurts user experience
and also may cause problems with custom Citus solutions.
2017-01-31 14:51:44 -08:00
Samay Sharma 88f4956064 Merge pull request #1178 from citusdata/ozgune-patch-1
Update README.md to include use cases
2017-01-30 13:24:52 -08:00
Ozgun Erdogan 80e241e5c8 Update README.md to include use cases
Updated to the README.md to reflect newer product features.

* Include references to the multi-tenant use case
* Minor update to tutorial link to include 6.0
* Minor update to Contributing guidelines (we haven't used #helpwanted tags over the past year)
* Minor update to remove link to support & training
2017-01-27 16:36:33 -08:00
Brian Cloutier 6843ad8e91 Fix bug where router executor sends query to failed connections 2017-01-27 09:40:30 +02:00