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 1vv61e-0038p7-16 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Feb 2026 03:57:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vv61b-004RxU-2X for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Feb 2026 03:57:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vv61b-004RxL-1H for pgsql-hackers@lists.postgresql.org; Wed, 25 Feb 2026 03:57:23 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vv61Y-000000019tL-14zE for pgsql-hackers@lists.postgresql.org; Wed, 25 Feb 2026 03:57:22 +0000 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-3590042fa8eso469321a91.1 for ; Tue, 24 Feb 2026 19:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771991839; cv=none; d=google.com; s=arc-20240605; b=i1pUSSThkuwPiIxmiqWRPpZPRdF+dRDddhrCIizcUhw18D7y4SK2+i7Hy2VeBzu0a2 j7GyQC+fe5/bvlFcg2Za4OP8mNHopz2ttdX5W8H6ZBfuGBvxSOCJQkKDZuU1o2XUksq8 wpIDLIsaK+FXVER/wmEx7J/fwNPbsVJ25+pxNq2JCQYCvodbtIYhxIEduAZtE1ioZYsE uttDf5j9WFnofERLAKkWdSR3qbuMKKsrwPpuqzmsV6eJyWQ/6LtSljjwkYKbbwUGC/Kf 5avz4lUe7sCobcp1UHxXnWeCLw8gLjlTEhK3rvYapn2bYcKGvh1PVzNHcEhyF1sqGMx2 hCHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=k8m1I9XTPdxIkFycmTutJ7OzoPvpLH4KrVdPy8784VI=; fh=82D3XxPSglwIrc4T+GSAlqVHKMH6vQKBwKhtXGq8Crk=; b=j0gTU/es1LIy7vtgfwGUA5rXkVFiewSSqG6f5jH7GXVSmsT8As8JurGPQCf2ofPdo3 o7Ho98hugOmnFhvH8Dj0lfZSKHmT89fWwReKehZ+Dc5NwNFdRSH8wgH0tk0DBa5uXQzL qx3ZWN1UQTkc4qq3GnfzP2bVDRlhfwLQMDJP1sXjMfV+wDOZMa309t85fPuTtKlxv+/3 pHoQFZ3RgyDDCdxbs9/4MYsx/CyhdQ+3uxgJ2T74llHoYFCAa+XyOr7YEBIwUeIYbp3A u2ilqpD50zI9vk+e+n9nzweFxHrssHuDIwT1EqGYKWy6LmgL8aL5rNKv+ZDcnXf6kl1n aKHA==; 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=1771991839; x=1772596639; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=k8m1I9XTPdxIkFycmTutJ7OzoPvpLH4KrVdPy8784VI=; b=I2j/IVDw+1XhlWuPYNlNiGM5V+iiFg+S5MoMulnTKIQH2FFqOWSol4KdF9RlwbudGJ 3zkNL7Q81mcYsoRY/q43vto+8qPxe9oJZwzEPnQqtouxj9EbCmpir6H0ytWTvp+3BQzU vFZQyIRCEQ9k7eF++8VA1C52f7WNzZ2cjeLE+MVyiaJGSkajgd1bDfQpJUS8KAeY8mN4 jmnLkxhZ+Pqpv1ApU9JoPx23eH+mAHV57/XdDX5vSA+tf+hkURyhqZk1MgK4WyaiLgI7 g1OpXYuReF7HlPXhicF/hV0d8bElDed78YEn4ZicgURdS3DfNIooN4tndBKiVnKCgveY GuMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771991839; x=1772596639; h=content-transfer-encoding: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=k8m1I9XTPdxIkFycmTutJ7OzoPvpLH4KrVdPy8784VI=; b=n2vNV9vbucOGi7B9PAaceWl58NleRy+OFXNiQ6L8kFUq4mbFD5k7C5mrP5ryXHM12r nnCgAPwTJ9sNBK0nuc7kWJkZCG2dQyqqPjoULjGwBQM9c8gXn3EI2A/TvaoIJiaklpdV 2Bn7uO35kqu/57iIZF6C2vCUFmjrVxUghYtY/AwJEjlA7NJPZER6sEl3njcxrsfJ40Za AcZIiEm+hRYuW07S+dVv1HsKvRr9P6rOCplza+KK9Epq0kcYy81tXmjLOlNkr6a1Y6Pf B79qqBvaL4TthzWwwOJuLk9ZRf4TlbIveggPrD+w1UTlDMtjsMewqrRr70EHvdd3k5Hg Pvqg== X-Forwarded-Encrypted: i=1; AJvYcCXXQ9aKOLCceFOCG/bAIDGSqaeBa6TRJhgkN27VZG17f2Z4T6+aq/ZaJsgiiDz1Fmz/w4nmvDwU8tPX5UzH@lists.postgresql.org X-Gm-Message-State: AOJu0Yw2lpe8YddhoDACr0IPNHCCzlIP28OkB0paSW6IRetMsWWhP2FK GvioVKBqi/ohLrZJEDY/w3UfN9F4dwnsoOfYgH0AFeepR5vzDf3wiMEFDzWZF564Zj3gLxc/12K 4PzB/TFqJtM4+xtJFFyjOUY1nHb24L/o= X-Gm-Gg: ATEYQzxNHHg9uXx+FlS4dzMGas2uhT5tiPKKYfYiEakG6BjnVt3naSjFnNfKvLmRJGg /Mrw3YsVpwhX77qHtJhF31OXyJ7XJuYWyvrXeRnzv5aCmkU+ulmTpTdpb5151NHDH5LaqZyJyIe DycShKH0LBNYTN4AzcDRjmE546WMSsB0zHBA8uHNCMi4NiB7/uDbj57CAfRTWdIoYnMb/9OiWm0 9Vbf1bpmGVTDl7OMbj92EzV1Fqndv8LDQJlM/yRE1GKw2ldxKKWK2GxauIToSCBt7MVisa9wlop IW570CQaX63etOZ2va2c/bAKJPxQi9dS5tuFf672mW7QxocR6nzD68IKGEB63Ejd X-Received: by 2002:a17:90a:e7c4:b0:353:3b33:8263 with SMTP id 98e67ed59e1d1-358ae7fe516mr14897013a91.9.1771991838517; Tue, 24 Feb 2026 19:57:18 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Wed, 25 Feb 2026 09:27:06 +0530 X-Gm-Features: AaiRm52OqYijwxDh1LK1DL1198jEWUm2gY4ysZsqXUtQh8b0HKWfE3jRsf5DSeY Message-ID: Subject: Re: [PATCH] Support automatic sequence replication To: Amit Kapila Cc: Dilip Kumar , Ajin Cherian , "Hayato Kuroda (Fujitsu)" , Ashutosh Sharma , PostgreSQL Hackers , shveta malik Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Feb 25, 2026 at 8:32=E2=80=AFAM Amit Kapila wrote: > > On Tue, Feb 24, 2026 at 6:49=E2=80=AFPM Dilip Kumar wrote: > > > > On Tue, Feb 24, 2026 at 4:55=E2=80=AFPM Amit Kapila wrote: > > > > > > On Tue, Feb 24, 2026 at 4:34=E2=80=AFPM Ajin Cherian wrote: > > > > > > > > Currently REFRESH SEQUENCES can only be called if the subscription = is > > > > enabled. All it does is change the states of all the sequences in > > > > subscription_rel to INIT, this will prompt the sequence worker to w= ake > > > > up and unconditionally sync all the sequences. For sequences in the > > > > INIT state, it doesn't check if there is drift or not, it updates a= ll > > > > sequences unconditionally. From your discussions with Dilip, I > > > > understand we want to reduce the time it takes to REFRESH SEQUENCES= at > > > > the time of an upgrade. If so, then this might not be a good approa= ch. > > > > > > > > > > The point I was trying to make is that with automatic sequence sync, > > > we won't need to execute REFRESH SEQUENCES before upgrade or failover > > > as the sequences will be in sync. > > > > > > > That is a valid goal, however, the sequence sync worker is an > > asynchronous process triggered at specific intervals. For a switchover > > to guarantee consistency, we must disconnect all connections from the > > current publisher and wait for all pending data to sync. Relying on an > > automated, interval-based worker at this critical time is risky, as it > > directly extends our downtime. To minimize the cutover window, we > > should either treat sequence data the same as relational data > > (synchronous streaming) or manually trigger for the sequence sync > > during the switchover phase, i.e. REFRESH SEQUENCES. Anyway this is > > my understanding, do you have anything else in mind that how you are > > trying to completely avoid REFRESH SEQUENCES. Having said that I > > agree that in many cases where sequences are not frequently modified > > it is very much possible that when we are in switchover phase all > > sequences are already in sync and if we can identify that then we can > > avoid REFRESH SEQUENCES, but my point is we can not completely avoid > > that in all caes. > > > > Right, I am also of the point that we can't completely avoid REFRESH > SEQUENCES in all cases. Having sequence sync worker syncing > periodically reduces the chances that one need to perform REFRESH > SEQUENCES, so we need both. Do we agree with that? > > Additionally, I am thinking that after sync-worker we change REFRESH > SEQUENCES functionality such that it will refresh all sequences during > command. And, even we fail to copy one sequence, the command should > fail. This should use almost the same functionality (like we sync only > the required ones) as syncworker but online. This is because the case > where it would be used will be less likely, say when due to some > reason like max_logical_workers limit, we are not able to invoke > sequencesync worker or just before upgrade (when sequences are not > already synced), so doing sync during refresh command sounds > reasonable. What do you think? > I agree with the overall direction of the discussion. But this is how I look at it: Given that sequences can be large, it=E2=80=99s not always practical and ma= y place an unnecessary burden on users to manually verify whether all sequences are in sync before an upgrade. Requiring users to inspect sequence values and manually determine drift before deciding whether to run REFRESH introduces unnecessary operational complexity. So instead of trying to find ways to avoid REFRESH, we can position it as the final safety step before upgrade, optimized to refresh only drifted sequences and to fail if synchronization of any required sequence does not succeed. This approach gives us several advantages: --Users don=E2=80=99t need to manually check for drift. --REFRESH becomes a safe, final synchronization step before upgrade. --In most real-world scenarios, sequences are likely already in sync due to the periodic sync worker. When everything is already synchronized, REFRESH effectively becomes a lightweight confirmation check. --If some sequences are out of sync (due to high activity, worker limits such as max_logical_replication_workers, or other edge cases), REFRESH will correct only those. This creates a practical win-win situation: fast execution when sequences are already in sync, guaranteed correctness when they are not, and no additional manual validation burden on the user. Thoughts? thanks Shveta