Commit Graph

6231 Commits (5e4b05bcaeb3bba6f054c21fda337c8b4bc2174e)

Author SHA1 Message Date
Gürkan İndibay 5e4b05bcae
Bump Citus version to 11.1.7 (#7502) 2024-02-14 08:42:40 +03:00
Gürkan İndibay dff43c7ca4
Adds changelog for 11.1.7 (#7494)
---------

Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
2024-02-13 16:38:03 +03:00
Teja Mupparti 75be4a4d99 Fix the incorrect column count after ALTER TABLE, this fixes the bug #7378 (please read the analysis in the bug for more information)
(cherry picked from commit 00068e07c5)
2024-01-26 18:29:51 -08:00
Gokhan Gulbiz 78f7066b70
Backport GHA Migration to release-11.1 (#7305)
Co-authored-by: Jelte Fennema-Nio <jelte.fennema@microsoft.com>
2023-11-10 11:14:00 +02:00
Onur Tirtir df0458a70e Make sure to disallow creating a replicated distributed table concurrently (#7219)
See explanation in https://github.com/citusdata/citus/issues/7216.
Fixes https://github.com/citusdata/citus/issues/7216.

DESCRIPTION: Makes sure to disallow creating a replicated distributed
table concurrently

(cherry picked from commit 111b4c19bc)
2023-10-24 14:04:30 +03:00
Nils Dijk 87e7e4ee50
Fix leaking of memory and memory contexts in Foreign Constraint Graphs (#7236)
DESCRIPTION: Fix leaking of memory and memory contexts in Foreign
Constraint Graphs

Previously, every time we (re)created the Foreign Constraint
Relationship Graph, we created a new Memory Context while loosing a
reference to the previous context. This old context could still have
left over memory in there causing a memory leak.

With this patch we statically have one memory context that we lazily
initialize the first time we create our foreign constraint relationship
graph. On every subsequent creation, beside destroying our previous
hashmap we also reset our memory context to remove any left over
references.
2023-10-09 13:15:26 +02:00
Gürkan İndibay cdd74f92f4 Removes ubuntu:kinetic pipelines since it's EOL (#7195)
ubuntu:kinetic is EOL so removing it's pipeline

https://fridge.ubuntu.com/2023/06/14/ubuntu-22-10-kinetic-kudu-reaches-end-of-life-on-july-20-2023/
(cherry picked from commit e0683aab84)
2023-09-26 16:54:21 +03:00
Gürkan İndibay 15d3633b7b Removes pg_send_cancellation (#7135)
DESCRIPTION: Removes pg_send_cancellation and all references
(cherry picked from commit 371f094b68)
2023-09-26 16:54:21 +03:00
Hanefi Onaldi 1598a1c59d
Create a new colocation properly after braking one
When braking a colocation, we need to create a new colocation group
record in pg_dist_colocation for the relation. It is not sufficient to
have a new colocationid value in pg_dist_partition only.

This patch also fixes a bug when deleting a colocation group if no
tables are left in it. Previously we passed a relation id as a parameter
to DeleteColocationGroupIfNoTablesBelong function, where we should have
passed a colocation id.

(cherry picked from commit c22547d221)
2023-09-05 11:45:16 +03:00
zhjwpku 18920232b6 PQputCopyData's return value 0 should be considered fail (#7152) 2023-08-29 11:22:09 +02:00
onderkalaci 5c766f4fb5 Improve failure handling of distributed execution
Prior to this commit, the code would skip processing the
    errors happened for local commands.

    Prior to https://github.com/citusdata/citus/pull/5379, it might
    make sense to allow the execution continue. But, as of today,
    if a modification fails on any placement, we can safely fail
    the execution.

(cherry picked from commit b4008bc872)
2023-08-01 13:42:45 +03:00
aykutbozkurt 785c5815bb fix implicit header decleration for commit ca416caae4 2023-06-21 20:39:34 +03:00
aykut-bozkurt ca416caae4 Properly handle error at owner check (#6984)
We did not properly handle the error at ownership check method, which
causes `max stack depth for errors` as in
https://github.com/citusdata/citus/issues/6980.

**Fix:**
In case of an error, we should rollback subtransaction and throw the
message with log level to `LOG_SERVER_ONLY`.

Note: We prevent logs from the client to prevent pg vanilla test
failures due to Citus logs which differs from the actual Postgres logs.
(For context: https://github.com/citusdata/citus/pull/6130)

I also needed to fix a flaky test: `multi_schema_support`

DESCRIPTION: Fixes a bug related to non-existent objects in DDL
commands.

Fixes https://github.com/citusdata/citus/issues/6980

(cherry picked from commit 565c5260fd)
2023-06-21 19:44:11 +03:00
aykut-bozkurt a6afb18578 Rewind tuple store to fix scrollable with hold cursor fetches (#7014)
We need to rewind the tuplestorestate's tuple index to get correct
results on fetching scrollable with hold cursors.

`PersistHoldablePortal` is responsible for persisting out
tuplestorestate inside a with hold cursor before commiting a
transaction.

It rewinds the cursor like below (`ExecutorRewindcalls` calls `rescan`):
```c
if (portal->cursorOptions & CURSOR_OPT_SCROLL)
{
  ExecutorRewind(queryDesc);
}
```

At the end, it adjusts tuple index for holdStore in the portal properly.
```c
if (portal->cursorOptions & CURSOR_OPT_SCROLL)
{
         if (!tuplestore_skiptuples(portal->holdStore,
	                                         portal->portalPos,
	                                         true))
	    elog(ERROR, "unexpected end of tuple stream");
}
```

DESCRIPTION: Fixes incorrect results on fetching scrollable with hold
cursors.

Fixes https://github.com/citusdata/citus/issues/7010

(cherry picked from commit f667f14029)
2023-06-21 19:40:04 +03:00
Hanefi Onaldi 54424583c5 Bump Citus version to 11.1.6 2023-04-25 14:11:51 +03:00
Hanefi Onaldi fe56ca2d74 Add changelog entries for 11.1.6
(cherry picked from commit c36adc8426)
2023-04-25 14:11:51 +03:00
Gürkan İndibay 4f9a344085 Fix packaging test pipelines
We had #6737 fix the same issue on main branch, but we need to fix it on
release branches as well. As the patch does not really apply to earlier
release branches, we just added the fix manually.
2023-04-25 14:11:51 +03:00
Emel Şimşek fb209e9491 When creating a HTAB we need to use HASH_COMPARE flag in order to set a user defined comparison function. (#6845)
DESCRIPTION: Fixes memory errors, caught by valgrind, of type
"conditional jump or move depends on uninitialized value"

When running Citus tests under Postgres with valgrind, the test cases
calling into `NonBlockingShardSplit` function produce valgrind errors of
type "conditional jump or move depends on uninitialized value".

The issue is caused by creating a HTAB in a wrong way. HASH_COMPARE flag
should have been used when creating a HTAB with user defined comparison
function. In the absence of HASH_COMPARE flag, HTAB falls back into
built-in string comparison function. However, valgrind somehow discovers
that the match function is not assigned to the user defined function as
intended.

Fixes #6835

(cherry picked from commit e7a25d82c9)
2023-04-24 15:07:42 +03:00
Emel Şimşek dec4a9c012 Exclude-Generated-Columns-In-Copy (#6721)
DESCRIPTION: Fixes a bug in shard copy operations.

For copying shards in both shard move and shard split operations, Citus
uses the COPY statement.

A COPY all statement in the following form
` COPY target_shard FROM STDIN;`
throws an error when there is a GENERATED column in the shard table.

In order to fix this issue, we need to exclude the GENERATED columns in
the COPY and the matching SELECT statements. Hence this fix converts the
COPY and SELECT all statements to the following form:
```
COPY target_shard (col1, col2, ..., coln) FROM STDIN;
SELECT (col1, col2, ..., coln) FROM source_shard;
```
where (col1, col2, ..., coln) does not include a GENERATED column.
GENERATED column values are created in the target_shard as the values
are inserted.

Fixes #6705.

---------

Co-authored-by: Teja Mupparti <temuppar@microsoft.com>
Co-authored-by: aykut-bozkurt <51649454+aykut-bozkurt@users.noreply.github.com>
Co-authored-by: Jelte Fennema <jelte.fennema@microsoft.com>
Co-authored-by: Gürkan İndibay <gindibay@microsoft.com>
(cherry picked from commit 4043abd5aa)
2023-03-07 20:26:04 +03:00
Jelte Fennema 20141223b6 Use pg_total_relation_size in citus_shards (#6748)
DESCRIPTION: Correctly report shard size in citus_shards view

When looking at citus_shards, people are interested in the actual size
that all the data related to the shard takes up on disk.
`pg_total_relation_size` is the function to use for that purpose. The
previously used `pg_relation_size` does not include indexes or TOAST.
Especially the missing toast can have enormous impact on the size of the
shown data.

(cherry picked from commit b489d763e1)
2023-03-06 11:38:30 +01:00
aykut-bozkurt ba2d8b0fac 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:35:02 +03:00
rajeshkt78 4a7de5e521 Update fix_gitignore.sh
(cherry picked from commit 7d75bbf734)
2023-02-10 16:43:02 +01:00
Rajesh Kumar Thandapani 8f53dab84a Added a workaround for a bug in git ls-files command.
(cherry picked from commit d5abcefc98)
2023-02-10 16:42:52 +01:00
Jelte Fennema 0ff23c07da Support compilation and run tests on latest PG versions (#6711)
Postgres got minor updates this starts using the images with the latest
version for our tests.

These new Postgres versions caused a compilation issue in PG14 and PG13
due to some function being backported that we had already backported
ourselves. Due this backport being a static inline function it doesn't
matter who provides this and there will be no linkage errors when either
running old Citus packages on new PG versions or the other way around.

(cherry picked from commit 3200187757)
2023-02-10 16:37:39 +01:00
Jelte Fennema e67899a620 Fix background rebalance when reference table has no PK (#6682)
DESCRIPTION: Fix background rebalance when reference table has no PK

For the background rebalance we would always fail if a reference table
that was not replicated to all nodes would not have a PK (or replica
identity). Even when we used force_logical or block_writes as the shard
transfer mode. This fixes that and adds some regression tests.

Fixes #6680

(cherry picked from commit 14c31fbb07)
2023-02-10 16:37:39 +01:00
Jelte Fennema d41f88b6f8 Actually skip constraint validation on shards after shard move (#6640)
DESCRIPTION: Fix foreign key validation skip at the end of shard move

In eadc88a we started completely skipping foreign key constraint
validation at the end of a non blocking shard move, instead of only for
foreign keys to reference tables. However, it turns out that this didn't
work at all because of a hard to notice bug: By resetting the
SkipConstraintValidation flag at the end of our utility hook, we
actually make the SET command that sets it a no-op.

This fixes that bug by removing the code that resets it. This is fine
because #6543 removed the only place where we set the flag in C code. So
the resetting of the flag has no purpose anymore. This PR also adds a
regression test, because it turned out we didn't have any otherwise we
would have caught that the feature was completely broken.

It also moves the constraint validation skipping to the utility hook.
The reason is that #6550 showed us that this is the better place to skip
it, because it will also skip the planning phase and not just the
execution.

(cherry picked from commit 81dcddd1ef)
2023-02-10 16:17:58 +01:00
Jelte Fennema 0dfdf9fdd3 Fix regression in allowed foreign keys on distributed tables (#6550)
DESCRIPTION: Fix regression in allowed foreign keys on distributed
tables

In commit eadc88a we changed how we skip foreign key validation. The
goal was to skip it in more cases. However, one change had the
unintended regression of introducing failures when trying to create
certain foreign keys. This reverts that part of the change.

The way of skipping validation of foreign keys that was introduced in
eadc88a was skipping validation during execution. The reason that
this caused this regression was because some foreign key validation
queries already fail during planning. In those cases it never gets to
the execution step where it would later be skipped.

Fixes #6543

(cherry picked from commit 7a7880aec9)
2023-02-10 16:17:26 +01:00
Jelte Fennema ebd9964b99 Quote all identifiers that we use for logical replication (#6604)
In #6598 it was noticed that Citus could generate syntactically invalid
statements during logical replication. With #6603 we resolved the direct
issue, by only generating valid subscription names. But there was also
the underlying problem that we did not escape certain identifier
strings. While in theory this should be okay since we should only
generate names that are valid, this issue reiterated that we should not
take this for granted. As an extra line of defense this quotes all
identifiers we use during logical replication setup.

(cherry picked from commit c2b4087ff0)
2023-02-10 16:08:55 +01:00
Jelte Fennema c70cf963c4 Also reset transactions at connection shutdown (#6685)
In #6314 I refactored the connection cleanup to be simpler to
understand and use. However, by doing so I introduced a use-after-free
possibility (that valgrind luckily picked up):

In the `ShouldShutdownConnection` path of
`AfterXactHostConnectionHandling`
we free connections without removing the `transactionNode` from the
dlist that it might be part of. Before the refactoring this wasn't a
problem, because the dlist would be completely reset quickly after in
`ResetGlobalVariables` (without reading or writing the dlist entries).

The refactoring changed this by moving the `dlist_delete` call to
`ResetRemoteTransaction`, which in turn was called in the
`!ShouldShutdownConnection` path of `AfterXactHostConnectionHandling`.
Thus this `!ShouldShutdownConnection` path would now delete from the
`dlist`, but the `ShouldShutdownConnection` path would not. Thus to
remove itself the deleting path would sometimes update nodes in the list
that were freed right before.

There's two ways of fixing this:
1. Call `dlist_delete` from **both** of paths.
2. Call `dlist_delete` from **neither** of the paths.

This commit implements the second approach, and #6684 implements the
first. We need to choose which approach we prefer.

To make calling `dlist_delete` from both paths actually work, we also need
to use a slightly different check to determine if we need to call dlist_delete.
Various regression tests showed that there can be cases where the
`transactionState` is something else than `REMOTE_TRANS_NOT_STARTED`
but the connection was not added to the `InProgressTransactions` list
One example of such a case is when running `TransactionStateMachine`
without calling `StartRemoteTransactionBegin` beforehand. In those
cases the connection won't be added to `InProgressTransactions`, but
the `transactionState` is changed to `REMOTE_TRANS_SENT_COMMAND`. 

Sidenote: This bug already existed in 11.1, but valgrind didn't catch it
back then. My guess is that this happened because #6314 was merged after
the initial release branch was cut.

Fixes #6638

(cherry picked from commit f061dbb253)
2023-02-03 18:33:42 +03:00
Gürkan İndibay 5a662b4bf9 Fixes validate Output phase of packaging pipeline (#6678)
Pyenv is installed in our container images but I found out that pyenv is
not being activated since it is activated from ~/bashrc script and in
GitHub Actions (GHA) this script is not being executed
Since pyenv is not activated, default python versions comes from docker
images is being used and in this case we get errors for python version
3.11.
Additionally, $HOME directory is /github/home for containers executed
under GHA and our pyenv installation is under /root directory which is
normally home directory for our packaging containers
This PR activates usage of pyenv and additionally uses pyenv virtualenv
feature to execute validate_output function in isolation

---------

Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
(cherry picked from commit d919506076)
2023-01-31 14:01:28 +03:00
Onur Tirtir 1b7b2ecf37 Fall-back to seq-scan when accessing columnar metadata if the index doesn't exist
Fixes #6570.

In the past, having columnar tables in the cluster was causing pg
upgrades to fail when attempting to access columnar metadata. This is
because, pg_dump doesn't see objects that we use for columnar-am related
booking as the dependencies of the tables using columnar-am.
To fix that; in #5456, we inserted some "normal dependency" edges (from
those objects to columnar-am) into pg_depend.

This helped us ensuring the existency of a class of metadata objects
--such as columnar.storageid_seq-- and helped fixing #5437.

However, the normal-dependency edges that we added for indexes on
columnar metadata tables --such columnar.stripe_pkey-- didn't help at
all because they were indeed causing dependency loops (#5510) and
pg_dump was not able to take those dependency edges into the account.

For this reason, instead of inserting such dependency edges from indexes
to columnar-am, we allow columnar metadata accessors to fall-back to
sequential scan during pg upgrades.

(cherry picked from commit 1c51ddae49)
2023-01-30 18:55:42 +03:00
aykut-bozkurt 30ba5fe2b4 fix dropping table_name option from foreign table (#6669)
We should disallow dropping table_name option if foreign table is in
metadata. Otherwise, we get table not found error which contains
shardid.

DESCRIPTION: Fixes an unexpected foreign table error by disallowing to drop the table_name option.

Fixes #6663

(cherry picked from commit 8a9bb272e4)
2023-01-30 17:55:11 +03:00
Gokhan Gulbiz e74597b419 Allow plain pg foreign tables without a table_name option (#6652)
(cherry picked from commit 4e26464969)
2023-01-30 17:54:45 +03:00
Ahmet Gedemenli 9e32e34313 Fix crash when trying to replicate a ref table that is actually dropped (#6595)
DESCRIPTION: Fix crash when trying to replicate a ref table that is actually dropped

see #6592
We should have a real solution for it.

(cherry picked from commit bc3383170e)
2023-01-10 13:20:36 +03:00
Ahmet Gedemenli 57dc187e53 Use %u instead of %i for naming subscriptions & roles
(cherry picked from commit e37c4af1bb)
2023-01-06 16:56:18 +03:00
Hanefi Onaldi 8e0ce65d6d
Bump Citus version to 11.1.5 2022-12-20 14:39:51 +03:00
Hanefi Onaldi deb4f11749
Add changelog entries for 11.1.5
(cherry picked from commit 4eb555721f)
2022-12-20 14:38:43 +03:00
Gürkan İndibay 68dbafcf16
Add jobs to test builds on different distros (release-11.1) (#6541)
With this PR, citus code will be tested in all packaging environments.
Sometimes, there can be compile errors which blocks packaging and in
this case unplanned delays may occur.
By testing the code in packaging environments, I'm aiming to detect any
compilation errors before packaging.

Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
Co-authored-by: Hanefi Onaldi <Hanefi.Onaldi@microsoft.com>

DESCRIPTION: PR description that will go into the change log, up to 78
characters

Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
Co-authored-by: Hanefi Onaldi <Hanefi.Onaldi@microsoft.com>
2022-12-05 14:24:09 +03:00
Jelte Fennema 8c1cca1a87 Correctly fix OpenSSL 3.0 warnings (#6502)
In #6038 I tried to fix OpenSSL 3.0 warnings with PG13, but I had made a
mistake when doing that. This actually fixes these warnings.

(cherry picked from commit a477ffdf4b)
2022-12-05 09:31:55 +01:00
Teja Mupparti 3a3c037b3b Fix the dangling pointer bug in get_merged_argument_list()
(cherry picked from commit edaf88e0ff)
2022-11-22 11:08:11 -08:00
Onur Tirtir 486a3b6be9 Fix dangling pointer warning in AnyTableReplicated (#6504)
DESCRIPTION: Fixes a potential dangling pointer issue

Need to backport to 11.0 & 11.1 since we might want to release packages
for debian/bookworm based on those branches in future.

(cherry picked from commit 80faf47ab5)
2022-11-21 16:43:47 +03:00
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