Data migration to partitioned global unique tables
Background
The deployment of db patches for CUMULUS-4982 Partition files_global_unique and granules_global_unique tables creates the new HASH-partitioned structures and safely renames your active data to *_old_non_partitioned backup tables. This guide covers how to manually transfer that data, verify it, and clean up the old tables.
Execution Steps
-
Login into EC2 instance with database access.
From AWS console: Go to EC2, pick a
<prefix>-CumulusECSClusterinstance, click Connect, click Session Manager and click the Connect button.From AWS CLI: aws ssm start-session --target
EC2 Instance ID.Remember to take a note on which instance you run the commands. -
Install tmux, postgres client and python packages
sudo yum install -y tmuxsudo dnf install -y postgresql17Once installed, a
tmuxsession is started with two windows, the Cumulus database is connected to each window using the PostgreSQL client. The primary window is used for running the migration SQL script, while the secondary window is used to monitor the database. The tmux session can be detached and reattached later as needed. -
Run Migration Script
The database login credentials can be retrieved from the
<prefix>_db_loginsecret. When the migration script is running, perform step 4 to monitor the commands. The migration script also prints out the progress messages.curl -o /home/ssm-user/20260625_migrate_and_verify_global_uniqueness.sql https://raw.githubusercontent.com/nasa/cumulus/master/packages/db/src/migrations/20260625_migrate_and_verify_global_uniqueness.sqltmux new-session -s CumulusUpgrade -n migrateGlobalUniquepsql -h <Endpoint for writer instance> -p <Port for database or 5432> -d <cumulus database name> -U <database admin user> -f /home/ssm-user/20260625_migrate_and_verify_global_uniqueness.sql -W#e.g. psql -h cumulus-dev-rds-cluster.cluster-xxx.us-east-1.rds.amazonaws.com -p 5432 -d cumulus_test_db -U cumulus_test -f /home/ssm-user/20260625_migrate_and_verify_global_uniqueness.sql -W -
Monitor the Running Command
# From tmux CumulusUpgrade session, open another window<Ctrl>-b cpsql -h <Endpoint for writer instance> -p <Port for database or 5432> -d <cumulus database name> -U <database admin user> -Wselect pid, query, state, wait_event_type, wait_event from pg_stat_activity where state = 'active'; -
Close the Session
Close the tmux session after the task is complete by
exitor<Ctrl>-b x.