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 1vxjPU-00H53x-1a for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2026 10:24:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vxjPQ-00CLXA-2I for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2026 10:24:53 +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 1vxjPQ-00CLX1-1H for pgsql-hackers@lists.postgresql.org; Wed, 04 Mar 2026 10:24:52 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vxjPO-00000000Vox-2Q01 for pgsql-hackers@lists.postgresql.org; Wed, 04 Mar 2026 10:24:52 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-3598e7155bbso2067730a91.2 for ; Wed, 04 Mar 2026 02:24:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772619888; cv=none; d=google.com; s=arc-20240605; b=cV32wcGNIWMYkeCHIO+dBbKIROz2E14W4/rps5oJjWoG/LXRM03yfdp/DOrmRPoV/l yUixeNHiXZzsXX+wc7EJGBDF10qHhc7Aw33M7ya6jbTnkCsmXu3AZRGrQdHIDkEaM4YP YASbOb1sWU25KarZJH74DUMg0ZpmCD0ut0499QG8MfHR1lhcG0PGnuhITFjvtn1Cja0I iFNqzlYhRGkKRbCcd/6xzXMe2vnEmQc5pPyMVt56Pn90OFF9op13R5gyxwfH04oPHhYl ttox5gzlgoBNlvXvhoulIN/2+LRLrO5exZUb0RoQevEgfsfR3A8MqR8xXWgjFbCaftvR ny1A== 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=Qzpb1Vo+FcHB7GCyNZr0V4BtVjr/Vgpq0lHxYs/8J8g=; fh=dAwPal4+NgrgxP1KG8aEFugEThqGohjir80v09hyiZI=; b=bmTF7lhXpjX5XFnmnZ+CQ+vHjH49MIKAqQuZ1yKNRaW1A+2MI9MI447j38seqtvd9h lcxK3EV9DVKXUAD6eNh5dr5fbKgGve7Ayml7xZsU41/D8PkkaVtPX7GS4zXHs9vg6rAe VyOxh/G6qj2O2ZHk0aZjQfPC9bVV6uwQNHhxW5ArToVx/8rVoNuVqsG4iDtBl0kHxCAv xfCyweGIw9Rz66leCHIGDSyA9ZQXCbG9SETqzHG971MfclNuA1rQeuVFfwc2Tx6O6PnP 3EesBQKvGKnqnDgxlQkKMVOy6ElcKPYJgyIETvUmKpTHsjEEcbJrN0Joh6MyqjiMaCFZ 7KTw==; 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=1772619888; x=1773224688; 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=Qzpb1Vo+FcHB7GCyNZr0V4BtVjr/Vgpq0lHxYs/8J8g=; b=EomDSjQlV9IdNXJR5TS+z8bXpHuGJ+oTptsiHx1y2ppo4SZDIwSfxkg/auK9++4jCJ WpJ08ukDlp/JNgUlOdcXMHoAWrzTVEHh9xo2TQbnN2CFnkBsayPJMpZYTgGXa4+p+km1 ROZow2aKdyQ27R1oyIC3gXd4tU3OTbRC03CJHYHoITjAz51mSuyIrWQ5ee6USzL7LuoW VDeJglrDz5ZjNsNW3LyPLdI5os8L5Nj+ypItAbHClqqvJdwb0oxn2PvylXNsX5VjbDUV 8IZM1fmoQQqUdcilXub3F2jq6SlcfrKdy2sOTlqwcqe28vUP4vAD2aOySVTSNMYO2Z47 ztGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772619888; x=1773224688; 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=Qzpb1Vo+FcHB7GCyNZr0V4BtVjr/Vgpq0lHxYs/8J8g=; b=s8TJY7NVpJToBZbByiSoyT9qFAdonGyeRz2PFFRMVlxcop78lHilf4ewPVoIQd1J// /yUYt+poN/3pAu6eaeiDbPo+bky7ykVmVDrW0QHLGHFOw//55Si6rnoisRVmu+CQoinz l4p7/jiedKEEvmO3BahHc99al8EJVmQApX6ge4s369LTeuXYIzgXcC9kbuPR3gq1fEBR RWSk6LzOJ8UW6knaniQJC7H/8+ggqWBQpWjuFdUo2jDxbCfBbWTbyvvb/UvzwAHcJA2x XCv833Uvwt0NV5/ldjzQ2etfW132LiV5qv0OOUVU6Ep5yB+b8/tWuXnPtXzo/wnFP272 z+sA== X-Forwarded-Encrypted: i=1; AJvYcCUxdu7vXX3mMHcWbOZF3oUC6oo9GarvAikTxuqutcPGybyHudgSpQT9IeBjCN2x29rqty+ZZEcEj7BlU+RG@lists.postgresql.org X-Gm-Message-State: AOJu0YzhcUO90BOKN+XAZTlE9xOC0H9Tsxwy83qX0ElQItKwTw8qCR7l ELVQIuxqVE0DA83IzuPhKBBQ8vCDcwDwA9lCwGyaNypiVVKaoQmmtqg3o7ibYvgOxcu8ef/EfHg vz5MT+iE/X8Eql/WKhpDnBPXDXllsFzU= X-Gm-Gg: ATEYQzxqKHkuGHD8WJINjZ6C9xY9jxYPxiC6C0fLOhuvjXzRkjXTwJBFkMdKut4cCSS +zOo9eJ6gcQ1Y5lVcQw92wqg8mMT4VLdloE3JHNNKavuBk2LQQwUI4SxJJLJ8byysvheLENnYw8 bSkwqpMF6FTUup8a+wN0cFS10nutgnZ0ay2Eqi9RaUNdw3uRjSgCbn17SJs9FJzRqFkAKSuRE+E hyQohPkr9iRxuJTtmx0eNJEpAPm/X1EWZ8rh8xnNPSWle3YjzDN6t0AlSOAu98efu7YpOidClS/ IW8gpVx65uWoE0Bak1/H1Kp5IKbUTW6OM/4ixR4nkR734BPXdIxegfwXp4izJ8PY X-Received: by 2002:a17:90b:3a4d:b0:359:9224:6c24 with SMTP id 98e67ed59e1d1-359a69a86abmr1426403a91.2.1772619887747; Wed, 04 Mar 2026 02:24:47 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Wed, 4 Mar 2026 15:54:35 +0530 X-Gm-Features: AaiRm53atqNO6-rfvw-TbqTpc0FXjTVZBHfAA6-cVCG-zPt7lBzngrFSuZJ7FLI 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 Mon, Mar 2, 2026 at 1:28=E2=80=AFPM Zhijie Hou (Fujitsu) wrote: > > Rebased the patch to silence compile warning due to a recent commit > a2c89835. > Thanks for the patch. Please find a few comments for 001: 1) /* * Record the remote sequence's LSN in pg_subscription_rel and mark the - * sequence as READY. + * sequence as READY if updating a sequence that is in INIT state. */ - UpdateSubscriptionRelState(MySubscription->oid, seqoid, SUBREL_STATE_READ= Y, - seqinfo->page_lsn, false); + if (seqinfo->relstate =3D=3D SUBREL_STATE_INIT) + UpdateSubscriptionRelState(MySubscription->oid, seqoid, SUBREL_STATE_READ= Y, + seqinfo->page_lsn, false); What if page-lsn has changed and we are in READY state, don't we need to update that in pg_subscription_rel? Or is that done somewhere else? 2) + * + * If relstate is SUBREL_STATE_READY, only synchronize sequences that + * have drifted from their publisher values. Otherwise, synchronize + * all sequences. + * + * Returns true/false if any sequences were actually copied. */ +static bool +copy_sequences(WalReceiverConn *conn, List *seqinfos) There is no relstate, comments need correction. 3) Currently we use same state 'COPYSEQ_SUCCESS' for 2 cases: allowed to copy (as returned by validate_seqsync_state and get_and_validate_seq_info) and copy-done (by copy_sequences, copy_sequence). It is slightly confusing. Shall we add one more state for 'allowed' case, could be COPYSEQ_ELIGIBLE or COPYSEQ_PROCEED or COPYSEQ_ALLOWED? COPYSEQ_SUCCESS was used for such a case in previous seq-sync commands too (on HEAD), but now its usage is more in 'allowed' case as compared to HEAD, so perhaps we can change in this patch. But I would like to know what others think here. 4) + * Preliminary check to determine if copying the sequence is allowed. How about this comment: Check whether the user has required privileges on the sequence and whether the sequence has drifted. 5) validate_seqsync_state(): + /* + * Skip synchronization if the sequence is already in READY state and + * has not drifted from the publisher's value. + */ + if (local_last_value =3D=3D seqinfo->last_value && + local_is_called =3D=3D seqinfo->is_called) + return COPYSEQ_NO_DRIFT; Since we already have a comment where we check READY state in outer if-block and since we are not checking READY state here, perhaps we can change the above comment to simply: "Skip synchronization if it has not drifted from the publisher's value." thanks Shveta