Commit Graph

3791 Commits (a9c5925d2e9cd611b9ffa82ea9a4c533fedbf45c)

Author SHA1 Message Date
Hanefi Onaldi a9c5925d2e
Bump Citus version to 9.4.6 2021-08-11 11:03:35 +03:00
Hanefi Onaldi 800bb6289d
Add changelog entries for 9.4.6
(cherry picked from commit c6e428896a)
2021-08-11 11:01:19 +03:00
Onder Kalaci 1f1fd4434d Guard against hard WaitEvenSet errors
In short, add wrappers around Postgres' AddWaitEventToSet() and
ModifyWaitEvent().

AddWaitEventToSet()/ModifyWaitEvent*() may throw hard errors. For
example, when the underlying socket for a connection is closed by
the remote server and already reflected by the OS, however
Citus hasn't had a chance to get this information. In that case,
if replication factor is >1, Citus can failover to other nodes
for executing the query. Even if replication factor = 1, Citus
can give much nicer errors.

So CitusAddWaitEventSetToSet()/CitusModifyWaitEvent() simply puts
AddWaitEventToSet()/ModifyWaitEvent() into a PG_TRY/PG_CATCH block
in order to catch any hard errors, and returns this information to
the caller.
2021-08-10 09:48:59 +02:00
naisila c272bfcd63 Bump use of new sql function 2021-08-03 16:44:12 +03:00
naisila c2c71eec9e Fix master_update_table_statistics scripts for 9.4 2021-08-03 16:44:12 +03:00
naisila 81bed61b4e Reimplement master_update_table_statistics to detect dist. deadlocks
(ALL CODE BORROWED from commit 2f30614fe3)
2021-08-03 16:44:12 +03:00
Onur Tirtir acdecc8fe5 Remove fkey graph visited flags & rework GetConnectedListHelper (#4446)
With this commit, we remove visited flags from ForeignConstraintRelationshipNode
struct since keeping local state in global object is both dangerous and
meaningless.

Also to improve readability, this commit also converts needless recursion to
iterative DFS to avoid passing local hash-map as another parameter to
GetConnectedListHelper function.
(cherry picked from commit 0db21bbe14)
2021-08-03 16:44:12 +03:00
Onur Tirtir 6b1a146df1 Refactor foreign_key_relationship.c (#4438)
(cherry picked from commit 3f60b08b11)
2021-08-03 16:44:12 +03:00
naisila dd619e3f72 Add OpenConnectionToNodes and functions that generate shard queries
(ALL CODE BORROWED from commit 724d56f949)
2021-08-03 16:44:12 +03:00
Hanefi Onaldi 2a17fdbb88
Bump Citus version to 9.4.5 2021-07-08 09:51:28 +03:00
Hanefi Onaldi cdf8a123c6
Add changelog entry for 9.4.5
(cherry picked from commit 80a5539671)
2021-07-08 09:51:12 +03:00
Nils Dijk 46bc57a99a Bump use of new sql function 2021-07-05 16:15:51 +02:00
Marco Slot 1a21c524b7 Fix PG upgrade scripts for 9.4 2021-07-05 16:15:51 +02:00
Onur Tirtir be3da3901e Fix lower boundary calculation when pruning range dist table shards (#5082)
This happens only when we have a "<" or "<=" filter on distribution
column of a range distributed table and that filter falls in between
two shards.

When the filter falls in between two shards:

  If the filter is ">" or ">=", then UpperShardBoundary was
  returning "upperBoundIndex - 1", where upperBoundIndex is
  exclusive shard index used during binary seach.
  This is expected since upperBoundIndex is an exclusive
  index.

  If the filter is "<" or "<=", then LowerShardBoundary was
  returning "lowerBoundIndex + 1", where lowerBoundIndex is
  inclusive shard index used during binary seach.
  On the other hand, since lowerBoundIndex is an inclusive
  index, we should just return lowerBoundIndex instead of
  doing "+ 1". Before this commit, we were missing leftmost
  shard in such queries.

* Remove useless conditional branches

The branch that we delete from UpperShardBoundary was obviously useless.

The other one in LowerShardBoundary became useless after we remove "+ 1"
from there.

This indeed is another proof of what & how we are fixing with this pr.

* Improve comments and add more

* Add some tests for upper bound calculation too

(cherry picked from commit b118d4188e)

* Also fix a debug message diff for 9.4
2021-07-02 14:59:36 +03:00
Hanefi Onaldi 6348efca64 Do not use security flags by default (#4770)
(cherry picked from commit 697bbbd3c6)
2021-03-04 01:08:48 +03:00
Hanefi Onaldi 0e147f9c8c Add security flags in configure scripts (#4760)
(cherry picked from commit f87107eb6b)
2021-03-04 01:07:26 +03:00
Onder Kalaci 281460fbaa Do not connection re-use for intermediate results
/*
 * Colocated intermediate results are just files and not required to use
 * the same connections with their co-located shards. So, we are free to
 * use any connection we can get.
 *
 * Also, the current connection re-use logic does not know how to handle
 * intermediate results as the intermediate results always truncates the
 * existing files. That's why, we use one connection per intermediate
 * result.
 */

(cherry picked from commit 5d5a357487)
2021-02-11 17:13:55 +01:00
Onder Kalaci 3065966d13 When reaches to executor pool size, COPY sets the placement access
It looks like we forgot to set the placement accesses, and
this could lead to self-deadlocks on complex transaction blocks.

(cherry picked from commit 36bdeef1bb)
2021-02-02 10:17:28 +01:00
Gürkan İndibay d0000a15bd
Bump version to 9.4.4 (#4468)
Update configuration files version info
2021-01-04 13:56:34 +03:00
gurkanindibay a5adc49077 Add changelog entry for version 9.4.4
Conflicts:
	CHANGELOG.md

 Committing a cherry-pick with sha 19977792d8
2020-12-30 13:12:58 +00:00
Onur Tirtir 7233c27533 Not consider single shard hash dist. tables as replicated (#4413)
(cherry picked from commit 0eb5701658)
2020-12-22 16:59:32 +03:00
Onur Tirtir 51f422f3c6
Add some more tests with views to test recursive planning on views (#4404) 2020-12-18 17:42:35 +03:00
Marco Slot 8fae9aae96
Reliably detect local tables in router queries in 9.4 (#4418)
Co-authored-by: Marco Slot <marco.slot@gmail.com>
2020-12-17 13:38:16 +01:00
Onur Tirtir 59774b1dd4 Handle invalid connection hash entries (#4362)
If MemoryContextAlloc errors out -e.g. during an OOM-, ConnectionHashEntry->connections
stays as NULL.

With this commit, we add isValid flag to ConnectionHashEntry that should be set to true
right after we allocate & initialize ConnectionHashEntry->connections list properly, and we
check it before accesing to ConnectionHashEntry->connections.
(cherry picked from commit 7f3d1182ed)

 Conflicts:
	src/backend/distributed/connection/connection_management.c
2020-12-01 11:09:33 +03:00
Onur Tirtir 221aa1a381 Update CHANGELOG for 9.4.3
(cherry picked from commit 76a429f19b)

 Conflicts:
	CHANGELOG.md
2020-11-24 13:21:08 +03:00
Onur Tirtir 7e99324bd9 Bump version to 9.4.3 2020-11-24 12:19:15 +03:00
Önder Kalacı 447c7ecdd4 Enable parallel query on EXPLAIN ANALYZE (#4325)
It seems that we forgot to pass the revelant
flag to enable Postgres' parallel query
capabilities on the shards when user does
EXPLAIN ANALYZE on a distributed table.

(cherry picked from commit b0ddbbd33a)

 Conflicts:
	src/backend/distributed/planner/multi_explain.c
2020-11-24 12:19:15 +03:00
Onder Kalaci a943696c44 Do not execute subplans multiple times with cursors
Before this commit, we let AdaptiveExecutorPreExecutorRun()
to be effective multiple times on every FETCH on cursors.
That does not affect the correctness of the query results,
but adds significant overhead.

(cherry picked from commit c433c66f2b)
2020-11-23 13:43:24 +03:00
Onur Tirtir ca2bbd89b6 Update CHANGELOG for 9.4.2
(cherry picked from commit c7755103f1)
2020-10-21 15:29:24 +03:00
Onur Tirtir 3d2e1a7464 Bump version to 9.4.2 2020-10-21 15:28:12 +03:00
Marco Slot b7b7b66beb Support reference table view in reference table modification 2020-10-16 13:16:16 +02:00
Marco Slot f6e5006dfd Fix a bug that could lead to multiple maintenance daemons 2020-10-16 13:15:51 +02:00
Marco Slot 03e4bec352 Add maintenance daemon error tests 2020-10-16 13:15:39 +02:00
Onur Tirtir 6aac62e847 Update CHANGELOG for 9.4.1
(cherry picked from commit bc29238546)
2020-09-30 10:53:05 +03:00
Onur Tirtir 72c54b5cdd Bump version to 9.4.1 2020-09-30 10:52:31 +03:00
Marco Slot 637d93e8ff Fix EXPLAIN ANALYZE truncation
(cherry picked from commit c9d46c618b)

Conflicts:
	src/test/regress/expected/multi_explain.out
	src/test/regress/sql/multi_explain.sql
2020-09-28 15:49:58 +03:00
SaitTalhaNisanci 7a00c5b83c Not take ShareUpdateExlusiveLock on pg_dist_transaction (#4184)
* Not take ShareUpdateExlusiveLock on pg_dist_transaction

We were taking ShareUpdateExlusiveLock on pg_dist_transaction during
recovery to prevent multiple recoveries happening concurrenly. VACUUM(
not FULL) also takes ShareUpdateExclusiveLock, and they can conflict. It
seems that VACUUM will skip the table if there is a conflicting lock
already taken unless it is doing the vacuum to prevent id wraparound, in
which case there can be a deadlock. I guess the deadlock happens if:

- VACUUM takes a lock on pg_dist_transaction and is done for id
wraparound problem
- The transaction in the maintenance tries to take a lock but
cannot as that conflicts with the lock acquired by VACUUM
- The transaction in the maintenance daemon has a very old xid hence
VACUUM cannot proceed.

If we take a row exclusive lock in transaction recovery then it wouldn't
conflict with VACUUM hence it could proceed so the deadlock would be
resolved. To prevent concurrent transaction recoveries happening, an
advisory lock is taken with ShareUpdateExlusiveLock as before.

* Use CITUS_OPERATIONS tag

(cherry picked from commit e7cd1ed0ee)

 Conflicts:
	src/backend/distributed/transaction/transaction_recovery.c
2020-09-28 11:38:04 +03:00
Onur Tirtir 51b7b01a09 Update CHANGELOG for 9.4.0
(cherry picked from commit c7f97a9e01)

 Conflicts:
	CHANGELOG.md
2020-07-28 14:58:05 +03:00
Halil Ozan Akgul 993a402c73 Fixes create index concurrently bug
(cherry picked from commit 38b72ddd66)
2020-07-27 10:32:08 +03:00
SaitTalhaNisanci 39e63f5a08 Fix int32 overflow and use PG macros for INT32_XX (#4061)
* Use CalculateUniformHashRangeIndex in HashPartitionId

INT32_MIN definition can change among different platforms hence it is
possible to get overflow, we would see crashes because of this in debian
distros. We have already solved a similar problem with introducing
CalculateUniformHashRangeIndex method, hence to solve it we can use the
same method, this also removes some duplication and has a single place
to decide that.

* Use PG_INT32_XX instead of INT32_XX to be safer

(cherry picked from commit ef841115de)
2020-07-27 10:32:08 +03:00
Halil Ozan Akgül 2271e9ded1 Fixes the non existing table bug (#4058)
(cherry picked from commit e9f89ed651)
2020-07-27 10:32:08 +03:00
Sait Talha Nisanci 4c90dbbd88 improve error message in secondaries
(cherry picked from commit 6f4686c741467b5c8bd6ca15c0788d8db856392a)
2020-07-21 13:55:12 +03:00
Sait Talha Nisanci 388893ce5e add multi follower repartition tests
(cherry picked from commit 6e5598fd58a1c0c6a597ca06539ac5e286cb6914)
2020-07-21 13:55:08 +03:00
Sait Talha Nisanci 4b98f6c5c2 address feedback
(cherry picked from commit 24043a3602abc7b525f2724a35168e4c45442165)
2020-07-21 13:55:04 +03:00
Sait Talha Nisanci 97dda868a0 use ActiveReadableNodeList in JobExecutorType and task tracker
The reason we should use ActiveReadableNodeList instead of ActiveReadableNonCoordinatorNodeList is that if coordinator is added to cluster as a worker, it should be counted as well. Otherwise if there is only coordinator in the cluster, the count will be 0, hence we get a warning.

In MultiTaskTrackerExecute, we should connect to coordinator if it is
added to the cluster because it will also be assigned tasks.

(cherry picked from commit ae6180ace2931223c58b87444a9e812f5e9f06e8)
2020-07-21 13:55:00 +03:00
Sait Talha Nisanci 27ef768f36 use ActivePrimaryNodeList to include coordinator
ActiveReadableWorkerNodeList doesn't include coordinator, however if
coordinator is added as a worker, we should also include that while
planning. The current methods are very easily misusable and this
requires a refactoring to make the distinction between methods that
include coordinator and that don't very explicit as they can introduce
subtle/major bugs pretty easily.

(cherry picked from commit 86b974e4ceddaf5e2c44799148a8cf485c7d90bf)
2020-07-21 13:54:56 +03:00
Sait Talha Nisanci c238e6c8b0 send schema creation/cleanup to coordinator in repartitions
We were using ALL_WORKERS TargetWorkerSet while sending temporary schema
creation and cleanup. We(well mostly I) thought that ALL_WORKERS would also include coordinator when it is added as a worker. It turns out that it was FILTERING OUT the coordinator even if it is added as a worker to the cluster.

So to have some context here, in repartitions, for each jobId we create
(at least we were supposed to) a schema in each worker node in the cluster. Then we partition each shard table into some intermediate files, which is called the PARTITION step. So after this partition step each node has some intermediate files having tuples in those nodes. Then we fetch the partition files to necessary worker nodes, which is called the FETCH step. Then from the files we create intermediate tables in the temporarily created schemas, which is called a MERGE step. Then after evaluating the result, we remove the temporary schemas(one for each job ID in each node) and files.

If node 1 has file1, and node 2 has file2 after PARTITION step, it is
enough to either move file1 from node1 to node2 or vice versa. So we
prune one of them.

In the MERGE step, if the schema for a given jobID doesn't exist, the
node tries to use the `public` schema if it is a superuser, which is
actually added for testing in the past.

So when we were not sending schema creation comands for each job ID to
the coordinator(because we were using ALL_WORKERS flag, and it doesn't
include the coordinator), we would basically not have any schemas for
repartitions in the coordinator. The PARTITION step would be executed on
the coordinator (because the tasks are generated in the planner part)
and it wouldn't give us any error because it doesn't have anything to do
with the temporary schemas(that we didn't create). But later two things
would happen:

- If by chance the fetch is pruned on the coordinator side, we the other
nodes would fetch the partitioned files from the coordinator and execute
the query as expected, because it has all the information.
- If the fetch tasks are not pruned in the coordinator, in the MERGE
step, the coordinator would either error out saying that the necessary
schema doesn't exist, or it would try to create the temporary tables
under public schema ( if it is a superuser). But then if we had the same
task ID with different jobID it would fail saying that the table already
exists, which is an error we were getting.

In the first case, the query would work okay, but it would still not do
the cleanup, hence we would leave the partitioned files from the
PARTITION step there. Hence ensure_no_intermediate_data_leak would fail.

To make things more explicit and prevent such bugs in the future,
ALL_WORKERS is named as ALL_NON_COORD_WORKERS. And a new flag to return
all the active nodes is added as ALL_DATA_NODES. For repartition case,
we don't use the only-reference table nodes but this version makes the
code simpler and there shouldn't be any significant performance issue
with that.

(cherry picked from commit 6532506f4b92b1316eea0812b2bcedb818d3b25c)
2020-07-21 13:54:51 +03:00
Sait Talha Nisanci a04e7b233e rename node/worker utilities
The names were not explicit about what they do, and we have many
misusages in the codebase, so they are renamed to be more explicit.

(cherry picked from commit 09962a7e2ff340705b6b193bbfececa2d48e0855)
2020-07-21 13:54:45 +03:00
Sait Talha Nisanci 0bd4002e5f rename TargetWorkerSet enums
Rename TargetWorkerSet enums to make them more explicit about what they
mean. Ideally it would be good to treat everything as a node without the
'worker' concept because it makes things complicated. Another
improvement could be to rename TargetWorkerSet as TargetNodeSet but it
goes to renaming many occurrences of Worker, which is probably too big
for this PR.

(cherry picked from commit de4b9569359e4f10d4ebf3fbcf7159ee6e2328db)
2020-07-21 13:54:40 +03:00
Nils Dijk 23f24a9668 fix flappy tests due to undeterministic order of test output (#4029)
As reported on #4011 https://github.com/citusdata/citus/pull/4011/files#r453804702 some of the tests were flapping due to an indeterministic order for test outputs.

This PR makes the test output ordered for all tests returning non-zero rows.

Needs to be backported to 9.2, 9.3, 9.4
(cherry picked from commit 23d44eba9f)
2020-07-21 11:01:49 +03:00