Commit Graph

4693 Commits (28a503fad92fa22e21cc4da520029c5faecb4ccc)

Author SHA1 Message Date
Marco Slot 28a503fad9 Perform copy command as regular user in worker_append_table_to_shard 2021-09-10 13:25:52 +02:00
Onur Tirtir 30b46975b8 Not read heaptuple after closing pg_rewrite (#5255)
(cherry picked from commit cc49e63222)
2021-09-08 16:02:05 +03:00
Hanefi Onaldi 5f5e5ef471
Bump Citus version to 10.0.5 2021-08-17 07:45:37 +03:00
Hanefi Onaldi 5a1036e361
Add changelog entries for 10.0.5
(cherry picked from commit 167a023770)
2021-08-16 17:38:54 +03:00
Onder Kalaci 6de2a09d79 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:38:09 +02:00
Onder Kalaci d485003807 Adjust the tests to earlier versions
- Drop PRIMARY KEY for Citus 10 compatibility
- Drop columnar for PG 12
- Do not start/stop metadata sync as stop is not implemented in 10.1
- PG 11 parallel query changes explain outputs
2021-08-06 16:38:01 +02:00
Onder Kalaci 32124efd83 Dropped columns do not diverge distribution column for partitioned tables
Before this commit, creating a partition after a DROP column
on the parent (position before dist. key) was leading to
partition to have the wrong distribution column.
2021-08-06 13:42:06 +02:00
naisila c84d1d9e70 Fix master_update_table_statistics scripts for 9.5 2021-08-03 16:45:46 +03:00
naisila b46f8874d3 Fix master_update_table_statistics scripts for 9.4 2021-08-03 16:45:46 +03:00
Hanefi Onaldi 1492bd1e8b
Bump Citus to 10.0.4 2021-07-14 16:03:45 +03:00
Hanefi Onaldi 4082fab0c9
Add changelog entry for 10.0.4
(cherry picked from commit 45b72c204d)
2021-07-14 15:49:44 +03:00
Hanefi Onaldi 4ca544200c
Use ONLY keywords on PG11 deparser 2021-07-13 17:27:34 +03:00
Marco Slot e58b78f1e8
Fix FROM ONLY queries on partitioned tables
(cherry picked from commit 4b49cb112f)
2021-07-13 17:27:33 +03:00
jeff-davis f526eec6a8 Columnar: use clause Vars for chunk group filtering. (#4856)
* Columnar: use clause Vars for chunk group filtering.

This solves #4780 and also provides a cleaner separation between chunk
group filtering and projection pushdown.

* Columnar: sort and deduplicate Vars pulled from clauses.

* Columnar: cleanup variable names.

* Columnar: remove alternate test output.

* Columnar: do not recurse when looking for whereClauseVars.

Co-authored-by: Jeff Davis <jefdavi@microsoft.com>
(cherry picked from commit 063e673038)
2021-07-13 12:01:57 -07:00
SaitTalhaNisanci 5759233f15
Warm up connections params hash (#4872)
ConnParams(AuthInfo and PoolInfo) gets a snapshot, which will block the
remote connectinos to localhost. And the release of snapshot will be
blocked by the snapshot. This leads to a deadlock.

We warm up the conn params hash before starting a new transaction so
that the entries will already be there when we start a new transaction.
Hence GetConnParams will not get a snapshot.

(cherry picked from commit b453563e88)
2021-07-13 11:30:15 +03:00
Hanefi Onaldi 6640c76bde
Switch to sequential mode on long partition names
This commit adds support for long partition names for distributed tables:
- ALTER TABLE dist_table ATTACH PARTITION ..
- CREATE TABLE .. PARTITION OF dist_table ..

Note: create_distributed_table UDF does not support long table and
partition names, and is not covered in this commit

(cherry picked from commit 9919fbe3f8)
2021-07-13 08:06:58 +03:00
Sait Talha Nisanci 11d5d21fd8
Call LockPlacementCleanup in RemoveOldShardPlacementForNodeGroup 2021-07-13 05:30:51 +03:00
SaitTalhaNisanci 4fbed90505
Fix data-race with concurrent calls of DropMarkedShards (#4909)
* Fix problews with concurrent calls of DropMarkedShards

When trying to enable `citus.defer_drop_after_shard_move` by default it
turned out that DropMarkedShards was not safe to call concurrently.
This could especially cause big problems when also moving shards at the
same time. During tests it was possible to trigger a state where a shard
that was moved would not be available on any of the nodes anymore after
the move.

Currently DropMarkedShards is only called in production by the
maintenaince deamon. Since this is only a single process triggering such
a race is currently impossible in production settings. In future changes
we will want to call DropMarkedShards from other places too though.

* Add some isolation tests

Co-authored-by: Jelte Fennema <github-tech@jeltef.nl>
(cherry picked from commit 93c2dcf3d2)
2021-07-13 05:30:51 +03:00
Ahmet Gedemenli 7214673a9f Fix test output for cherry-picked commits for 10.0 2021-07-12 16:42:15 +03:00
Ahmet Gedemenli 79a274e226 Fix relname null bug when parallel execution
(cherry picked from commit 69d39c0e8b)
2021-07-12 16:42:15 +03:00
Ahmet Gedemenli dd2dfac198 Remove function GenerateNewTargetEntriesForSortClauses
(cherry picked from commit 9638933d9d)
2021-07-12 16:42:15 +03:00
Sait Talha Nisanci 3bcfadf2f1 update cluster test
(cherry picked from commit 3218e34be9)
2021-07-12 12:18:05 +03:00
Sait Talha Nisanci f5a7858ab9 Not consider old placements when disabling or removing a node
(cherry picked from commit 73c58b6160)
2021-07-12 11:50:39 +03:00
Hanefi Onaldi d7b90e0804
Remove public schema dependency for 10.0 upgrades
This commit contains a subset of the changes that should be cherry
picked to 10.0 releases.

(cherry picked from commit 8e9cc229ff)
2021-07-09 11:55:32 +03:00
Nils Dijk 74985a0977 fix 9.5-2 upgrade script to adhere to idempotency 2021-07-08 12:25:26 +02:00
Nils Dijk 57a52b01a2 Add test for idempotency of citus_prepare_pg_upgrade 2021-07-08 12:25:26 +02:00
Onur Tirtir c24088e12f 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)
2021-07-07 13:13:50 +03:00
Nils Dijk 9a2227c70d Bump use of new sql function 2021-07-05 16:14:52 +02:00
Marco Slot 826ac1b099 Fix PG upgrade scripts for 10.0 2021-07-05 16:14:52 +02:00
Marco Slot d9514fa697 Fix PG upgrade scripts for 9.5 2021-07-05 16:14:52 +02:00
Marco Slot 2f27325b15 Fix PG upgrade scripts for 9.4 2021-07-05 16:14:52 +02:00
Jelte Fennema f41b5060f0 Avoid two race conditions in the rebalance progress monitor (#5050)
The first and main issue was that we were putting absolute pointers into
shared memory for the `steps` field of the `ProgressMonitorData`. This
pointer was being overwritten every time a process requested the monitor
steps, which is the only reason why this even worked in the first place.

To quote a part of a relevant stack overflow answer:

> First of all, putting absolute pointers in shared memory segments is
> terrible terible idea - those pointers would only be valid in the
> process that filled in their values. Shared memory segments are not
> guaranteed to attach at the same virtual address in every process.
> On the contrary - they attach where the system deems it possible when
> `shmaddr == NULL` is specified on call to `shmat()`

Source: https://stackoverflow.com/a/10781921/2570866

In this case a race condition occurred when a second process overwrote
the pointer in between the first process its write and read of the steps
field.

This issue is fixed by not storing the pointer in shared memory anymore.
Instead we now calculate it's position every time we need it.

The second race condition I have not been able to trigger, but I found
it while investigating this. This issue was that we published the handle
of the shared memory segment, before we initialized the data in the
steps. This means that during initialization of the data, a call to
`get_rebalance_progress()` could read partial data in an unsynchronized
manner.

(cherry picked from commit ca00b63272)
2021-06-21 16:42:10 +02:00
Nils Dijk 823ede78ab
Feature: localhost guc (#4836)
DESCRIPTION: introduce `citus.local_hostname` GUC for connections to the current node

Citus once in a while needs to connect to itself for some systems operations. This used to be hardcoded to `localhost`. The hardcoded hostname causes some issues, for example in environments where `sslmode=verify-full` is required. It is not always desirable or even feasible to get `localhost` as an alt name on the certificate.

By introducing a GUC to use when connecting to the current instance the user has more control what network path is used and what hostname is required to be present in the server certificate.
2021-06-01 13:18:15 +02:00
Ahmet Gedemenli 2ea3618f22 Add test for public shard not found issue
(cherry picked from commit 48a6a5b128)
2021-06-01 10:50:26 +03:00
Ahmet Gedemenli 88825b89a1 Fix tests for public schema
(cherry picked from commit d530d79d73)
2021-06-01 10:50:26 +03:00
Ahmet Gedemenli a216c6b62c Remove redundant if statement for schema name
(cherry picked from commit 840c879572)
2021-06-01 10:50:26 +03:00
Sait Talha Nisanci fcb932268a Bump version to 10.0.3 2021-03-17 18:02:01 +03:00
Sait Talha Nisanci 1200c8fd1c Update CHANGELOG for 10.0.3
(cherry picked from commit 92130ae2a2)
2021-03-17 18:01:57 +03:00
Önder Kalacı 0237d826d5 Make sure that single task local executions start coordinated transaction (#4831)
With https://github.com/citusdata/citus/pull/4806 we enabled
2PC for any non-read-only local task. However, if the execution
is a single task, enabling 2PC (CoordinatedTransactionShouldUse2PC)
hits an assertion as we are not in a coordinated transaction.

There is no downside of using a coordinated transaction for single
task local queries.
2021-03-17 14:56:28 +03:00
Ahmet Gedemenli e54b253713 Add udf citus_get_active_worker_nodes
(cherry picked from commit 5e5db9eefa)
2021-03-17 14:56:28 +03:00
Marco Slot 61efc87c53 Replace MAX_PUT_COPY_DATA_BUFFER_SIZE by citus.remote_copy_flush_threshold GUC
(cherry picked from commit fbc2147e11)
2021-03-17 07:35:46 +03:00
Marco Slot f5608c2769 Add GUC to set maximum connection lifetime
(cherry picked from commit 1646fca445)
2021-03-17 07:35:46 +03:00
Marco Slot ecf0f2fdbf Remove unnecessary AtEOXact_Files call
(cherry picked from commit 6c5d263b7a)
2021-03-16 10:01:14 +03:00
Onder Kalaci 0a09551dab Rename use -> shouldUse
Because setting the flag doesn't necessarily mean that we'll
use 2PC. If connections are read-only, we will not use 2PC.
In other words, we'll use 2PC only for connections that modified
any placements.

(cherry picked from commit e65e72130d)
2021-03-16 10:01:14 +03:00
Onder Kalaci 0805ef9c79 Do not trigger 2PC for reads on local execution
Before this commit, Citus used 2PC no matter what kind of
local query execution happens.

For example, if the coordinator has shards (and the workers as well),
even a simple SELECT query could start 2PC:
```SQL

WITH cte_1 AS (SELECT * FROM test LIMIT 10) SELECT count(*) FROM cte_1;
```

In this query, the local execution of the shards (and also intermediate
result reads) triggers the 2PC.

To prevent that, Citus now distinguishes local reads and local writes.
And, Citus switches to 2PC only if a modification happens. This may
still lead to unnecessary 2PCs when there is a local modification
and remote SELECTs only. Though, we handle that separately
via #4587.

(cherry picked from commit 6a7ed7b309)
2021-03-16 10:01:14 +03:00
Naisila Puka a6435b7f6b Fix upgrade and downgrade paths for master/citus_update_table_statistics (#4805)
(cherry picked from commit 71a9f45513)
2021-03-16 10:01:09 +03:00
Marco Slot f13cf336f2 Add tests for modifying CTE and SELECT without FROM
(cherry picked from commit 9c0d7f5c26)
2021-03-16 09:44:00 +03:00
Marco Slot 46e316881b Fixes a crash in queries with a modifying CTE and a SELECT without FROM
(cherry picked from commit 58f85f55c0)
2021-03-16 09:43:24 +03:00
Onur Tirtir 18ab327c6c Add tests for concurrent index deadlock issue (#4775)
(cherry picked from commit 9728ce1167)
2021-03-16 09:42:21 +03:00
Hadi Moshayedi 61a89c69cd Populate DATABASEOID cache before CREATE INDEX CONCURRENTLY
(cherry picked from commit affe38eac6)
2021-03-16 09:41:19 +03:00