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 1vsvW4-0090rx-0X for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Feb 2026 04:19:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vsvW3-001pVB-03 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Feb 2026 04:19:51 +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 1vsvW2-001pV3-2F for pgsql-hackers@lists.postgresql.org; Thu, 19 Feb 2026 04:19:50 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vsvVz-000000005CT-3S8T for pgsql-hackers@lists.postgresql.org; Thu, 19 Feb 2026 04:19:50 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-3549bba5302so258377a91.1 for ; Wed, 18 Feb 2026 20:19:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771474786; cv=none; d=google.com; s=arc-20240605; b=G1mzfFyXPhBGQBJOof+1xNbDOpQa+0iLLy9fPwoRTCKlizvU/yP12hZaSsxOx6yTCq QPB6FHYs69MOJLapIBcSX5RLSNtpNaG6XXouemiTtPbMbv5hJ+rl5Vr1jPaX/Smf1M3j oRzO2VQtKHdO3s5CfowIUjt1j7t/Dl8PUxIyDRL8Kp0lvokvxoZV1Fs6puLKAzphcrtO 9FWNMAxwWywHhdgRjv8rsu7fftu3QDBfZO/qaMLNYvelRefHmWvMTICkwnxvCqd43nu5 Z3QDcZ2QjsHCFr6WVaC8XKWOBrpsh6bTYcCskF2Ie92rIvgJ+ydaAARA2LLXJo8X5aT7 qkKA== 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=Xmkw7a+KoZaaTOrcuX9jUtMO6yd988qrula+GCFASxI=; fh=jE5AL0WLwiSfndKjWNjIhZqKgoUSay7DAN7j8ayHmQU=; b=dRb/c+/SrGZ7rMXj/DUmJ5cQ0NTgYfnTc/++1AFefxzYbtix/st/xnhk9tQ3hRbeLj 9dzqUJzVr768cPYJbx7PK8xPUCFzwJsJl3OSx5tOtLunyJG5yTopNBW7aARirIu/tGxU b6o1ACmCnRdkdTgMhK6JCxdQeid+N9up7Y1yuSWhcnnJiN0z+AS41YbC+YbCBAdSRJzC jg4jIPt3iyn65i78s2lu1SAZ+Uy8QwpSSCY6EuvWbzC6mAVy8hcehcSs7H8xHEzHhbtS 6A81b+fZjt+OD5MoCR8857kEC5cX8MSTgyG0vBG1D9A7XFZI4WaeRHTKsg9kMV6p1zDm oUwA==; 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=1771474786; x=1772079586; 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=Xmkw7a+KoZaaTOrcuX9jUtMO6yd988qrula+GCFASxI=; b=bX0sSDsNf1x6uOjOjoSz46JnUle/o3CALvr7KRTJK1tM7OCBmAlPXRFTHyGk0ErjIl WKY2baaUSDCiRI+J6Jf3r6odeK4iR/FBFzLDbwj0k32TIujSFU9BYYLU7wbwL9tc876x AWNB0cchyKPiyxZ86CLvyGePTNynCxei69noUpULGryQ7NTnliMy5DoTgdKvh1X1iv/N QIZcGrcOq02cxWMDDuUDtu2K8iUQu1EnUsq/4Y7hWn/qAk0+kDMd/lWXcihhGLCVSut6 lMBdqyVY8tk86tG3oQ/jjpqoSgAPWSEpZvt4qzPzgYU5j/Tay9QfnpaL0Obc2gbSouAJ A2OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771474786; x=1772079586; 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=Xmkw7a+KoZaaTOrcuX9jUtMO6yd988qrula+GCFASxI=; b=uW/xA7rhPsHkk0pErg3s7w8uLLz4QITVqNAG2nzw3LdgFuivhWnzooBOn0xcX9EmNS Afc548iHXAKQJVT36ayHfdcAffCQNdFb9VBeSfxAKeS91vC1Ac9djMbNSt/CgVjh3Fia 5NsWdxd/90hVmypo4745E35oexepUSOEwR9jx9dM3z8IFxHnc47NJGeQfO+O6NmHPJrv /RX3v9n0H059j2yPe4jQAhvmy4lNsi5HINZbN8hOUSLiwhVGxnUJ3bu71Zk97EuWOY33 cBDmxDKrgb1Lm46sSwbJgJm8N9yIugq10AFyiADPIGkJuQLL3+n+HFunTS7PRB1LcCD6 XXWg== X-Forwarded-Encrypted: i=1; AJvYcCWEoaiS0hwLzirE6+NY7tBn+hsBO7hmuH9BK6Mmb7Z47chpjrgkqHon1Gi+0re5EuSayi4aBSpLzwsX30FW@lists.postgresql.org X-Gm-Message-State: AOJu0Yy1yW1DECZRJU/BkN5NapO595YAPQJIo9mhBVgOMooV3WW21ck4 NzGQ0/eRbrlRf0KYwsXFSj88IeXMOA1tEGFkU5W0D7vLYs/K9TcLtxGQ/oLqNCY6i6yqa/Kifyp VffoBmC5EZ8Ri4CVNkBArLfwN+RftuXZuB9BO X-Gm-Gg: AZuq6aIyVzm76C5gSSd7I85VkYKhBMdbZ4ZeUWqCRLDWoc/am0UPWSOw3kXw15q8Jlf 6QMAVgHPiJaZl4exZnDKFbqYObtOxKlfYqaSdfCOFDhBTpRyq34py2tZdIccm3eaQfMBnEIN6Qh Xq8wrMDxSySlzwIo7FSJw80oc0gJcEUeZ8Lpy7hUJ7htDHLql3N6Uqigi1mhvZSYuQozlwnSSY7 qjNREX50wnj9PxfIuV6l2gkWcLXHei3EdS7jSkB9NHeqeeHO6ktMTFrK+d3h/suPdh0or/wYiH8 AFVVFUbRAGqyzDXgNZjLOEzZvm7ULATWNFcPZN6fw06NuG8stB8= X-Received: by 2002:a17:90b:4acc:b0:340:2a16:94be with SMTP id 98e67ed59e1d1-356aab94132mr17931716a91.4.1771474786180; Wed, 18 Feb 2026 20:19:46 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Thu, 19 Feb 2026 09:49:34 +0530 X-Gm-Features: AaiRm50HLhn8BwI54ro7yWpavppAuP4nRRGal32CPvWccSE25QxXsNGpqkP2RgU Message-ID: Subject: Re: [PATCH] Support automatic sequence replication To: Amit Kapila Cc: Ajin Cherian , 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, Feb 19, 2026 at 7:45=E2=80=AFAM Amit Kapila wrote: > > On Wed, Feb 18, 2026 at 4:58=E2=80=AFPM shveta malik wrote: > > > > On Wed, Feb 18, 2026 at 1:12=E2=80=AFPM Amit Kapila wrote: > > > > > > On Wed, Feb 18, 2026 at 12:36=E2=80=AFPM shveta malik wrote: > > > > > > > > I tested a few scenarios on the latest patch. Sequence sync worker = did > > > > not stop in below scenarios: > > > > > > > > 1) When the subscription was disabled. > > > > 2) When the only publication for sequences was dropped from > > > > subscription ( ALTER SUBSCRIPTION sub1 DROP PUBLICATION pub_seq;) > > > > 3) When all sequences were dropped on sub. > > > > > > > > Application worker stops in scenario 1, seq-sync worker should also > > > > stop. See maybe_reread_subscription(). > > > > > > > > We need to decide the behavior of the seq-sync worker for 2 and 3. > > > > > > > > > > Shouldn't we try to map (2) and (3) to what we do for table publicati= on? > > > > > > > I thought about it, this is what I have in mind: > > > > 1) When there is no sequences and tables to be synced, we will be > > blocking 2 workers slot, one for apply worker and one for seq-sync > > worker. While only apply-worker is enough, as it may restart seq-sync > > worker as soon as it notices a sequence. > > > > 2) In case of apply-worker, when no tables are being published, it > > hardly does any work. IIUC, it just sends responses to keep-alive > > messages. OTOH, seq-sync worker will begin a transaction and query > > pg_subscription_rel every few seconds. I feel, we should avoid this > > unnecessary activity if possible. > > > > Overall, I feel the sequence sync worker is logically different from > > the table apply worker. It behaves more like an auxiliary worker > > managed by the apply worker and derives all of its state from the > > system catalogs. > > > > I understand that sequence-sync worker won't be doing anything useful > in such corner cases but the chances of such situations are rare and > the consequences are not that bad. Similarly, one can say that we can > exit the launcher process when no subscription is present and the > system should figure out and restart when required. No, I don=E2=80=99t think this is comparable to our case. For that scenario= to work, we would need to expose subscription-related awareness and state to the postmaster, which is not recommended. In our case, the apply worker is already responsible for monitoring the sequence-sync worker. It is already checking two things: --whether the subscription includes sequences, and --whether the sequence-sync worker is running and if not, it starts it. So there is no additional logic required. None. We don=E2=80=99t need any extra awareness in the apply worker. Given that, I don=E2=80=99t think the = two cases are comparable at all. But I also agree that it is a corner case, and running additional seq-sync worker per subscription may not harm that much. > In this case also, > the apply-worker needs to check from time-to-time or needs to be > informed to launch the new sequence-sync worker. It is already doing that. There is always a case where seq-sync worker errors out or exits unexpectedly. In such a case, the apply worker is the one to start it again. And for that, apply worker has to keep checking it. > I think we can > evaluate these cases separately and can decide to write a top-up patch > if found useful to make sequence-sync worker detect and exit. > Sure, we can do that. thanks Shveta