Commit Graph

6951 Commits (alter_database_nonmain2)

Author SHA1 Message Date
Gürkan İndibay e089f906b1
Merge branch 'main' into alter_database_nonmain2 2024-04-19 11:16:52 +03:00
Gürkan İndibay 824a172401
Apply suggestions from code review
Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
2024-04-19 11:01:53 +03:00
gurkanindibay 43d3b906bb Removes unnecessary empty lines 2024-04-19 11:00:44 +03:00
Jelte Fennema-Nio a0151aa31d
Greatly speed up "\d tablename" on servers with many tables (#7577)
DESCRIPTION: Fix performance issue when using "\d tablename" on a server
with many tables

We introduce a filter to every query on pg_class to automatically remove
shards. This is useful to make sure \d and PgAdmin are not cluttered
with shards. However, the way we were introducing this filter was using
`securityQuals` which can have negative impact on query performance.

On clusters with 100k+ tables this could cause a simple "\d tablename"
command to take multiple seconds, because a skipped optimization by
Postgres causes a full table scan. This changes the code to introduce
this filter in the regular `quals` list instead of in `securityQuals`.
Which causes Postgres to use the intended optimization again.

For reference, this was initially reported as a Postgres issue by me:

https://www.postgresql.org/message-id/flat/4189982.1712785863%40sss.pgh.pa.us#b87421293b362d581ea8677e3bfea920
2024-04-16 17:26:12 +02:00
Xing Guo ada3ba2507
Add missing volatile qualifier. (#7570)
Variables being modified in the PG_TRY block and read in the PG_CATCH
block should be qualified with volatile.

The variable waitEventSet is modified in the PG_TRY block (line 1085)
and read in the PG_CATCH block (line 1095).

The variable relation is modified in the PG_TRY block (line 500) and
read in the PG_CATCH block (line 515).

Besides, the variable objectAddress doesn't need the volatile qualifier.

Ref: C99 7.13.2.1[^1],

> All accessible objects have values, and all other components of the
abstract machine have state, as of the time the longjmp function was
called, except that the values of objects of automatic storage duration
that are local to the function containing the invocation of the
corresponding setjmp macro that do not have volatile-qualified type and
have been changed between the setjmp invocation and longjmp call are
indeterminate.

[^1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

DESCRIPTION: Correctly mark some variables as volatile

---------

Co-authored-by: Hong Yi <zouzou0208@gmail.com>
2024-04-16 15:29:14 +02:00
Karina 41e2af8ff5
Use expecteddir option in _run_pg_regress() (#7582)
Fix check-arbitrary-configs tests failure with current REL_16_STABLE.
This is the same problem as described in #7573. I missed pg_regress call
in _run_pg_regress() in that PR.

Co-authored-by: Karina Litskevich <litskevichkarina@gmail.com>
2024-04-16 08:44:47 +00:00
Jelte Fennema-Nio a263ac6f5f
Speed up GetForeignKeyOids (#7578)
DESCRIPTION: Fix performance issue in GetForeignKeyOids on systems with
many constraints

GetForeignKeyOids was showing up in CPU profiles when distributing
schemas on systems with 100k+ constraints. The reason was that this
function was doing a sequence scan of pg_constraint to get the foreign
keys that referenced the requested table.

This fixes that by finding the constraints referencing the table through
pg_depend instead of pg_constraint. We're doing this indirection,
because pg_constraint doesn't have an index that we can use, but
pg_depend does.
2024-04-16 08:16:40 +00:00
Jelte Fennema-Nio 110b4192b2
Fix PG upgrades when invalid rebalance strategies exist (#7580)
DESCRIPTION: Fix PG upgrades when invalid rebalance strategies exist

Without this change an upgrade of a cluster with an invalid rebalance
strategy would fail with an error like this:
```
cache lookup failed for shard_cost_function with oid 6077337
CONTEXT:  SQL statement "SELECT citus_validate_rebalance_strategy_functions(
        NEW.shard_cost_function,
        NEW.node_capacity_function,
        NEW.shard_allowed_on_node_function)"
PL/pgSQL function citus_internal.pg_dist_rebalance_strategy_trigger_func() line 5 at PERFORM
SQL statement "INSERT INTO pg_catalog.pg_dist_rebalance_strategy SELECT
        name,
        default_strategy,
        shard_cost_function::regprocedure::regproc,
        node_capacity_function::regprocedure::regproc,
        shard_allowed_on_node_function::regprocedure::regproc,
        default_threshold,
        minimum_threshold,
        improvement_threshold
    FROM public.pg_dist_rebalance_strategy"
PL/pgSQL function citus_finish_pg_upgrade() line 115 at SQL statement
```

This fixes that by disabling the trigger and simply re-inserting the
invalid rebalance strategy without checking. We could also silently
remove it, but this seems nicer.
2024-04-15 14:26:33 +00:00
Jelte Fennema-Nio 16604a6601
Use an index to get FDWs that depend on extensions (#7574)
DESCRIPTION: Fix performance issue when distributing a table that
depends on an extension

When the database contains many objects this function would show up in
profiles because it was doing a sequence scan on pg_depend. And with
many objects pg_depend can get very large.

This starts using an index scan to only look for rows containing FDWs,
of which there are expected to be very few (often even zero).
2024-04-15 12:42:56 +00:00
Jelte Fennema-Nio cdf51da458
Speed up SequenceUsedInDistributedTable (#7579)
DESCRIPTION: Fix performance issue when creating distributed tables if
many already exist

This builds on the work to speed up EnsureSequenceTypeSupported, and now
does something similar for SequenceUsedInDistributedTable.
SequenceUsedInDistributedTable had a similar O(number of citus tables)
operation. This fixes that and speeds up creation of distributed tables
significantly when many distributed tables already exist.

Fixes #7022
2024-04-15 12:01:55 +00:00
Jelte Fennema-Nio 381f31756e
Speed up EnsureSequenceTypeSupported (#7575)
DESCRIPTION: Fix performance issue when creating distributed tables and many already exist

EnsureSequenceTypeSupported was doing an O(number of distributed tables)
operation. This can become very slow with lots of Citus tables, which
now happens much more frequently in practice due to schema based sharding.

Partially addresses #7022
2024-04-15 10:28:11 +00:00
Onur Tirtir 3586aab17a
Allow providing "host" parameter via citus.node_conninfo (#7541)
And when that is the case, directly use it as "host" parameter for the
connections between nodes and use the "hostname" provided in
pg_dist_node / pg_dist_poolinfo as "hostaddr" to avoid host name lookup.

This is to avoid allowing dns resolution (and / or setting up DNS names
for each host in the cluster). This already works currently when using
IPs in the hostname. The only use of setting host is that you can then
use sslmode=verify-full and it will validate that the hostname matches
the certificate provided by the node you're connecting too.

It would be more flexible to make this a per-node setting, but that
requires SQL changes. And we'd like to backport this change, and
backporting such a sql change would be quite hard while backporting this
change would be very easy. And in many setups, a different hostname for
TLS validation is actually not needed. The reason for that is
query-from-any node: With query-from-any-node all nodes usually have a
certificate that is valid for the same "cluster hostname", either using
a wildcard cert or a Subject Alternative Name (SAN). Because if you load
balance across nodes you don't know which node you're connecting to, but
you still want TLS validation to do it's job. So with this change you
can use this same "cluster hostname" for TLS validation within the
cluster. Obviously this means you don't validate that you're connecting
to a particular node, just that you're connecting to one of the nodes in
the cluster, but that should be fine from a security perspective (in
most cases).

Note to self: This change requires updating

https://docs.citusdata.com/en/latest/develop/api_guc.html#citus-node-conninfo-text.

DESCRIPTION: Allows overwriting host name for all inter-node connections
by supporting "host" parameter in citus.node_conninfo
2024-04-15 09:51:11 +00:00
gurkanindibay 0f38a29184 Fixes revire comments 2024-04-15 11:35:13 +03:00
Karina 41d99249d9
Use expecteddir option when running vanilla tests (#7573)
In PostgreSQL 16 a new option expecteddir was introduced to pg_regress.
Together with fix in
[196eeb6b](https://github.com/postgres/postgres/commit/196eeb6b) it
causes check-vanilla failure if expecteddir is not specified.

Co-authored-by: Karina Litskevich <litskevichkarina@gmail.com>
2024-04-10 16:08:54 +00:00
gurkanindibay 5aebb585cb Fixes review issues 2024-04-02 12:59:00 +03:00
gurkanindibay 7b280315c1 Adds detailed logs 2024-04-02 12:49:59 +03:00
gurkanindibay 152b46da0a Fixes indentation 2024-04-02 09:27:23 +03:00
gurkanindibay 3c4f66a8c4 Fixes review comments 2024-04-02 09:25:06 +03:00
Gürkan İndibay 62de6dc0b4
Apply suggestions from code review
Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
2024-04-02 09:14:35 +03:00
gurkanindibay 179f2e5fad Fixes indentation 2024-03-30 12:36:26 +03:00
gurkanindibay 0299897395 Fixes test errors 2024-03-30 12:00:55 +03:00
gurkanindibay 6d964baa0c Adds additional tests for alter tablespace 2024-03-29 14:06:40 +03:00
gurkanindibay 0e02faccc4 Fixes test output 2024-03-29 13:32:49 +03:00
gurkanindibay ccac41b711 Fixes from any node issues 2024-03-29 13:02:30 +03:00
gurkanindibay 48fdee016a Fixes test errors 2024-03-28 13:31:47 +03:00
gurkanindibay e24552493e Merge branch 'alter_database_nonmain2' of https://github.com/citusdata/citus into alter_database_nonmain2 2024-03-28 13:16:32 +03:00
gurkanindibay c790b568fa Removes unnecessary output files 2024-03-28 13:16:28 +03:00
Gürkan İndibay 7a59910ea2
Update src/test/regress/expected/multi_cluster_management.out
Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
2024-03-28 13:15:10 +03:00
Gürkan İndibay 98b600058b
Update src/test/regress/expected/minimal_cluster_management.out
Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
2024-03-28 13:14:58 +03:00
gurkanindibay 98111eed96 Fixes review comments 2024-03-28 13:12:04 +03:00
gurkanindibay 18e3924530 Fixes review comments 2024-03-28 12:49:08 +03:00
gurkanindibay 24e7389d3e Fixes review comments 2024-03-27 13:51:23 +03:00
gurkanindibay 082e35687c Fixes review comments 2024-03-27 11:03:21 +03:00
gurkanindibay c458ae13e8 Fixes isolation and failure lock issues 2024-03-27 10:28:10 +03:00
gurkanindibay a78a77edca Fixes indentation 2024-03-26 16:53:08 +03:00
gurkanindibay 3b6236bd1c Fixes flaky tests 2024-03-26 16:30:55 +03:00
gurkanindibay aaa1030157 Fixes multi_follower_schedule execution 2024-03-26 14:16:03 +03:00
gurkanindibay 56171a4a17 Enriches tests 2024-03-26 13:02:43 +03:00
gurkanindibay 6472292593 Adds logs 2024-03-26 11:18:13 +03:00
gurkanindibay 21bbe5fdf7 Fixes Flaky tests 2024-03-26 11:03:40 +03:00
gurkanindibay ce6d76fbb1 Adds log 2024-03-26 10:56:31 +03:00
gurkanindibay c47ac5e1da Fixes indentation 2024-03-26 10:37:40 +03:00
gurkanindibay 603cec47df Adds enable ddl prop after multi_cluster_management 2024-03-26 10:34:00 +03:00
gurkanindibay 7bde99c7d7 Fixes multi extension test 2024-03-25 19:08:41 +03:00
gurkanindibay b0282e6219 Adds a comment 2024-03-25 19:06:51 +03:00
gurkanindibay fbb38dd7ea Fixes additional tests 2024-03-25 18:43:17 +03:00
gurkanindibay 2013554050 Removes unnecessary enable_ddl_propagation entries 2024-03-25 18:27:47 +03:00
gurkanindibay 602c8c1206 Removes unnecessary changes 2024-03-25 18:23:22 +03:00
gurkanindibay 625c8d4af0 Fixes test issues 2024-03-25 18:20:20 +03:00
gurkanindibay 24f9d599d0 Fixes minimal_cluster_management issue 2024-03-25 18:18:16 +03:00