Commit Graph

4711 Commits (11db00990f5f8ffd1905df17be0cb807672fe35d)

Author SHA1 Message Date
Hanefi Onaldi 11db00990f
Bump Citus version to 10.0.8 2023-04-26 16:05:20 +03:00
Hanefi Onaldi bd5544fdc5
Add missing entry for 10.0.8 2023-04-26 16:05:20 +03:00
Hanefi Onaldi e5e50570b3
Add changelog entries for 10.0.8 2023-04-26 13:31:50 +03:00
aykut-bozkurt 758cda1394 fix single tuple result memory leak (#6724)
We should not omit to free PGResult when we receive single tuple result
from an internal backend.
Single tuple results are normally freed by our ReceiveResults for
`tupleDescriptor != NULL` flow but not for those with `tupleDescriptor
== NULL`. See PR #6722 for details.

DESCRIPTION: Fixes memory leak issue with query results that returns
single row.

(cherry picked from commit 9e69dd0e7f)
2023-02-17 14:41:30 +03:00
Halil Ozan Akgul 8b4bab14a2 Fixes the bug where undistribute can drop Citus extension
(cherry picked from commit b255706189)

 Conflicts:
	src/backend/distributed/commands/alter_table.c
	src/include/distributed/metadata/dependency.h
2022-06-13 16:36:59 +03:00
jeff-davis 115f2c124a Columnar: fix wraparound bug. (#5962)
columnar_vacuum_rel() now advances relfrozenxid.

Fixes #5958.

(cherry picked from commit 74ce210f8b)
2022-05-27 09:33:18 -07:00
Onur Tirtir 4b7af5aaaf Fix coordinator/worker query targetlists for agg. that we cannot push-down (#5679)
Previously, we were wrapping targetlist nodes with Vars that reference
to the result of the worker query, if the node itself is not `Const` or
not a `Param`. Indeed, we should not do that unless the node itself is
a `Var` node or contains a `Var` within it (e.g.: `OpExpr(Var(column_a) > 2)`).
Otherwise, when worker query returns empty result set, then combine
query exec would crash since the `Var` would be pointing to an empty
tuple slot, which is not desirable for the node-executor methods.

(cherry picked from commit 79442df1b7)
2022-02-07 11:40:39 +03:00
Onur Tirtir 6b87b3ea27 Skip deleting options if columnar.options is already dropped (#5458)
Drop extension might cascade to columnar.options before dropping a
columnar table. In that case, we were getting below error when opening
columnar.options to delete records for the columnar table that we are
about to drop.: "ERROR:  could not open relation with OID 0".

I somehow reproduced this bug easily when upgrading pg, that is why
adding added the test to after_pg_upgrade_schedule.

(cherry picked from commit 25024b776e)

 Conflicts:
	src/test/regress/after_pg_upgrade_schedule
	src/test/regress/expected/upgrade_columnar_after.out
	src/test/regress/sql/upgrade_columnar_after.sql
2021-11-12 15:17:59 +03:00
Hanefi Onaldi d13b989cff
Bump Citus version to 10.0.6 2021-11-12 14:14:33 +03:00
Hanefi Onaldi 0f62f1a93a
Add changelog entries for 10.0.6
(cherry picked from commit 45549d20a6)
2021-11-12 14:12:16 +03:00
Sait Talha Nisanci 83585e32f9 Adjust tests for release-10.0 2021-11-08 12:51:23 +03:00
Sait Talha Nisanci 0f1f55c287 Fix missing from entry
(cherry picked from commit a0e0759f73)
2021-11-08 12:39:23 +03:00
Onder Kalaci 3e8348c29e Deparse/parse the local cached queries
With local query caching, we try to avoid deparse/parse stages as the
operation is too costly.

However, we can do deparse/parse operations once per cached queries, right
before we put the plan into the cache. With that, we avoid edge
cases like (4239) or (5038).

In a sense, we are making the local plan caching behave similar for non-cached
local/remote queries, by forcing to deparse the query once.

(cherry picked from commit 69ca943e58)
2021-11-08 12:38:11 +03:00
Nils Dijk 537618aaed
reinstate optimization that got unintentionally broken in 366461ccdb (#5418)
DESCRIPTION: Reinstate optimisation for uniform shard interval ranges

During a refactor introduced in #4132 the following change was made, which made the optimisation in `CalculateUniformHashRangeIndex` unreachable: 
366461ccdb (diff-565a339ed3c78bc5a0d4ffeb4e91032150b1dffbeeff59cd3e65981d20b998c7L319-R319)

This PR reinstates the path to the optimisation!
2021-11-05 13:09:25 +01:00
Onur Tirtir 6c989830d2 Add CheckCitusVersion() calls to columnarAM (#5308)
Considering all code-paths that we might interact with a columnar table,
add `CheckCitusVersion` calls to tableAM callbacks:
- initializing table scan (`columnar_beginscan` & `columnar_index_fetch_begin`)
- setting a new filenode for a relation (storage initializiation or a table rewrite)
- truncating the storage
- inserting tuple (single and multi)

Also add `CheckCitusVersion` call to:
- drop hook (`ColumnarTableDropHook`)
- `alter_columnar_table_set` & `alter_columnar_table_reset` UDFs
(cherry picked from commit f8b1ff7214)

 Conflicts:
	src/backend/columnar/cstore_tableam.c
	src/test/regress/expected/multi_extension.out
	src/test/regress/sql/multi_extension.sql

 Note: Not applying multi_extension.sql/out changes to 10.0 since
       previous Citus version (9.5) already doesn't have columnarAM.
2021-09-20 17:45:27 +03:00
Marco Slot 259511746e Small fix to PG12 compatibility 2021-09-10 14:21:03 +02:00
Marco Slot bd245b5fbb Avoid switch to superuser in worker_merge_files_into_table 2021-09-10 13:25:52 +02:00
Marco Slot 25c71fb3d0 Add worker_append_table_to_shard permissions tests 2021-09-10 13:25:52 +02:00
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