v8-0004-Move-a-registration-of-atexit-callback-to-behind.patch

application/octet-stream

Filename: v8-0004-Move-a-registration-of-atexit-callback-to-behind.patch
Type: application/octet-stream
Part: 3
Message: RE: speed up a logical replica setup

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v8-0004
Subject: Move a registration of atexit() callback to behind
File+
src/bin/pg_basebackup/pg_subscriber.c 6 2
From eb912015aa8b5d8481b852d91e3d146fc1a31703 Mon Sep 17 00:00:00 2001
From: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Date: Wed, 24 Jan 2024 07:18:47 +0000
Subject: [PATCH v8 4/4] Move a registration of atexit() callback to behind

---
 src/bin/pg_basebackup/pg_subscriber.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_subscriber.c b/src/bin/pg_basebackup/pg_subscriber.c
index 355738c20c..17a6b552af 100644
--- a/src/bin/pg_basebackup/pg_subscriber.c
+++ b/src/bin/pg_basebackup/pg_subscriber.c
@@ -1373,8 +1373,6 @@ main(int argc, char **argv)
 		}
 	}
 
-	atexit(cleanup_objects_atexit);
-
 	/*
 	 * Don't allow it to be run as root. It uses pg_ctl which does not allow
 	 * it either.
@@ -1727,6 +1725,12 @@ main(int argc, char **argv)
 		pg_ctl_status(pg_ctl_cmd, rc, 0);
 	}
 
+	/*
+	 * Subsequent operations define some database objects on both primary and
+	 * standby. The callback is useful to clean up them in case of failure.
+	 */
+	atexit(cleanup_objects_atexit);
+
 	/*
 	 * Create a replication slot for each database on the publisher.
 	 */
-- 
2.43.0