Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds alter database support on non-main database and on any node #7563

Open
wants to merge 82 commits into
base: main
Choose a base branch
from

Conversation

gurkanindibay
Copy link
Contributor

@gurkanindibay gurkanindibay commented Mar 18, 2024

DESCRIPTION: Adds alter database support on non-main database and on any node

This PR introduces the ability to alter database on main and non-main databases on any node expanding the existing alter database support.

During the implementation, we encountered an issue related to the initialization of the IsMainDB parameter. As a result, we had to turn off enable_ddl_propagation in pg_regress.pl and reactivate it post-creation of the extension in the test environment.

We've added two tests to the test schedules to turn on ddl propagation:

  1. enable_ddl_propagation
  2. isolation_enable_ddl_propagation
    In each schedule, we've placed enable_ddl_propagation (or the other file) at the top to activate ddl propagation system-wide once. This is necessary for the propagation of helper functions.

Above tests are mostly used at the start of each schedule.
Through extensive testing, we discovered that the tests minimal_cluster_management and multi_cluster_management inadvertently disable enable_ddl_propagation on worker nodes. This was causing multi_test_catalog_views to stuck. Upon further investigation, we identified that the function run_command_on_master_and_workers_temp was causing this problem. To address this, we've arranged schedule files such that enable_ddl_propagation is executed inside the minimal_cluster_management and multi_cluster_management schedules.

@gurkanindibay gurkanindibay changed the base branch from main to refactor-nonmain-db-path March 19, 2024 07:38
Base automatically changed from refactor-nonmain-db-path to main March 19, 2024 13:26
Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Merging #7563 (e089f90) into main (a0151aa) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7563      +/-   ##
==========================================
- Coverage   89.69%   89.61%   -0.08%     
==========================================
  Files         283      283              
  Lines       60505    60541      +36     
  Branches     7538     7540       +2     
==========================================
- Hits        54270    54256      -14     
- Misses       4081     4113      +32     
- Partials     2154     2172      +18     

@eaydingol
Copy link
Contributor

The PR adds ability to propagate "ALTER DATABASE ..." statement from any node with the last commits. It would be good to update the PR description to reflect this.

@gurkanindibay gurkanindibay changed the title Adds alter database support on non-main database Adds alter database support on non-main database and on any node Apr 1, 2024
@gurkanindibay
Copy link
Contributor Author

The PR adds ability to propagate "ALTER DATABASE ..." statement from any node with the last commits. It would be good to update the PR description to reflect this.

Added some more details to express the any node support

alter database "altered_database!'2" owner to test_owner_non_main_db;
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE "altered_database!''2" OWNER TO test_owner_non_main_db;', 'postgres')
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
\c test_alter_db_from_nonmain_db - - :worker_1_port
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add checks to see the result, for example, after the alter database ... owner to ... , connect to another db / worker node and check the result, e.g. select db.datname, pg_catalog.pg_get_userbyid(db.datdba) FROM pg_catalog.pg_database db where db.datname = ....;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, can use the functions that we used before to collect settings of a database from all nodes (via run_command_on_all_nodes etc.), but yes, we definitely somehow need to check database options on all nodes after issuing those commands from a non-main db.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added value checks for tests

EnsureCoordinator();

EnsurePropagationToCoordinator();
EnsureAllObjectDependenciesExistOnAllNodes(list_make1(dbAddress));
Copy link
Member

@onurctirtir onurctirtir Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have some bugs caused by not calling EnsureAllObjectDependenciesExistOnAllNodes in the functions defined in this file, I think we should not fix them in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So can we remove them from the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You pointed out that we should not fix them in this PR. And I approved it and assumed that there is nothing to do with this comment.
I need more clarification here on what needs to be done here. Are you asking if we can remove selected changes? If so, this block is necessary to propagate non-main db operations, therefore we need to keep it

src/backend/distributed/commands/database.c Outdated Show resolved Hide resolved
src/backend/distributed/commands/database.c Show resolved Hide resolved
src/backend/distributed/commands/database.c Show resolved Hide resolved
src/include/distributed/commands.h Outdated Show resolved Hide resolved
src/test/regress/citus_tests/run_test.py Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let delete trailing newlines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@eaydingol eaydingol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the PR looks good to me.
I added some minor comments about the tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7563 not addressed yet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7563 is the PR link at all. Do you intend to give a link of comment? If so could you give the exact link/clarify the request?
Thanks

Comment on lines 179 to 181



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still seeing some #7563

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I redesigned the sql file after some review comments. Those are the newly formed empty lines removed all of them

EnsureCoordinator();

EnsurePropagationToCoordinator();
EnsureAllObjectDependenciesExistOnAllNodes(list_make1(dbAddress));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So can we remove them from the PR?

src/test/regress/citus_tests/run_test.py Outdated Show resolved Hide resolved
src/test/regress/citus_tests/run_test.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants