Commit Graph

5252 Commits (4bc11c9bb4ecefc2f840dc5904b34d14500e4a35)

Author SHA1 Message Date
Hanefi Onaldi 4bc11c9bb4
Bump Citus version to 10.2.9 2023-04-25 15:51:16 +03:00
Hanefi Onaldi e5a9ef584b
Add changelog entries for 10.2.9
(cherry picked from commit 65f957d345)
2023-04-25 15:50:30 +03:00
Jelte Fennema f508898c8d 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:56:05 +01:00
aykut-bozkurt 46babb9cdf 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:38:36 +03:00
Onur Tirtir 8071c07cd8 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)
(cherry picked from commit b9e18406fa)
2023-01-30 19:15:28 +03:00
Ying Xu 5347a10f7e [Columnar] Bugfix for Columnar: options ignored during ALTER TABLE rewrite (#6337)
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 picked from commit 868bc37670)
2022-10-11 15:03:47 +03:00
Onur Tirtir 9e8c7b4484 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:02:42 +03:00
Hanefi Onaldi 8fd0aff620
Ensure no dependencies to index before drop
(cherry picked from commit 11a9a3771f)
2022-10-04 20:40:36 +03:00
Hanefi Onaldi f3ebea7e64
Document failing downgrades from 10.2-4 to 10.2-2
(cherry picked from commit 5ddd4754a2)
2022-10-04 20:40:36 +03:00
Hanefi Onaldi 0b0b740955
Fix tests for missing downgrades
(cherry picked from commit 0efd6f7829)
2022-10-04 20:40:36 +03:00
Naisila Puka d605cde3b7 Use RelationGetPrimaryKeyIndex for citus catalog tables (#6262)
pg_dist_node and pg_dist_colocation have a primary key index, not a replica identity index.

Citus catalog tables are created in public schema, which has replica identity index by default 
as primary key index. Later the citus catalog tables are moved to pg_catalog schema.

During pg_upgrade, all tables are recreated, and given that pg_dist_colocation is found in
pg_catalog schema, it is recreated in that schema, and when it is recreated it doesn't
have a replica identity index, because catalog tables have no replica identity.

Further action:
Do we even need to acquire this lock on the primary key index?
Postgres doesn't acquire such locks on indexes before deleting catalog tuples.
Also, catalog tuples don't have replica identities by definition.
2022-09-22 12:52:34 +03:00
Onur Tirtir 2badbf3b55 Add a changelog entry for 10.2.8
(cherry picked from commit 93bcd39a83)
2022-08-19 15:31:40 +03:00
Onur Tirtir 1440cd1a7a Bump citus version to 10.2.8 2022-08-19 15:31:40 +03:00
Jelte Fennema c0d2c7be44 Remove warnings on PG13 + OpenSSL 3.0
OpenSSL 3.0 has marked some functions that we use as deprecated, but we
want to continue support OpenSSL 1.0.1 for the time being too. This
indicates that to OpenSSL 3.0, so it doesn't show warnings.

(cherry picked from commit 58e8da8339a4540dff4baf589ab6efc506ac2e6b)
2022-08-19 15:31:40 +03:00
Onur Tirtir 1a5fb8a9a6
Fix upgrade script one more time (#6206)
Seems that we incorrectly added the same migration file into downgrades/ and this causes some warnings on Citus repo's CI & when building packages.

The same problem doesn't exist on main, so opened the PR against release-10.2 branch.

```
Makefile:71: warning: overriding recipe for target '/home/onurctirtir/citus/src/backend/distributed/build/sql/citus--10.2-5--10.2-4.sql'
Makefile:62: warning: ignoring old recipe for target '/home/onurctirtir/citus/src/backend/distributed/build/sql/citus--10.2-5--10.2-4.sql'
Makefile:71: warning: overriding recipe for target '/home/onurctirtir/citus/src/backend/distributed/build/sql/citus--10.2-5--10.2-4.sql'
Makefile:62: warning: ignoring old recipe for target '/home/onurctirtir/citus/src/backend/distributed/build/sql/citus--10.2-5--10.2-4.sql'
```
2022-08-19 15:01:33 +03:00
Onur Tirtir 814d302ba8 Add changelog entries for 10.2.7
(cherry picked from commit efb0d5f48e)
2022-08-19 11:08:11 +03:00
Onur Tirtir 664b11a249 Bump citus version to 10.2.7 2022-08-19 10:55:03 +03:00
Jelte Fennema 9bf79e2ebf
Fix flakyness in isolation_reference_table (#6193)
The newly introduced isolation_reference_table test had some flakyness,
because the assumption on how the arbitrary reference table gets chosen
was incorrect. This introduces a VACUUM FULL at the start of the test to
ensure the assumption actually holds.

Example of failed test: https://app.circleci.com/pipelines/github/citusdata/citus/26108/workflows/0a5cd526-006b-423e-8b67-7411b9c6be36/jobs/736802
2022-08-18 14:59:00 +02:00
Nils Dijk 8bbfff34c6
Fix reference table lock contention (#6173)
DESCRIPTION: Fix reference table lock contention

Dropping and creating reference tables unintentionally blocked on each other due to the use of an ExclusiveLock for both the Drop and conditionally copying existing reference tables to (new) nodes.

The patch does the following:
 - Lower lock lever for dropping (reference) tables to `ShareLock` so they don't self conflict
 - Treat reference tables and distributed tables equally and acquire the colocation lock when dropping any table that is in a colocation group
 - Perform the precondition check for copying reference tables twice, first time with a lower lock that doesn't conflict with anything. Could have been a NoLock, however, in preparation for dropping a colocation group, it is an `AccessShareLock`

During normal operation the first check will always pass and we don't have to escalate that lock. Making it that we won't be blocked on adding and remove reference tables. Only after a node addition the first `create_reference_table` will still need to acquire an `ExclusiveLock` on the colocation group to perform the copy.
2022-08-18 14:58:49 +02:00
Ahmet Gedemenli 276fb6f29e
Do not create truncate triggers on foreign tables (#6106)
* Do not create truncate triggers on foreign tables

* Add citus--10.2-5--10.2-4.sql
2022-08-17 21:34:46 +03:00
Marco Slot 232ad4735b Fix issues with insert..select casts and column ordering 2022-07-28 16:24:17 +02:00
Marco Slot 4fae4db6e0 Fix issues with insert..select casts and column ordering 2022-07-28 14:18:55 +02:00
Ahmet Gedemenli c187ae8e79 Fix materialized view intermediate result filename (#5982)
(cherry picked from commit 268d3fa3a6)
2022-06-14 15:39:52 +03:00
Halil Ozan Akgul 042e54c9cf Fixes the bug where undistribute can drop Citus extension
(cherry picked from commit b255706189)

 Conflicts:
	src/include/distributed/metadata/dependency.h
2022-06-13 15:17:54 +03:00
jeff-davis 4c2f22d9fa Columnar: fix wraparound bug. (#5962)
columnar_vacuum_rel() now advances relfrozenxid.

Fixes #5958.

(cherry picked from commit 74ce210f8b)
2022-05-27 09:34:59 -07:00
Hanefi Onaldi 6663635593
Bump Citus version to 10.2.5 2022-03-17 00:45:38 +03:00
Hanefi Onaldi 54978b738d
Add changelog entries for 10.2.5 2022-03-17 00:45:31 +03:00
Onder Kalaci 29ba5a6251
Only change the sequence types if the target column type is a supported sequence type
Before this commit, we erroneously converted the sequence
type to the column's type it is used. However, it is possible
that the sequence is used in an expression which then converted
to a type that cannot be a sequence, such as text.

With this commit, we only try this conversion if the column
type is a supported sequence type (e.g., smallint, int and bigint).

Note that we do this conversion because if the column type is a
bigint and the sequence is NOT a bigint, users would be in trouble
because sequences would generate values that are out of the range
of the column. (The other ways are already not supported such as
the column is int and the sequence is bigint would fail on the worker.)

In other words, with this commit, we scope this optimization only
when the target column type is a supported sequence type. Otherwise,
we let users to more freely use the sequences.

(cherry picked from commit db529facab)

Conflicts:
- src/backend/distributed/commands/create_distributed_table.c
- src/include/distributed/metadata_utility.h
    EnsureSequenceTypeSupported did not have the third parameter prior
	to Citus 11. I removed the references to ownerRelationId.

- src/test/regress/multi_schedule

    Trivial conflict for the newly introduced test files. This conflict
    was easy to resolve, but I modified the tests to prevent failures
    due to the following:

	a) MX is not on by default on 10.2 contrary to Citus 11
	b) We set replication factor = 2 here contrary to 1 in Citus 11
2022-03-17 00:42:12 +03:00
Hanefi Onaldi 7fa26cd095
Do not acquire locks on node metadata explicitly
(cherry picked from commit f4e8af2c22)
2022-03-16 05:18:14 +03:00
Hanefi Onaldi d8a8e530fb
Lock nodes when building ddl task lists
(cherry picked from commit b70949ae8c)
2022-03-16 05:18:03 +03:00
Marco Slot 629ba8978f Ensure worker_save_query_explain_analyze always fully qualifies types (#5776)
Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
Co-authored-by: Marco Slot <marco.slot@gmail.com>
2022-03-11 11:45:24 +01:00
Onur Tirtir 3c84828931 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-04 16:38:41 +03:00
Hanefi Onaldi cb21065749
Bump Citus version to 10.2.4 2022-02-01 14:15:18 +03:00
Hanefi Onaldi cca5a76090
Add changelog entries for 10.2.4
(cherry picked from commit beafde5ff5)
2022-02-01 14:14:20 +03:00
Onder Kalaci ed3f298eb3 Use a fixed application_name while connecting to remote nodes
Citus heavily relies on application_name, see
`IsCitusInitiatedRemoteBackend()`.

But if the user set the application name, such as export PGAPPNAME=test_name,
Citus uses that name while connecting to the remote node.

With this commit, we ensure that Citus always connects with
the "citus" user name to the remote nodes.

(cherry picked from commit b26eeaecd3)
2022-01-27 12:58:04 +01:00
Onur Tirtir 5a1a1334d3 Tell other backends it's safe to ignore the backend that concurrently built the shell table index (#5520)
In addition to starting a new transaction, we also need to tell other
backends --including the ones spawned for connections opened to
localhost to build indexes on shards of this relation-- that concurrent
index builds can safely ignore us.

Normally, DefineIndex() only does that if index doesn't have any
predicates (i.e.: where clause) and no index expressions at all.
However, now that we already called standard process utility, index
build on the shell table is finished anyway.

The reason behind doing so is that we cannot guarantee not grabbing any
snapshots via adaptive executor, and the backends creating indexes on
local shards (if any) might block on waiting for current xact of the
current backend to finish, which would cause self deadlocks that are not
detectable.

(cherry picked from commit 3cc44ed8b3)

  Conflicts:
	src/backend/distributed/commands/utility_hook.c
2022-01-13 14:36:22 +03:00
Ahmet Gedemenli 5f04346408
Do not include return table params in the function arg list (#5568)
(cherry picked from commit 90928cfd74)

Fix function signature generation

Fix comment typo

Add test for worker_create_or_replace_object

Add test for recreating distributed functions with OUT/TABLE params

Add test for recreating distributed function that returns setof int

Fix test output

Fix comment

(cherry picked from commit 8e4ff34a2e)
2021-12-23 18:07:46 +03:00
Onur Tirtir 39348e2c3b HAVE_LZ4 -> HAVE_CITUS_LZ4 (#5541)
(cherry picked from commit cc4c83b1e5)
2021-12-16 16:38:45 +03:00
Marco Slot d695deae16 Support operator class parameters in indexes
(cherry picked from commit defb97b7f5)
2021-12-15 20:10:56 +03:00
Onur Tirtir e19089503e Bump citus version to 10.2.3 2021-11-29 11:50:44 +03:00
Onur Tirtir 81702af8d7 Add changelog entries for 10.2.3 (#5498)
(cherry picked from commit 1836361a51)

Conflicts:
	CHANGELOG.md
2021-11-29 11:50:35 +03:00
Onur Tirtir 6899e66f80 Drop upgrade_list_citus_objects_0.out 2021-11-26 10:09:30 +03:00
Onur Tirtir f5b297e149 Allow overwriting columnar storage pages written by aborted xacts (#5484)
When refactoring storage layer in #4907, we deleted the code that allows
overwriting a disk page previously written but not known by metadata.

Readers can see the change that introduced the code allows doing so in
commit a8da9acc63.

The reasoning was that; as of 10.2, we started aligning page
reservations (`AlignReservation`) for subsequent writes right after
allocating pages from disk. That means, even if writer transaction
fails, subsequent writes are guaranteed to allocate a new page and write
to there. For this reason, attempting to write to a page allocated
before is not possible for a columnar table that user created when using
v10.2.x.

However, since the older versions of columnar doesn't do that, following
example scenario can still result in writing to such disk page, even if
user now upgraded to v10.2.x. This is because, when upgrading storage to
2.0 (`ColumnarStorageUpdateIfNeeded`), we calculate `reservedOffset` of
the metapage based on the highest used address known by stripe
metadata (`GetHighestUsedAddressAndId`). However, stripe metadata
doesn't have entries for aborted writes. As a result, highest used
address would be computed by ignoring pages that are allocated but not
used.

- User attempts writing to columnar table on Citus v10.0x/v10.1x.
- Write operation fails for some reason.
- User upgrades Citus to v10.2.x.
- When attempting to write to same columnar table, they hit to "attempt
  to write columnar data .." error since write operation done in the
  older version of columnar already allocated that page, and now we are
  overwriting it.

For this reason, with this commit, we re-do the change done in
a8da9acc63.

And for the reasons given above, it wasn't possible to add a test for
this commit via usual code-paths. For this reason, added a UDF only for
testing purposes so that we can reproduce the exact scenario in our
regression test suite.

(cherry picked from commit 76b8006a9e)
2021-11-26 10:07:00 +03:00
Onur Tirtir b66abbcba8 Introduce dependencies from columnarAM to columnar metadata objects
During pg upgrades, we have seen that it is not guaranteed that a
columnar table will be created after metadata objects got created.
Prior to changes done in this commit, we had such a dependency
relationship in `pg_depend`:

```
columnar_table ----> columnarAM ----> citus extension
                                           ^  ^
                                           |  |
columnar.storage_id_seq --------------------  |
                                              |
columnar.stripe -------------------------------
```

Since `pg_upgrade` just knows to follow topological sort of the objects
when creating database dump, above dependency graph doesn't imply that
`columnar_table` should be created before metadata objects such as
`columnar.storage_id_seq` and `columnar.stripe` are created.

For this reason, with this commit we add new records to `pg_depend` to
make columnarAM depending on all rel objects living in `columnar`
schema. That way, `pg_upgrade` will know it needs to create those before
creating `columnarAM`, and similarly, before creating any tables using
`columnarAM`.

Note that in addition to inserting those records via installation script,
we also do the same in `citus_finish_pg_upgrade()`. This is because,
`pg_upgrade` rebuilds catalog tables in the new cluster and that means,
we must insert them in the new cluster too.

(cherry picked from commit 73f06323d8)
2021-11-26 10:02:11 +03:00
Onur Tirtir 88f2b8a60d Reproduce bug via test suite
(cherry picked from commit ef2ca03f24)
2021-11-26 09:55:50 +03:00
Onur Tirtir de39835da2 Store tmp_upgrade/newData/*.log as an artifact
(cherry picked from commit 4a97664fd7)
2021-11-26 09:55:10 +03:00
Onur Tirtir 3f2ac78cf6 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
2021-11-12 12:36:00 +03:00
naisila 757446bc61 Fix index name udf scripts for 10.2 and bump use of new sql functions 2021-11-09 08:56:57 +01:00
Naisila Puka 0a48c0aec7 Add fix_partition_shard_index_names udf to fix currently broken names (#5291)
* Add udf to include shardId in broken partition shard index names

* Address reviews: rename index such that operations can be done on it

* More comprehensive index tests

* Final touches and formatting
2021-11-09 08:56:57 +01:00
Önder Kalacı d18757b0cd Allow lock_shard_resources to be called by the users with privileges (#5441)
Before this commit, we required the user to be owner of the shard/table
in order to call lock_shard_resources.

However, that is too restrictive. We can have users with GRANTS
to the table who are not owners of the tables/shards.

With this commit, we allow such patterns.

(cherry picked from commit 98ca6ba6ca)
2021-11-08 15:45:02 +01:00