Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vqlxK-0003rs-34 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Feb 2026 05:43:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vqlxJ-00CdEb-0T for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Feb 2026 05:43:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vqlxI-00CdES-2f for pgsql-hackers@lists.postgresql.org; Fri, 13 Feb 2026 05:43:05 +0000 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vqlxG-00000000OoG-2jec for pgsql-hackers@lists.postgresql.org; Fri, 13 Feb 2026 05:43:04 +0000 Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-89577f866d6so8212466d6.0 for ; Thu, 12 Feb 2026 21:43:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770961382; cv=none; d=google.com; s=arc-20240605; b=YjREbF5shmkPibzYalBrMm8VOqmSgSLJzmFsLlMD/KhqXIo+FhTIEpiQSzo8YSe7YO OxzdbSwlYLOzI/iF/mnjlJQd0/kAvg1uAvgVqSiNR6pEsMzFQh27x2E4havQxiIgk7GQ om1v8+DzOK5XdEaRqO1PKB4oqcUS8pfNNTWtqXQ8myzj7of/vWfdoidGzXAuN7KLpepM mPsuButf4Z30v6eVaAYPlf6DQNiV1YAD79DpQH16VwirviL/WJMhjE8BndGZXU9w2QHy PQDPkO/d4l2d6kk/RSCYrW3/JbNtM6zSZLnEtYSzmVK11qS9BIYgc81NrRs4p/eAUWbP Pd2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=IeMmp01CaCkcaIC5b9/Mcs1IvadvvjfZzZ5jbjY+VOs=; fh=XiMygmgxNdnOTu45L/Jn9yOSg4tG6yASCZ2Cv/+Vhgw=; b=hKtkPGoBz36D/Y5bSS6HeZU75aBROMWgv5YQyoJ1OvwoSEPAT4n9RSUDk598LnCtJc c+Ds4qqPb0tZsYjWoMUeK2eDmvNDtIPkcQ93Yugfuf1huERvGSZE89+phS5xB8aKTeMT Isgxv0lnFA5gZ3RRE8j3/BASxX9Ovrct30Ajw4kZ2vrnSWh6NCiIHPs7bBhyGJYCGjs6 T5ZOfmTj6iXI6eFDMX6Or3bNDKfF89YMk/IiNJTEURKc728rroy4+3U6JeCSnLlZODLV kjP6AZtpzCiMi1REIaPBoMViI2EY0TKyuJv5NygIS6D8ZE3kKY6L/llt7zfrEBQF8REX TMeQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770961382; x=1771566182; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=IeMmp01CaCkcaIC5b9/Mcs1IvadvvjfZzZ5jbjY+VOs=; b=Tp8JTFL0wm4M2We63gwMddxqmqbOerYUe1FPqnpLc5QrWeSsJdmbq76UJV9UN1ApQm HvWf+HEOaIVpjiNZQYOtcfhTvTmcstKFdnziEvRjVc3KU3W/zdaaXsGdeXoMgtss0h8H PZ4ZKo947O+q3p7ekfnFMAqxXwyski+nCQBah/UrpY7Rw0E/3PTeIFNr7Y9kZXSRawle KqNxMBnwNH2vNzlnwVixAtAW6V7kNAa/QFOX2bcNafogjTqeqWyw7+rHWgKV33zyZOsg u2mAZ99TNYsxNGfvGCgLF5k9NNEOP4hZT42XiJCDv5LhgAAUkJquoIX9BnpWUpNTej6Z mL/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770961382; x=1771566182; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IeMmp01CaCkcaIC5b9/Mcs1IvadvvjfZzZ5jbjY+VOs=; b=Th/1LLzSzDTFcP5RqkKBLe0ZJ+fTRh0BNwa9SHMurHR8TrakFMg/pvhGaHzZqbiSkR b5pJU4fx9Ywit8/8fvsR69hD1ZzfBDsUqzsXSnU1GAxrz9WS63Bpp3otPAq+niGYq+ay kTPcJz++dlcFwAJhuYLz5plDo65HFx37MyFdeKqGje9K0IkZ9aykrpwzFQiQDIOsyLYT 8FGMXIQZBVZHyYsatlyBRadCZhX7jJfykzenMFScika+JbRd1BE9n2ZD0JH/DRMtWgec hklxpZgkAXi7Ow/vm0mmZAMTRDL0iIe4Qo9GSXwXx7NZEjp88yOMlkmVkxgnd0IC1WUf STcA== X-Forwarded-Encrypted: i=1; AJvYcCXm5OhbYw/YvG8wOp1G2R4oWlZ3h4a3l+qAjxMtFQnPio9fZtWLH7H2zTskmKF6PujCtMZ32jgacdRye9TF@lists.postgresql.org X-Gm-Message-State: AOJu0YwBPSakOzMUh2oVScvqLcz99rduqBkna7ROb0ClksBB/6VVPHcf OJiw4es6+CtHlfyiCXiZCOXp30Ed014JBBG8x70pqyxJ8A35LD87UZjqU3S+R3u5wxXHK6h33ta dwhaiFSowD8ZOsKJOmJOzlkpaAsG+6Hc= X-Gm-Gg: AZuq6aIUWwtnPgyw0JUDp/0/Dpxz7CUqbUrKrZ/2ILrdue9I7/XReDbDI/ucGzD9zi5 b7NdLQU7g07QXsuQYusBY4TcoJ8pM8Ko2FsoOGtUhrrzFqYIq1dYbZZgMk2EPRpt0vKvRzKtB9W WgsXaiqJRy7ZMB4A7+yh6TEQer43ThgX3mgnSvsXakkg1G/1mmgVEt6X0G41VR5j6reCZxU+ZnZ /ef4a+3rfo3QSRgfBxV3ApP90lyffXYyaygojmcU1/Dy8IbWvAm1zPFLEPTpatkvmNSwM4eqjzq ELIf43Qv9/L038AN+mOIg04eLisEFv3OccudbDPYGQ== X-Received: by 2002:a05:6214:4009:b0:895:9021:2721 with SMTP id 6a1803df08f44-89736348e58mr8589676d6.36.1770961382148; Thu, 12 Feb 2026 21:43:02 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Fri, 13 Feb 2026 16:42:35 +1100 X-Gm-Features: AZwV_Qg9IxHs6QK9oMYgSFg5eT-uC19-V9od3BodihBujuXFESLuYsuWqXcAGLo Message-ID: Subject: Re: [PATCH] Support automatic sequence replication To: Ajin Cherian Cc: shveta malik , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Ajin. Some review comments for patch v4-0001 ====== src/backend/commands/sequence.c GetSequence: 1. +/* + * Read the current sequence values (last_value and is_called) + * + * This is a read-only operation that acquires AccessShareLock on the sequence. + * Used by logical replication sequence synchronization to detect drift. + */ The comment seems stale. e.g. the function is not acquiring a lock anymore, contrary to what that comment says. ====== .../replication/logical/sequencesync.c 2. -static List *seqinfos = NIL; The removal of this global was not strictly part of this patch; it is more like a prerequisite to make everything tidier, so your new code does not go further down that track of side-affecting a global. From that POV, I thought this global removal should be implemented as a first/separate (0001) patch so that it might be quickly reviewed and committed independently of the new seq-sync logic. ~~~ LogicalRepSyncSequences: 3. + /* Error on unexpected states */ + if (relstate != SUBREL_STATE_INIT && relstate != SUBREL_STATE_READY) + { + table_close(sequence_rel, NoLock); + ereport(ERROR, + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("unexpected relstate '%c' for sequence \"%s.%s\" in subscription \"%s\"", + relstate, + get_namespace_name(RelationGetNamespace(sequence_rel)), + RelationGetRelationName(sequence_rel), + MySubscription->name))); + } + How is this possible? Should it just be Assert? ~~~ start_sequence_sync: 4. + /* + * Synchronize all sequences (both READY and INIT states). + * The function will process INIT sequences first, then READY sequences. + */ + sequence_copied = LogicalRepSyncSequences(LogRepWorkerWalRcvConn); Why is talking about the processing order relevant? ====== src/backend/replication/logical/syncutils.c 5. + /* Check if any new sequences need syncing */ + ProcessSequencesForSync(); + Maybe don't say "new" because IIUC it also handles older sequences where the values have drifted. ====== src/test/subscription/t/036_sequences.pl 6. -$result = $node_publisher->safe_psql( - 'postgres', qq( - SELECT last_value, is_called FROM regress_s1; -)); -is($result, '200|t', 'Check sequence value in the publisher'); - -# Check - existing sequence ('regress_s1') is not synced -$result = $node_subscriber->safe_psql( - 'postgres', qq( - SELECT last_value, is_called FROM regress_s1; -)); -is($result, '100|t', 'REFRESH PUBLICATION will not sync existing sequence'); - Since you are no longer testing "existing sequences" in this test part, should you also remove the earlier INSERT for 'regress_s1'? ====== Kind Regards, Peter Smith. Fujitsu Australia.