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 1vseQY-00BvhP-1q for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Feb 2026 10:05:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vseQW-00FLYz-2A for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Feb 2026 10:05:00 +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 1vseQW-00FLYr-1F for pgsql-hackers@lists.postgresql.org; Wed, 18 Feb 2026 10:05:00 +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 1vseQU-00000001CP3-0AK1 for pgsql-hackers@lists.postgresql.org; Wed, 18 Feb 2026 10:04:59 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-35621ce8a9cso2453028a91.1 for ; Wed, 18 Feb 2026 02:04:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771409098; cv=none; d=google.com; s=arc-20240605; b=P4lrJK03DD0/1wNZIxhXjUj9OJ74fytjpAvavhmmyASfMAMVcE0OwdNjYr0Qr2UnNs 1N7B5bKuVEsLgQr+Ja5SJB1gJhkEJN7bwUc5hdo1mfagymjdL3v2YlrrCPcphbFtYGG4 uEVIZaoA+sCIosgCcfYIyY5fwgo1zvHhCoPQGbD/tRAg+ChtQ28iLNCkBKwfYNWOfRPS biJ3ZyrM46G2/S7K96kt/ytXLuqr+5/v6fr3JhSo5/ZEj86u05HI79mCBcw8t20WXoW8 TPkMUq4EgzeppkhwJiFogUQ8VNmSC+sghkV+Q62kynfyTBEYCmKx2fR0yoVxwvAbzg3Z KRmA== 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=HSHgw2etLikxqZkw6L6KEwxEnNKyc4n0Zae8D1jsMiw=; fh=SNnkjvPcTiSs5V/3KIc98MW/yq8lzEJYwfdC2hm9/hk=; b=c8NPFxVBGlPUbnJzII8dXz55/7hlmXCvWE97yGmJZ6xfoQCUKURGNAQTvmxzED6FKW ZzMh89/r42PuWLUGcIkskcS8Jq6q52QfiWAC7XT1u+wJlGBa6mtcQNFveTJSGcoacanL KGk/+FGVXp1b00hlk3+Ep6ItDJsK1f+cC5qDh9m9O7pZMp45bUupX/8EWAu0ymw6hBym WK4f3w81gavSAeda4xaXVcZLJIgAdVhe+7yo7x37IMlqQ7tt618FFRlBfq17mQi8SyKl dxbe9oGyLgGFH8WZNFELZeKM/Ih32nTcOAL0fhQfbwDySDZamko3Ihdgl50QThlWdcou imbQ==; 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=1771409098; x=1772013898; 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=HSHgw2etLikxqZkw6L6KEwxEnNKyc4n0Zae8D1jsMiw=; b=N8/TxIJCljXUTBj7xVhdE8fXaSuMS7E4G5K3+bcXAn9dKwhlR1XZkAr1gHNJr9jd/i TPp8Khf0A9Z3cotYACtTu81dH36Ii/nKRVn4itzrn2KjXaWRDhp85l9ADv7p2pzK8WU9 qGxjT4powyZYEzWJXOm7Cr7n+f1Oa0XzQHQuCPxHZT78gf6/D80BqgZSkvrn11jT8S2k aZhBArPTRZXbyja40WcfvsRK27AJmXga0xA1HA8gDrl6sV7Xtvvgy78DsxuHKhY8vJ// VPFc3aGxI2Y2p4FavosZXW7bioLNqXZjVAUReO2dn+BTGWkUkAyCut8QyIfVmyrx+Hwz dGFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771409098; x=1772013898; 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=HSHgw2etLikxqZkw6L6KEwxEnNKyc4n0Zae8D1jsMiw=; b=TfOYkDEChazwFqHvnCTLG+LRpDkUq4WlM8geMc4t+Wp4EffOBiphtcHSfEw/z6MFFH NS8e0QsLqXMKf/DzPAb19+5huv/jvTZZdOvjiVFD2pu7YaZEM9TOdf3A+hJ9ZigurN5X pS0Yj6fRG/y4SokJSAbgAGzM1YHGxh0ZAXias718U6Oqxo//4PE/L03IPoKuNXLmTM2j yagcjsB0E1NSX2z9kmuGnKfQPZkNVhMWTsFg3/CHKs2t9OBgNJSsFpiYK9xS8BwGW0x6 1n2zzFyEIshfajQ8cvRB+N44smK+Hh2Y5Rjz9J3DsSooeORYJa2TlJtVUwQhRzzk73Yt X3Mw== X-Forwarded-Encrypted: i=1; AJvYcCXv620qONgp36nIU7hDcOugiBfpZAUQzf9rdsAnTU8d/nroDyUN4JNL5K7JBXvpBJGMc7HKbkCF3XwRClIP@lists.postgresql.org X-Gm-Message-State: AOJu0YybIyrfikiE3gKVfTFa0cWJmi3I/c9vzPBcrCW22vXoiO+rawpI tZUmviRujAWiodmaEDJNaoU9rADW4lXwDevty38OfVmtdhW6L0DguTlhaGpb4FeWHKMLePEpseB Y54gzPUdKsFiz7hc+A6eh1tbc929OEw8= X-Gm-Gg: AZuq6aIzeokdxH64x4U5JHStiW9rhc2kmIjtIfrQPpOrZZNN7sIK4oE3lToCJU8NzWd 3k8LIoNDCcwGLeVicQ0C51T5ZFxKXIK2A9enjM+120yFZK8Dvk84uxM8V/+zROZstHMgCG9CzSc p+WYwPv2hEe3BZ01BTh3vyX0wCpyBrzyvtYkbBG+KlZMQHe6nKvTwegKvGaM+S08lv3ELvQdR+A EgIzAMt71JMOCLQM2VPm2HoadnSq1D7MP9ViGvFLBORfB24CAcc/4s/uyYajZMdNCRYP59KbYsw U1LyHDGbFW8bkf48ODPdrijh4vW/96csq07gjrBtACcPpko6/QSW8F6hVReqinsB5ZN8+XSo9AD pA6RKv1o= X-Received: by 2002:a17:90b:274c:b0:343:c3d1:8b9b with SMTP id 98e67ed59e1d1-35844f85b15mr12430492a91.19.1771409097817; Wed, 18 Feb 2026 02:04:57 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Wed, 18 Feb 2026 15:34:46 +0530 X-Gm-Features: AaiRm53DW9blXziavxLXiRdK0LDQSBiovAAXpIKgUGqzjtdCktPJ6bdMcjN65JQ Message-ID: Subject: Re: [PATCH] Support automatic sequence replication To: Ajin Cherian Cc: Ashutosh Sharma , PostgreSQL Hackers , Amit Kapila , 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 Few comments: 1) + /* Check if any new sequences need syncing */ + ProcessSequencesForSync(); + Shall we name it 'maybe_start_seqsync_worker()' (or something better?) and move it immediately after 'maybe_advance_nonremovable_xid()'. Thoughts? This is because we do not process sequences here, we just check if the subscription includes sequences and start worker. 2) We can also change the comment atop ProcessSequencesForSync to mention that. Currently it says: /* * Apply worker determines if sequence synchronization is needed. * * Start a sequencesync worker if one is not already running. Now, we shall change it to: Apply worker determines whether a sequence sync worker is needed. Check if the subscription includes sequences and start a sequencesync worker if one is not already running. 3) I noticed that copy_sequences is invoked twice per sync cycle=E2=80=94once = for sequences in the INIT state, and once for sequences in the READY state to detect drift. This means we ping the primary twice during each sync cycle. We should consider combining this logic into a single copy_sequences call. Since we already have the state information (INIT, READY, etc.) for each local sequence, copy_sequences can internally check the current state and decide whether to transition a sequence to READY based on its previous state. This approach would allow us to fetch all required information from the primary in a single call. I also think that we do not even need to mention the states here and we can give a single message instead of 2: DEBUG: logical replication sequence synchronization for subscription "sub1" - for sequences in INIT state batch #1 =3D 5 attempted, 5 succeeded, 0 mismatched, 0 insufficient permission, 0 missing from publisher, 0 skipped, 0 no drift DEBUG: logical replication sequence synchronization for subscription "sub1" - for sequences in READY state batch #1 =3D 5 attempted, 0 succeeded, 0 mismatched, 0 insufficient permission, 0 missing from publisher, 0 skipped, 5 no drift 4) FetchRelationStates(): + List *seq_states; It would be better to initialize it with NIL. thanks Shveta