Commit Graph

6190 Commits (846cf8e3d717d232d615064f4c76f8ca0ba8eed7)

Author SHA1 Message Date
Hanefi Onaldi 846cf8e3d7
Bump Citus version to 11.1.4 2022-10-24 12:51:11 +03:00
Hanefi Onaldi b5b2726985
Add changelog entries for 11.1.4
(cherry picked from commit 7c5b787b9c)
2022-10-24 12:50:25 +03:00
aykut-bozkurt 6c51d5f403 Drop worker_fetch_foreign_file/worker_repartition_cleanup only if they exist when upgrading Citus (#6441)
We should not introduce breaking sql changes to upgrade files after they
are released. We did that for worker_fetch_foreign_file in v9.0.0 and
worker_repartition_cleanup in v9.2.0. Later when we try to drop those
udfs, they were missing for some clients unexpectedly due to breaking
change in an old upgrade script. For that case, the fix is to add DROP
IF EXISTS for those 2 udfs in 11.0-4--11.1-1.

(cherry picked from commit 162c8a5160)
2022-10-21 13:49:46 +03:00
Hanefi Onaldi 1128862e7b
Bump PG15 CI images to 15.0 (#6439)
Related: citusdata/the-process#95
(cherry picked from commit 82ea76bc0c)
2022-10-15 13:15:25 +03:00
Hanefi Onaldi 51ef251535
Bump Citus version to 11.1.3 2022-10-14 13:51:26 +03:00
Hanefi Onaldi 5efbc758ef
Add changelog entries for 11.1.3 (#6435)
(cherry picked from commit 4d037f03fe)
2022-10-14 13:50:12 +03:00
Onur Tirtir 452b6a2212 Hint users to call "citus_set_coordinator_host" first (#6425)
If an operation requires having coordinator in pg_dist_node and if that
is not the case, then we automatically add the coordinator into
pg_dist_node if user didn't add any worker nodes yet.

However, if user have already added some worker nodes before, we throw
an error. With this commit, we improve the error thrown in that case.

Closes #6423 based on the discussion made there.

(cherry picked from commit 20847515fa)
2022-10-12 18:29:39 +03:00
Hanefi Onaldi 26ae4b8fb3 Rename a function that collides with PG15 (#6422)
PG15 introduced a function called ReplicationSlotName that causes
conflicts with our function with the same name. I solved this issue by
renaming our function to ReplicationSlotNameForNodeAndOwner

Relevant PG commit:
c3b5992b91

(cherry picked from commit ec3eebbaf6)
2022-10-12 17:01:21 +03:00
Hanefi Onaldi 64db74c051 Remove references to optimization PG15 reverted
PG15 introduced an optimization on GROUP BY keys that is now reverted on
RC2.

Relevant PG commit:
Revert "Optimize order of GROUP BY keys".
443df6e2db932a7cd6d85ddfb67e11a43345130d

(cherry picked from commit cbe4298c5b)
2022-10-12 17:01:05 +03:00
Hanefi Onaldi 4f2a563df3 Bump PG15 CI images to rc2
(cherry picked from commit 30af70926f)
(cherry picked from commit 6c2a3c0651ae2a16a7fb8fa0d82079162c02fd95)
2022-10-12 16:59:55 +03:00
Hanefi Onaldi 90a2fb3a67 Bump PG15 CI images to rc1
(cherry picked from commit a38428b665)
(cherry picked from commit 80e68810cb53075ffdd5a10a0a8ab3941f0d9d32)
2022-10-12 16:59:20 +03:00
Hanefi Onaldi 0488697ff3 Update hints on trigger rename of partitions
There is a new commit in REL_15_STABLE that improves message styles.

Relevant PG commit:
517484b5820e9e20057ff066b5df7d09cbb5f464

(cherry picked from commit 8be8eb9d8c)
2022-10-12 15:16:24 +03:00
Hanefi Onaldi f06ae0c106 Add tests for CREATE DATABASE with OID option (#6376)
PG15 now allows users to specify oids when creating databases. This
feature is a side effect of a bigger feature in pg_upgrade.

Relevant PG Commit:
pg_upgrade: Preserve database OIDs.
aa01051418f10afbdfa781b8dc109615ca785ff9

(cherry picked from commit 7e0edee4ec)
2022-10-12 15:15:39 +03:00
Naisila Puka 0bbfbf3c36 Tests moving a shard with RLS owned by nonbypassrls & nonsuperuser (#6369)
(cherry picked from commit 63e4d23722)
2022-10-12 15:14:44 +03:00
Naisila Puka 2e06e62476 Adds tests for suppressed constants in postgres_fdw queries (#6370)
PG15 has suppressed some casts on constants when querying foreign
tables.
For example, we can use text to represent a type that's an enum on the
remote side.
A comparison on such a column will get shipped as "var = 'foo'::text".
But there's no enum = text operator on the remote side.
If we leave off the explicit cast, the comparison will work.

Test we behave in the same way with a Citus foreign table
Reminder: foreign tables cannot be distributed/reference, can only be
Citus local

Relevant PG commit:
f8abb0f5e1

(cherry picked from commit 1b26d57288)
2022-10-12 15:14:04 +03:00
Hanefi Onaldi 5294df1602 Add tests for jsonpath changes on PG15
PostgreSQL 15 had some changes to jsonpath to conform with ECMA-262
referenced by SQL standard. This commit adds tests to make sure Citus
also supports the same standards.

Relevant pg commit:
e26114c817b610424010cfbe91a743f591246ff1

(cherry picked from commit 30ac6f0fe9)
2022-10-12 15:13:08 +03:00
Naisila Puka 781960d16b Comment about column list for fk ON DELETE SET in PG15 (#6372)
As a part of
a868cc049a

(cherry picked from commit dc9723fa45)
2022-10-12 15:12:00 +03:00
Naisila Puka 4e54d1f0be Add tests to verify we support security invoker views (#6362)
PG15 added support for security invoker views. Relevant PG conmit:
7faa5fc84b

These views check the permissions for the underlying tables of the view
invoker user, not the view definer user.

When the view has underlying distributed tables, the queries to the
shards are sent by opening connections with the current user, which is
the view invoker, no matter what the type of the view is. This means
that, for distributed views, they were always behaving like security
invoker views. Check the following issue for more details:
https://github.com/citusdata/citus/issues/6161
So, Citus doesn't fully support security definer views.

However Citus does fully support security invoker views. We add tests to
make sure we cover different cases.

(cherry picked from commit 1ede0b9db3)
2022-10-12 15:10:37 +03:00
Onder Kalaci 270a18ca06 Add tests for PG15 new aggregate commands
Both tests include pushdown and pull to coordinator type of aggregate
execution.

Relevant PG commits:

Add min() and max() aggregates for xid8
400fc6b6487ddf16aa82c9d76e5cfbe64d94f660

Add range_agg with multirange inputs
7ae1619bc5b1794938c7387a766b8cae34e38d8a

Co-authored-by: Onder Kalaci <onderkalaci@gmail.com>
(cherry picked from commit 03ac8b4f82)
2022-10-12 15:07:15 +03:00
Naisila Puka 71d049025d Fixes empty password issue (#6417)
(cherry picked from commit 89aa9a015f)
2022-10-11 15:59:43 +03:00
Onur Tirtir d6f20392b8 Use memcpy instead of memcpy_s to avoid pointless limits in columnar (#6419)
DESCRIPTION: Raises memory limits in columnar from 256MB to 1GB for
reads and writes

This doesn't completely fix #5918 but at least increases the
buffer limits that might cause throwing an error when reading
from or writing into into columnar storage. A way better approach
to fix this is documented in #6420.

Replacing memcpy_s with memcpy is quite safe in those places
since we anyway make sure to allocate enough amount of memory
before writing into related buffers.

(cherry picked from commit 0b81f68def)
2022-10-11 15:01:39 +03:00
Onur Tirtir 5417fffc70 Fix use-after-free in GetAlterTriggerStateCommand() (#6413)
Fix use-after-free in GetAlterTriggerStateCommand() introduced in #6398.

(cherry picked from commit 517b72a9d5)
2022-10-10 16:38:59 +03:00
Onur Tirtir c2c0b97a5b Retain trigger settings when re-creating the triggers (on shards) (#6398)
Fixes https://github.com/citusdata/citus/issues/6394.

DESCRIPTION: Fixes a bug that causes creating disabled-triggers on
shards as enabled

Since CREATE TRIGGER doesn't have syntax support to specify
whether the trigger should be enabled/disabled, the underlying
PG function (`pg_get_triggerdef()`) that we use to generate the
command to create the trigger is not enough. For this reason, we
append a second command to enable/disable trigger, right after
creating it.

We don't retain explicit extension dependencies set by using
`ALTER trigger DEPENDS ON EXTENSION` commands too, but apparently
right fix for that is to throw an error as in
`PreprocessAlterTriggerDependsStmt()`; so, opened a separate PR
to fix that #6399.

(cherry picked from commit 86e186f671)
2022-10-10 11:24:36 +03:00
Ying Xu cf3018bd5a
[Columnar] Bugfix for Columnar: options ignored during ALTER TABLE (#6411)
DESCRIPTION: Fixes a bug that prevents retaining columnar table options
after a table-rewrite A fix for this issue: Columnar: options ignored
during ALTER TABLE rewrite #5927
The OID for the temporary table created during ALTER TABLE was not the
same as the original table's OID so the columnar options were not being
applied during rewrite.

The change is that I applied the original table's columnar options to
the new table so that it has the correct options during write. I also
added a test.

Cherry-pick from commit f21cbe68f8
2022-10-09 22:30:54 -07:00
Naisila Puka b926fe8114 Use original relation to retrieve column name because of syscache (#6387)
During alter_distributed_table, we create a new table like the
original table but with the altered options.

To retrieve the name of the distribution column, we were using
the attribute syscache of the new table, since we already created
the new table as identical to the original table.

However, the attribute syscaches of these two tables are not
the same if the original table has dropped columns. The reason
is that dropped columns are all still present in the cache.
Hence, for example, the attnos would be different in the syscaches.

So, let's use the attribute syscache of the original table.
2022-10-06 12:13:57 +03:00
Hanefi Onaldi 84e43424fc
Ensure no dependencies to index before drop
(cherry picked from commit 11a9a3771f)
2022-10-04 21:08:56 +03:00
Hanefi Onaldi d2181aec7f
Document failing downgrades from 10.2-4 to 10.2-2
(cherry picked from commit 5ddd4754a2)
2022-10-04 21:08:56 +03:00
Hanefi Onaldi 8a1c0ae821
Fix tests for missing downgrades
(cherry picked from commit 0efd6f7829)
2022-10-04 21:08:56 +03:00
Hanefi Onaldi ee66ca06a8
Note PG release candidate support in changelog (#6390)
Co-authored-by: Joe Nelson <jonels@microsoft.com>
(cherry picked from commit 580ab012bf)
2022-09-30 22:26:52 +03:00
Onur Tirtir 9b19e41e46 Add changelog entries for 11.1.2 (#6386)
(cherry picked from commit 17cf137c4c)
2022-09-30 13:07:28 +03:00
Onur Tirtir 10be12e4be Bump citus version to 11.1.2 2022-09-30 13:06:12 +03:00
Jelte Fennema 006f6aceaf Reuse connections for Splits and Logical Replication (#6314)
In Split, Logical replication logic and ShardCleaner we call
`SendCommandListToWorkerOutsideTransaction` and
`SendOptionalCommandListToWorkerOutsideTransaction` frequently. This
opens new connection for each of those calls, even though we already
have a perfectly good connection lying around.

This PR adds two new APIs
`SendCommandListToWorkerOutsideTransactionWithConnection` and
`SendOptionalCommandListToWorkerOutsideTransactionWithConnection` that
allow sending a list of queries in a transaction over an existing
connection. We also update the callers (Split, ShardCleaner, Logical
Replication) to use these new APIs instead.

Co-authored-by: Nitish Upreti <niupre@microsoft.com>
Co-authored-by: Onder Kalaci <onderkalaci@gmail.com>
(cherry picked from commit 24e06af6d2)
2022-09-26 16:53:38 +02:00
Jelte Fennema ebe70adc92 Revert replica identity creation order for shard moves (#6367)
In Citus 11.1.0 we changed the order of doing the initial data copy and
the replica identity creation when doing a non blocking shard move. This
was done to try and increase the speed with which shard moves could be
done. But after doing more extensive performance testing this change
turned out to have a negative impact on the speed of moves on the setups
that I tested.

Looking at the resource usage metrics of the VMs the reason for this
seems to be that these shard moves were bottlenecked by disk bandwidth.
While creating replica identities in bulk after the initial copy will
reduce CPU usage a bit, it does require an additional sequence scan of
the just written data. So when a VM is bottlenecked on disk, it makes
sense to spend a little bit more CPU to avoid an additional scan. Since
PKs are usually simple indexes that don't require lots of CPU to update,
as opposed to e.g. GiST indexes.

This reverts the order change to avoid a regression on shard move speed
in these cases.

For future releases we might consider re-evaluating our index creation
order for other indexes too, and create "simple" indexes before the
copy.

(cherry picked from commit d9a9a3263b)
2022-09-26 16:53:30 +02:00
Onur Tirtir b9e4364acc Not allow ON DELETE/UPDATE SET DEFAULT actions on columns that default to sequences (#6340)
Given that we drop DEFAULT nextval('sequence') expressions from
shard relation columns, allowing `ON DELETE/UPDATE SET DEFAULT`
on such columns might cause inserting NULL values as a result
of a delete/update operation.

For this reason, we disallow ON DELETE/UPDATE SET DEFAULT actions
on columns that default to sequences.

DESCRIPTION: Disallows having ON DELETE/UPDATE SET DEFAULT actions on
columns that default to sequences

Fixes #6339.

(cherry picked from commit a868cc049a)

 Conflicts:
	src/test/regress/expected/pg15.out
	src/test/regress/sql/pg15.sql
2022-09-23 13:55:51 +03:00
Onur Tirtir 53ec5abb75 Not drop default col exprs from shard when adding local table to metadata (#6323)
As we did for GENERATED STORED columns in #4613, we should not drop
column
default expressions that are not based on sequences from shard relation
since
such expressions need to exist e.g. for foreign key actions.

For the column default expressions that are based on sequences we cannot
do much, so we need to disallow having ON DELETE SET DEFAULT actions on
such columns in a separate PR, see #6339.

Fixes #6318.

DESCRIPTION: Fixes a bug that might cause inserting incorrect DEFAULT
values when applying foreign key actions

(cherry picked from commit de24a3eda5)
2022-09-23 13:53:04 +03:00
Ahmet Gedemenli ecaa0cda6d Fix dropping replication slot (#6359)
DESCRIPTION: Fixes dropping replication slots

As detected by a flaky test, Citus sometimes fails to drop replication
slots, possibly due to a race condition, at the end of a shard split.
With this PR, we retry to drop them in case of an `OBJECT_IN_USE` error,
consistently for 20 seconds.

fixes: #6326
(cherry picked from commit bae4b47c2f)
2022-09-22 11:31:37 +03:00
Nitish Upreti a8e7c2cb09 Shard Split : Add / Update logging (#6336)
DESCRIPTION: Improve logging during shard split and resource cleanup

### DESCRIPTION

This PR makes logging improvements to Shard Split : 

1. Update confusing logging to fix #6312
2. Added new `ereport(LOG` to make debugging easier as part of telemetry review.
2022-09-16 10:11:37 -07:00
Onur Tirtir b7ae596fe8
Bump citus version to 11.1.1 (#6356) 2022-09-16 12:33:09 +03:00
Onur Tirtir 6f4324623c Add changelog entries for 11.1.1 (#6354)
(cherry picked from commit 8b5cdaf0e9)
2022-09-16 12:17:25 +03:00
Marco Slot d5db0adc17 Allow create_distributed_table_concurrently on an empty node (#6353)
Co-authored-by: Marco Slot <marco.slot@gmail.com>
2022-09-16 12:17:25 +03:00
Onur Tirtir 099523452e Add changelog entries for 11.1.0 (#6349)
Created by executing `prepare_changelog.pl citus 11.1.0 2022-03-29`.

(cherry picked from commit 57e354ac91)
2022-09-16 11:20:00 +03:00
Onder Kalaci af448da1a7 Prevent failures on partitioned distributed tables with statistics objects on PG 15
Comment from the code is clear on this:
/*
 * The statistics objects of the distributed table are not relevant
 * for the distributed planning, so we can override it.
 *
 * Normally, we should not need this. However, the combination of
 * Postgres commit 269b532aef55a579ae02a3e8e8df14101570dfd9 and
 * Citus function AdjustPartitioningForDistributedPlanning()
 * forces us to do this. The commit expects statistics objects
 * of partitions to have "inh" flag set properly. Whereas, the
 * function overrides "inh" flag. To avoid Postgres to throw error,
 * we override statlist such that Postgres does not try to process
 * any statistics objects during the standard_planner() on the
 * coordinator. In the end, we do not need the standard_planner()
 * on the coordinator to generate an optimized plan. We call
 * into standard_planner() for other purposes, such as generating the
 * relationRestrictionContext here.
 *
 * AdjustPartitioningForDistributedPlanning() is a hack that we use
 * to prevent Postgres' standard_planner() to expand all the partitions
 * for the distributed planning when a distributed partitioned table
 * is queried. It is required for both correctness and performance
 * reasons. Although we can eliminate the use of the function for
 * the correctness (e.g., make sure that rest of the planner can handle
 * partitions), it's performance implication is hard to avoid. Certain
 * planning logic of Citus (such as router or query pushdown) relies
 * heavily on the relationRestrictionList. If
 * AdjustPartitioningForDistributedPlanning() is removed, all the
 * partitions show up in the, causing high planning times for
 * such queries.
 */
2022-09-15 14:37:28 +03:00
Sameer Awasekar acccad9879 Introduce code changes to fix Issue:6303 (#6328)
The PR introduces code changes to fix Issue
[6303](https://github.com/citusdata/citus/issues/6303)

`create_distributed_table_concurrently` following drop column, creates a
buggy situation in split decoder.
 * Consider the below scenario:
* Session1 : Drop column followed by
create_distributed_table_concurrently
 * Session2 : Concurrent insert workload

The child shards created by `create_distributed_table_concurrently` will
have less columns than the source shard because some column were
dropped. The incoming tuple from session2 will have more columns as the
writes happened on source shard. But now the tuple needs to be applied
on child shard. So we need to format existing tuple according to child
schema and skip dropped column values.
The PR fixes this by reformatting the tuple according the target child
schema.

Test:
1) isolation_create_distributed_concurrently_after_drop_column - Repros
the issue and tests on the same.
2022-09-15 09:48:43 +02:00
aykut-bozkurt 77947da17c ensure we have more active nodes than replication factor. (#6341)
DESCRIPTION: Fixes floating exception during
create_distributed_table_concurrently.

Fixes #6332.
During create_distributed_table_concurrently, when there is no active
primary node, it fails with floating exception. We added similar check
with create_distributed_table. It will fail with proper message if
current active node is less than replication factor.

(cherry picked from commit 739b91afa6)
2022-09-14 18:22:58 +03:00
Marco Slot 7d56c25e28 Fix escaping in sequence dependency queries (#6345)
Co-authored-by: Marco Slot <marco.slot@gmail.com>
2022-09-14 16:52:25 +02:00
Marco Slot eba70af7a2 Fix bugs in CheckIfRelationWithSameNameExists (#6343)
Co-authored-by: Marco Slot <marco.slot@gmail.com>
2022-09-14 15:59:43 +02:00
Hanefi Onaldi 3f33390f45 Bump Citus version to 11.1.0 2022-09-14 14:21:43 +03:00
Nils Dijk 7b51f3eee2
Fix: rebalance stop non super user (#6334)
No need for description, fixing issue introduced with new feature for
11.1

Fixes #6333 

Due to Postgres' C api being o-indexed and postgres' attributes being
1-indexed, we were reading the wrong Datum as the Task owner when
cancelling. Here we add a test to show the error and fix the off-by-one
error.
2022-09-13 23:20:06 +02:00
Hanefi Onaldi f34467dcb3
Remove missing declaration warning (#6330)
When I built Citus on PG15beta4 locally, I get a warning message.

```
utils/background_jobs.c:902:5: warning: declaration does not declare anything
      [-Wmissing-declarations]
                                __attribute__((fallthrough));
                                ^
1 warning generated.
```

This is a hint to the compiler that we are deliberately falling through
in a switch-case block.
2022-09-13 13:48:51 +03:00
Jelte Fennema f13b140621
Show citus_copy_shard_placement progress in get_rebalance_progress (#6322)
DESCRIPTION: Show citus_copy_shard_placement progress in
get_rebalance_progress

When rebalancing to a new node that does not have reference tables yet
the rebalancer will first copy the reference tables to the nodes.
Depending on the size of the reference tables, this might take a long
time. However, there's no indication of what's happening at this stage
of the rebalance.

This PR improves this situation by also showing the progress of any
citus_copy_shard_placement calls when calling get_rebalance_progress.
2022-09-13 08:59:52 +00:00