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 1vy1ae-00HM5J-14 for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 05:49:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vy1Zc-00GBYH-2m for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 05:48:37 +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 1vy1Zc-00GBY8-1T for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2026 05:48:37 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vy1Za-00000000oTu-1SIN for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2026 05:48:36 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-3597fea200dso3365613a91.3 for ; Wed, 04 Mar 2026 21:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772689712; cv=none; d=google.com; s=arc-20240605; b=C7+8H0WbR9YE6/Ikn3tAEcOX7x+BzP27Kno2NmGKcUsmjdiNVFhmQFYgUk6fF6oN0N zpTf0HjpT3zNnOr29tzIE+xq2PoIDp4hPOrtcvRMvkFptuw0bqPJXL16jyO99Hu7YSBC amUkomoW1moBgkH6PVdVcmjH2MW5ksU5TYeqMulF792O3GHmuZl1Ay82i3PB9GWXS+mE GoHoc8X3vPTvUVsNKUNl5fyGBXAYuSxV/WQ6O+V8RXvWDrkXZQcdCDh5dN7ufkICFso0 HTU9XTOYX1DvAsOFFgr48B+NOOFVOefmrVnRgut7qmVfniZ71kxjgJxPajvxK4IbiD1w X/KQ== 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=3Oan0yZJurIHK0//xcYj45A6VP5wK+yWJMP3Ihoe4/c=; fh=lhza9hicgd1avmLSwLaBl5aSE2c1/sQC+43nyNtKSlA=; b=KBMQLHIXBd9bpYUj7NBhABwCcK7LijLmEhoZ5x0L9kjZjSJbevFpXyvOBTan1q9ZKL eD0mtrn6MSBNP3GGECQBVC4gRqRQCGjYlLyiv5FutixWAQliGTN6n7DXB5Bus6I591VA KVzvDisjvRuQ3lpwoSLiaLuxI4tyaiAreTZDIkFyv7w3/JIoMDRXhmwpzy2bD+29pBI3 6i2GxM70fpV2XVhILcpnKKMq4ZkHRW4XS6l+/m7qYfPi6j5w8Q1izMxyFHh61mh21W+l pAF8Pc0TIX61WP/3IS+v4RJKdpGIaM8co4lNLx882iZu+oNyqvvahWXgu0O9Y3d3Yaao KooQ==; 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=1772689712; x=1773294512; 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=3Oan0yZJurIHK0//xcYj45A6VP5wK+yWJMP3Ihoe4/c=; b=fVF/03j39OdjtF5yext3JOLNvBKaItfoo2NStgIZ0V/fNCXVpWcxUWN2aS7BY+guXY e73/etDo2Ej2HgJ2IahsBaP60IvjIRunembvRZopt1W9X3J3/FJWw4CYI85E/oeQlTVZ ub2VStr+19GvvoR0lr9gHcJVG5rk5gwl4jct5CE7+l25uUyG/OrbYsmpjY7e+HB5k4ZK nwaRkbYRqgF7aFxCngkTUjHLOA9uF9HLZiD5Pn0vpoNsblDjOQ2ltLeFg3K8HslZZgi6 Wui/1JhuHJmfcFZPF5SmnVYaF25NBKEckBLCHGfvryYQWbq0txOFCnXZwOyIfF8Cn3Ow bmLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772689712; x=1773294512; 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=3Oan0yZJurIHK0//xcYj45A6VP5wK+yWJMP3Ihoe4/c=; b=H5YCkPmF2Zo3ncvRaxSBzuEtUHQqq3tYjvxr48MD6IOnufpYhVk2SwOR/p++Br3pM2 1WFvBBQdtpp7ZRFmqNUoy05c8URtZrr5oTBxRCPjcfmvYBn+rz6DhRV5buzFDhxLBIxq iPrdNigUnG+qxIrzJMHIpqfLiWR8MdRzxm7viFksC2QuJEXREAKlE1nJ/SZpxS9LwO3m bDwvtxgXAeNpgODaZ7SIqs7O1B9Jr36SwTpSgGFBPCiRHhij1DCHzQ8HgMbmTYZp+8mA 1P5tr0h5xbMPuG9GmoewyuMg0j7Ga9XAbIT8Smps/g3uy2X3gL6prquGiRv/M7Os1fOm +Bjg== X-Forwarded-Encrypted: i=1; AJvYcCUdA0LXszbl/i4XCpNK9Zs5aqxmcQGS57GRt2B5hEqHdln1gIsmiHLEbtlcKweyjZcymep7oUi3jqHnQqn7@lists.postgresql.org X-Gm-Message-State: AOJu0YyWb+e3R/05a4dP1jJ2zea3xh6e7tYyN2Zwq+4n+VrhUOH6DfC3 k07RcGQTsfzE8i1aasE6QZK943dwxC5qsxHN1oY6CBp4EGP4NqTiWLpcxCicKrDlEGxJnNGqUjV fkRraG3CzuS6afnLDhMIsR6w3CeMYyd0= X-Gm-Gg: ATEYQzxjjF9ygIaiXfUNcdHQ8B8RFxtAROpK0JkkPu7KB4ggkMhxusWr5pCC53NYevp EcoXcVVOiHY7kxyQWZYB8R/zXIqmPiCkyQ7GfAgg7FzWNvNx20BkS4/cfQL1ELFuUcLmKehhZJQ u5oEp8glzCn88skLuB18kLb5xxW+4d3885wTyeKrdRByrocG8TIigJHgN1zCD6/d7RV48zvqWQ1 E/yQ/Czx8zpWITzasfDmaGXAHwNxjxMc0ZijM/WDbl/xqcjIgRqLxDb24SBrsU6JFMgRrQVRdW/ DENpG86Bo/kBnCLzle4+ea0bGHqCa5iN2WbZ2jdPqLx1MSgqCz4pJyt+NdRGs4fu X-Received: by 2002:a17:90a:e70f:b0:359:9a25:d758 with SMTP id 98e67ed59e1d1-359a6a3bbdbmr4070461a91.16.1772689711786; Wed, 04 Mar 2026 21:48:31 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Thu, 5 Mar 2026 11:18:20 +0530 X-Gm-Features: AaiRm52jtGtDwMMc762f4hLi14vLLsOiCFZ3vBLHsgURoXdm-ZX3hC0mZS3xKIY Message-ID: Subject: Re: [PATCH] Support automatic sequence replication To: "Zhijie Hou (Fujitsu)" Cc: Amit Kapila , 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 Thu, Mar 5, 2026 at 9:35=E2=80=AFAM shveta malik wrote: > > On Thu, Mar 5, 2026 at 8:16=E2=80=AFAM Zhijie Hou (Fujitsu) > wrote: > > > > > > Here is V10 patch set which addressed all comments. > > > > Thank You. Please find a few comments on 001: > A concern in 002: I realized that below might not be the correct logic to avoid overwriting sequences at sub which are already at latest values. + /* + * 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; + } 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. Example: postgres=3D# CREATE SEQUENCE desc_seq START WITH 1000 INCREMENT BY -1 MINVALUE 1 MAXVALUE 1000; CREATE SEQUENCE postgres=3D# select nextval('desc_seq'); nextval --------- 1000 postgres=3D# select nextval('desc_seq'); nextval --------- 999 Doc also mentions descending sequences. See [1] (search for descending). [1]: https://www.postgresql.org/docs/18/sql-createsequence.html thanks Shveta