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 1vv5AZ-002PrD-2g for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Feb 2026 03:02:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vv5AW-004NUq-2k for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Feb 2026 03:02:32 +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 1vv5AW-004NUR-1O for pgsql-hackers@lists.postgresql.org; Wed, 25 Feb 2026 03:02:32 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vv5AT-000000013O9-0eKm for pgsql-hackers@lists.postgresql.org; Wed, 25 Feb 2026 03:02:31 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-389e268a9b4so2698301fa.2 for ; Tue, 24 Feb 2026 19:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771988548; cv=none; d=google.com; s=arc-20240605; b=U44U+6JCtFrB9FwiXryOKEOrSE0P4hcj/tIky6+ZBEjREKzU5jxSTrtLz/+Mb731Co GbiknRcHyAbIi7UOD5ilNwZoiDzZmKnB9IvnrAYZ1YNPSRhFs8lz6cMBh7xCUKdonihh kuSEjFmGqRWbhOqq5/JbLIdjbYVdsCvckxr5wF5hLrmK0yPa3fZ9nHEbGFcVf49Aj3Ty II8eDPtvxe4HWGMR4qamr0MwsGIopme5g75UO0Pwe0Vhv7zBriMjsTwsw/emm0FeOpsQ TiMGCasCv5NzoiUTj0ncI0fEQAL4VdiubimjlGBf1PWa16AsGZlDpES6vTxMSrcuRl+Y /kCw== 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=Xj0mvN0+sFU2XIICQSdyItQr/3PDbe9lZpBO8PQIDXg=; fh=ltIKbs0N74lqR2SmUyGqtFIWQFARoWUQl3kHgg2zZvU=; b=QrzdL0y5pcLMh7oyrr7RG6ZGJKYMjIUTlOQXbQPqoqDVla2CKZOpw32Ow7Ujk8VcPU 2LFajyR0gRj3pk18IMU/hxOx+A5jMl629V8EliQWGTF9yhIrF0DGaPxvrzIA//MiWaOJ GwYgtM3R+E/4eq/rxmK0INEIvomUHf5jd8PmFd5j+l8sd3c0s1cGCLWBl4k1QX4zYkPy HxKYv312yTdI7X9I00hAFs6D08KrPBbk7o/QFVQte1HOS8hIbsEiwx8epKsp6FQUJbXQ g8Wmwx+QkabJwY3DBEXAELghDEcAE5qj0BcVUmfw67yDFdzDeld2Q7HriBJBc61WDQ50 g4QA==; 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=1771988548; x=1772593348; 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=Xj0mvN0+sFU2XIICQSdyItQr/3PDbe9lZpBO8PQIDXg=; b=j0BrcUvEtmPlvameV9Iy1u+xGpvk8KbF/a3jgGwUvpR3Arj9+6fkGXG6/IpfH/pBtA tt8MwBnPX3GfmOzos536qusBSKOGvzYMjTSA1B7r+3LMNTzZ6LmPNskrKuRBRdTsyiy0 TDZEIj9cPzjz/+nEaXyb6Pd5qcD0KXkALC8iA/NwT8jtOJYn44/ETDi427ySQCDSnROi BtPwZdVXXE1HoKR7K3T4ssre/1ExDy1ZcCtt7NF9MRRH6fKOVVk6lq1t5D0o84JTTF8j ZQBohoaj8kG4P2awo7yXm0M9XeNO1sGplT4BJhKm+MhT9zXuLp/cAkVa2laje0vvwcRn PUOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771988548; x=1772593348; 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=Xj0mvN0+sFU2XIICQSdyItQr/3PDbe9lZpBO8PQIDXg=; b=oW+kHrzTAvvW/BzqhmQPdOcyPpATyIy/CGlDzQo3UDeeamkOmhnjOPCdbKJVutmIcb 0PVvMDYDGDlEQe2TYqLZydvF1uP1IOuWAx8lbqgaAsyfiUQfQ2AUmmracSpm8AiR/Szp qPl/Ks22GyRwTpmYlza07bBhWS3CILu3jKBcQLgbZLxM4/qzu3sp/oxfx12uEw3OPXR4 qOZRxmRe2NCg1rT7VkSRkcTQBex32iKafABvt5Pf0yn9RrYsj6tDsn1t5ajjlgjo/dp8 tFfoEc/+HjM6nJ/Z8+pgKA/EbclSXavfPECd45qtXKGOVQjYcAqFny8SqQPrNXp9uL9I WAAg== X-Forwarded-Encrypted: i=1; AJvYcCXwfSUpAVtqfchuyopSDVR3tMPG1a0aoD8dgDDLaNIJVjsNW85VPzdIKAcenfq4xvqFQtrx6fHA/h2a/t5O@lists.postgresql.org X-Gm-Message-State: AOJu0YzR5uCaMxJNQ4ocZNjqlXQbto+d5sA4SBNBi4X+MpuMSYaJlRSY RsHR1Ln50b+l72G8BmjqsEdGWli9vkJFYIi9tSeFHEAr6rRMWYAc2FWoo+dk+a9V2KoajI030XF K8b+Emrdc6Ae0vBhY/WVMire5FUbzxgY= X-Gm-Gg: ATEYQzxsG4JYB2P/k5I9vDCdNGYkt7wZBWF693UqNvHCIUM5ZRywakO31Ag8o9H6l5Y 17ZHcZKDImxvkN9WPHrMgq3Q4f+rtnimCkqNeHd/2bOpiBj56YMm4BM1nshm2SfhrM4IbLD2SUm ucFeTHJWPEP2gIpMQKDpHsK4iNLQzgcuC2AP/X0klDCH16pK5kfVLsnXt5qmoXRUZV+tfjz4kpv Rli8gpqZdX9OL5QiY79vtWRXW2iVfbIFJ1TUWfmwME2Veu8CnSaCajr6Jq6Fd6AE0ktr2pJiCTu yyZQMe13RMut/5fsOA80C0bvOfPPXqfhLvEG7hnuupDvFuLJ720oEYUY5CClqMP73JsGVbwE5w= = X-Received: by 2002:a05:651c:19aa:b0:383:26ac:4fca with SMTP id 38308e7fff4ca-389a5aa066fmr39414401fa.4.1771988547497; Tue, 24 Feb 2026 19:02:27 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Wed, 25 Feb 2026 08:32:14 +0530 X-Gm-Features: AaiRm5251btLWNtObxRB2Kt6hw21mfX9answA0ryLs5UWnber-JybcOgNxRo6pk Message-ID: Subject: Re: [PATCH] Support automatic sequence replication To: Dilip Kumar Cc: Ajin Cherian , "Hayato Kuroda (Fujitsu)" , shveta malik , Ashutosh Sharma , PostgreSQL Hackers 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 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 wak= e > > > 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 all > > > sequences unconditionally. From your discussions with Dilip, I > > > understand we want to reduce the time it takes to REFRESH SEQUENCES a= t > > > the time of an upgrade. If so, then this might not be a good approach= . > > > > > > > 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? --=20 With Regards, Amit Kapila.