diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 9d1dc87ceb1..8d671b7a29d 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -1796,9 +1796,9 @@ pg_sequence_parameters(PG_FUNCTION_ARGS) /* * Return the sequence tuple along with its page LSN. * - * This is primarily intended for use by pg_dump to gather sequence data - * without needing to individually query each sequence relation. This will also - * be used by logical replication while synchronizing sequences. + * This is primarily used by pg_dump to efficiently collect sequence data + * without querying each sequence individually, and is also leveraged by + * logical replication while synchronizing sequences. */ Datum pg_get_sequence_data(PG_FUNCTION_ARGS) @@ -1842,11 +1842,6 @@ pg_get_sequence_data(PG_FUNCTION_ARGS) values[0] = Int64GetDatum(seq->last_value); values[1] = BoolGetDatum(seq->is_called); - - /* - * For details about recording the LSN, see the - * UpdateSubscriptionRelState() call in copy_sequence(). - */ values[2] = LSNGetDatum(PageGetLSN(page)); UnlockReleaseBuffer(buf); diff --git a/src/backend/replication/logical/sequencesync.c b/src/backend/replication/logical/sequencesync.c index 7927aeac054..5418327c237 100644 --- a/src/backend/replication/logical/sequencesync.c +++ b/src/backend/replication/logical/sequencesync.c @@ -28,12 +28,13 @@ * to handle synchronization. * * A single sequencesync worker is responsible for synchronizing all sequences - * marked in pg_subscription_rel. It begins by retrieving the list of sequences - * flagged for synchronization. These sequences are then processed in batches, - * allowing multiple entries to be synchronized within a single transaction. - * The worker fetches the current sequence values and page LSNs from the remote - * publisher, updates the corresponding sequences on the local subscriber, and - * finally marks each sequence as READY upon successful synchronization. + * in INIT state in pg_subscription_rel. It begins by retrieving the list of + * sequences flagged for synchronization. These sequences are then processed + * in batches, allowing multiple entries to be synchronized within a single + * transaction. The worker fetches the current sequence values and page LSNs + * from the remote publisher, updates the corresponding sequences on the local + * subscriber, and finally marks each sequence as READY upon successful + * synchronization. * * Sequence state transitions follow this pattern: * INIT → READY @@ -42,19 +43,9 @@ * sequences are synchronized per transaction. The locks on the sequence * relation will be periodically released at each transaction commit. * - * XXX: An alternative design was considered where the launcher process would - * periodically check for sequences that need syncing and then start the - * sequencesync worker. However, the approach of having the apply worker - * manage the sequencesync worker was chosen for the following reasons: - * a) The apply worker can access the sequences that need to be synchronized - * from the pg_subscription_rel system catalog. Whereas the launcher process - * operates without direct database access so would need a framework to - * establish connections with the databases to retrieve the sequences for - * synchronization. - * b) It utilizes the existing tablesync worker code to start the sequencesync - * process, thus preventing code duplication in the launcher. - * c) It simplifies code maintenance by consolidating changes to a single - * location rather than multiple components. + * XXX: We didn't choose launcher process to maintain the launch of sequencesync + * worker as it didn't have database connection to access the sequences from the + * pg_subscription_rel system catalog that need to be synchronized. *------------------------------------------------------------------------- */ @@ -338,8 +329,7 @@ copy_sequence(LogicalRepSequenceInfo *seqinfo, int64 last_value, /* * Record the remote sequence’s LSN in pg_subscription_rel and mark the - * sequence as READY. The LSN represents the WAL position of the remote - * sequence at the time it was synchronized. + * sequence as READY. */ UpdateSubscriptionRelState(MySubscription->oid, seqoid, SUBREL_STATE_READY, page_lsn, false);