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 1vyQvq-0006qE-0J for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Mar 2026 08:53:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vyQvo-004Brb-1Y for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Mar 2026 08:53:12 +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 1vyQvo-004BrQ-00 for pgsql-hackers@lists.postgresql.org; Fri, 06 Mar 2026 08:53:12 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vyQvm-00000000kM5-0WEw for pgsql-hackers@lists.postgresql.org; Fri, 06 Mar 2026 08:53:11 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-354a18c48b5so7805596a91.1 for ; Fri, 06 Mar 2026 00:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772787189; x=1773391989; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DH/kyU9n9X7+SQMddLrBwOcOvenEjBhbnANHr0Svtso=; b=ko5K3Ci/gZK3ra3E1nDKJvImy4O0cD9Yyf967sH9+8M+SH73kQUqmARcShwGEvcMOr nk33n4npYyK26Zf0GW+xhQVUKbDiBdbpcqizkXdnQB7OpNCVHapHRXQkzqi8srqltHBC 1VL/QyzBIoIQ+Xe8ztnnnqosrfwrnUPYA7FVeWRypizc4+4Nrp7leI9GeHbRdli5IXhG zlgEoOldTrm3SjNuK5rFeRR/fQrXAX5zTaJlbzYNdhcguRvcUKNjh+8oQ6j3bHxUVoIm RCgLHgmboryA1aVVqWBUcCdFh1Z7yOG7G1h1c3L7lTreQZRQKc78cwRkXKSmPpbG699S zFJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772787189; x=1773391989; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DH/kyU9n9X7+SQMddLrBwOcOvenEjBhbnANHr0Svtso=; b=JPow+RNJIf5qSyVgG+NjhMTQ1e1crZD7OfZsscobZUXjz6m7ATQ/lQtvmjkwc4JA71 0xZevA1C6d96XjPCH4gBdPOPjhCbMPrEy/hZRfdDhT7QEddp0FYP6xna63lxBpgxTSes hzBmPNP5P3Vqx+ojA8YhjQ+44TkVL5v1ixZ1e8DkEq269Go44A7xs62JiMWzhAx0ddEB mkL9yb8l8VTW0EpDlF5cDSG29RNnPyubugGjJANwVPurAE0mmvBiA2QmOJSdqpuxqYq7 1E3hDKPuw69yIYOVozGxEXumfJc7DtGPIUQ04LKcq2eckH7D3tz1X+bSuJxLYNyS26eg MhcA== X-Forwarded-Encrypted: i=1; AJvYcCVtAOG/SrMteOSnQE3uoG5MdeDyUx6PBXlylO5NloG18+EztKGSWO8egSBf6prDu5u5y6q2b+HyMGQnPQSW@lists.postgresql.org X-Gm-Message-State: AOJu0Yw6NsyazLAdoT7hBXW6GdV2L/kULGq7l+oa6B6cUn3d4iz92N5X INWm2mo3pSoKUm5W6cf3UD5wqOnWH61OSoGcdNv8ROnXMg072eh+GfxC X-Gm-Gg: ATEYQzxWFpUX1S/JUri4cvSdxV21KhO6wNsHxI1k/wCza0A78Ne4uge4BN2NPpJWojI ZwFUMY+1mnSKIlnX80EFK5+3PImvx3GZ7FDGUOXu+wpVIXREw3zZKRERRS1nhA3P+eG9weqVhsH RS8aeOrsKk3BVAYUUpr6ZdzKb3vN5tEB8MbFrG7ZsNT8WMEpl4xhV85c/WIOo2IgbJA4Ps/y9Zk ucvXbz04CLP6AGEquV4yAxWVG2lawl+DIzDeSc75D+c8CppmcNGggXG5U3yvZTz06FRcd2r/NNW N5h8SlQreQXyQ/gIDTQ7RvbnxM+4sILY6JMCx4jEjb9lxOLjViqiTcDJrfYKJbaTpMY/cjWJi7V l5CIp+301S9qspma90c4HlNBRp8Vt8psyjVhR+ZDKAZpDlUn+jqsX7Ij5LKvJcbqhFtPCmZ4DGd 1SoEdZvUmmdXwTEOlvKp4PAolGEGQdEoY= X-Received: by 2002:a17:90b:4a50:b0:359:8c89:96d3 with SMTP id 98e67ed59e1d1-359be297579mr1397316a91.15.1772787189124; Fri, 06 Mar 2026 00:53:09 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-359bc9bd61fsm779769a91.3.2026.03.06.00.53.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Mar 2026 00:53:08 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: [PATCH] Support automatic sequence replication From: Chao Li In-Reply-To: Date: Fri, 6 Mar 2026 16:52:28 +0800 Cc: shveta malik , Amit Kapila , Ajin Cherian , "Hayato Kuroda (Fujitsu)" , Ashutosh Sharma , PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: To: "Zhijie Hou (Fujitsu)" X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Mar 5, 2026, at 19:34, Zhijie Hou (Fujitsu) = wrote: >=20 > On Thursday, March 5, 2026 1:48 PM shveta malik = wrote: >>=20 >> On Thu, Mar 5, 2026 at 9:35=E2=80=AFAM shveta malik = >> wrote: >>>=20 >>> On Thu, Mar 5, 2026 at 8:16=E2=80=AFAM Zhijie Hou (Fujitsu) >>> wrote: >>>>=20 >>>>=20 >>>> Here is V10 patch set which addressed all comments. >>>>=20 >>>=20 >>> Thank You. Please find a few comments on 001: >>>=20 >>=20 >> A concern in 002: >>=20 >> I realized that below might not be the correct logic to avoid = overwriting >> sequences at sub which are already at latest values. >>=20 >> + /* >> + * Skip synchronization if the local sequence value is already ahead = of >> + * the publisher's value. >> ... >> + */ >> + if (local_last_value > seqinfo->last_value) { ereport(WARNING, >> + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), >> + errmsg("skipped synchronizing the sequence \"%s.%s\"", >> + seqinfo->nspname, seqinfo->seqname), errdetail("The local >> + last_value %lld is ahead of the one on publisher", >> + (long long int) local_last_value)); >> + >> + return COPYSEQ_NO_DRIFT; >> + } >>=20 >>=20 >> A sequence could be descending one too and thus we may wrongly end up >> avoiding synchronization. We should first check if it is descending = or ascending >> (perhaps by checking if increment_by < 0 or >0), then decide to = manage >> conflict. >=20 > Thanks for catching this, I changed it to check the increment before = reporting warning. >=20 > Best Regards, > Hou zj Hi, I just started reviewing this patch and wanted to first discuss the = design. The current approach introduces a long-lived sync worker for any = subscription that has at least one sequence. I noticed a previous email = suggesting that this approach is =E2=80=9Cacceptable=E2=80=9D, but it = still seems like a big runtime cost. What I had in mind instead is whether we could extend the WAL decoding = protocol to send RM_SEQ_ID over the logical replication stream, so that = sequence synchronization becomes part of logical replication itself. = That would make it essentially event-driven and close to zero cost at = runtime, rather than relying on periodic polling. There is also one case I haven=E2=80=99t seen discussed yet. Suppose the = standby side inserts a tuple into a table that is under logical = replication. This might not immediately cause a tuple-level replication = conflict, but it could advance the sequence locally. In that case, the = standby sequence could diverge from the primary sequence and remain out = of sync indefinitely. How should that situation be handled? Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/