diff --git a/src/bin/pgcopydb/cli_clone_follow.c b/src/bin/pgcopydb/cli_clone_follow.c index ced0f1e1..d0c19b4c 100644 --- a/src/bin/pgcopydb/cli_clone_follow.c +++ b/src/bin/pgcopydb/cli_clone_follow.c @@ -645,6 +645,21 @@ cli_follow(int argc, char **argv) exit(EXIT_CODE_SOURCE); } + /* + * The snapshot connection is only needed for the catalog read above; + * nothing in the follow phase uses it. Close it now so a follow-only run + * doesn't hold it idle-in-transaction for the whole run. Gate on the live + * connection, not sourceSnapshot.state, which the catalog read leaves stale. + */ + if (copySpecs.sourceSnapshot.pgsql.connection != NULL) + { + if (!copydb_close_snapshot(©Specs)) + { + /* errors have already been logged */ + exit(EXIT_CODE_SOURCE); + } + } + if (!follow_main_loop(©Specs, &specs)) { /* errors have already been logged */