From 7148cd8a7bb1ddc774b9a0e2e21f914a948bb28e Mon Sep 17 00:00:00 2001 From: Kevin Yeap Date: Tue, 7 May 2024 15:37:21 -0700 Subject: [PATCH] pg_upgrade: freeze coordinator data after relfilenode transfer Original commit message: ``` Tuples of catalog tables like gp_fastsequence, and pg_aoseg need to be preserved. Tuples will be moved from old cluster to new cluster using relfilenode transfer. To ensure that these tuple's relfrozenxid are lower than their xmins, we first need to correct their relfrozenxid and then freeze them. The process of correcting relfrozenxids already happens on segments to ensure data visibility, so the same function was repurposed for coordinator. ``` Full testing for 6 > 7 upgrade will be added in a followup commit. reference commit: pg_upgrade: freeze coordinator after relfilenode transfer https://github.com/greenplum-db/gpdb/commit/9cd8cd2630 --- src/bin/pg_upgrade/pg_upgrade.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c index 082bbe39c6e0..62cf725623b2 100644 --- a/src/bin/pg_upgrade/pg_upgrade.c +++ b/src/bin/pg_upgrade/pg_upgrade.c @@ -255,12 +255,6 @@ main(int argc, char **argv) */ restore_aosegment_tables(); - if (is_greenplum_dispatcher_mode()) - { - /* freeze master data *right before* stopping */ - freeze_master_data(); - } - stop_postmaster(false); /* @@ -275,6 +269,23 @@ main(int argc, char **argv) transfer_all_new_tablespaces(&old_cluster.dbarr, &new_cluster.dbarr, old_cluster.pgdata, new_cluster.pgdata); + /* + * Tuples of gp_fastsequence are being upgraded using relfilenode transfer. + * Freezing coordinator's data must happen after relfilenodes land. We also + * need to fix the tuple's xmin to ensure they are lower than the + * relfrozenxid. Otherwise subsequent vacuums may fail. + */ + if (is_greenplum_dispatcher_mode()) + { + start_postmaster(&new_cluster, true); + + update_db_xids(); + freeze_master_data(); + + stop_postmaster(false); + } + + /* For non-master segments, uniquify the system identifier. */ if (!is_greenplum_dispatcher_mode()) reset_system_identifier();