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

[PG-961] automated bash script for replication, expected files and up… #71

Open
wants to merge 6 commits into
base: TDE_REL_17_STABLE
Choose a base branch
from

Conversation

shahidullah79
Copy link
Collaborator

…dated sql

PG-961

Description

A bash script that verify streaming replication. This script following tasks

  • Create a primary server
  • Enable pg_tde with global keys.
  • Update the primary configuration files.
  • Insert some data using sample_data.sql file
  • create two replica server using pg_basebackup
  • Verify sample_data using verify_sample_data.sql on both slave nodes.
  • Insert some more data on primary node (using incremental_data.sql file)
  • Verify the newly inserted data on both slave nodes.
  • Data should be same on expected and actual files.

Links

@shahidullah79 shahidullah79 requested review from jeltz and removed request for dAdAbird February 18, 2025 22:40
Copy link
Collaborator

@dutow dutow left a comment

Choose a reason for hiding this comment

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

This is a good base script, but I see three issues here:

  • No verification that data on disk is actually encrypted - not for the primary, not for the replica.
  • The data load is very minimal: we create a basic dataset with minimal tables, and then add a few extra SQL commands while the server is running. (1) The dataset should be bigger, currently everything fits into a few kilobytes, that's not realistic. (2) the replication process should run longer, with more changes, maybe even adding pgbench/sysbench there for a dynamic load. (3) The dataset should use more features. We have no indexes, toast tables, views/materalized views and so on.
  • The incremental/data load part doesn't change encryption parameters: rotating keys, changing the key provider, moving from default provider to database local, anything really.

Most of these comments are also true for the backup test.

@dutow
Copy link
Collaborator

dutow commented Feb 25, 2025

Please do not add main -> feature branch merges ("Merge branch 'TDE_REL_17_STABLE' into PG-961") to the PR.

When you need changes from the main branch, use the rebase functionality.

SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
INSTALL_DIR="$SCRIPT_DIR/../../pginst"
INSTALL_DIR="$SCRIPT_DIR/../../pginst/17"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to be inconsistent with the rest of the scripts?

@shahidullah79
Copy link
Collaborator Author

shahidullah79 commented Feb 25, 2025 via email

Copy link
Collaborator

@jeltz jeltz left a comment

Choose a reason for hiding this comment

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

Did not have time to review the main script now but will look at it later.

-- ELSE
-- RAISE NOTICE 'Skipping WAL check on Master.';
-- END IF;
--END $$;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As the output is different for master and slave node, so it was a bit tricky to handle the output file comparison. Now the script have separate function, which verify lsn on master/slave1/slave2 nodes on the run. The new changes in the script will have this function.

@@ -16,16 +16,16 @@ export PGPORT="${2:-5432}"

if [ -d "$PGDATA" ]; then
if pg_ctl -D "$PGDATA" status -o "-p $PGPORT" >/dev/null; then
pg_ctl -D "$PGDATA" stop -o "-p $PGPORT"
pg_ctl -D "$PGDATA" stop -o "-p $PGPORT" >/dev/null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I want the output so I can debug the script.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah agree, it will be difficult to debug. will remove this change.


psql postgres -f "$SCRIPT_DIR/tde_setup_global.sql"

pg_ctl -D "$PGDATA" restart -o "-p $PGPORT"
pg_ctl -D "$PGDATA" restart -o "-p $PGPORT" -l "$PGDATA/logfile"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit tricky. I would not want this behaviour locally but I can see the point of doing it for CI. Too much wirtten to stdout otherwise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what do you suggest in this case? Is it okay or should I revert this change?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dutow What do you think about this? I am unsure myself.

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.

3 participants