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 1w63oc-003uZr-1W for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 09:49:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w63oa-008oPX-0F for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 09:49:16 +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 1w63oZ-008oPP-2Z for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 09:49:16 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w63oX-00000001SFH-3GuR for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 09:49:15 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-38be5d7c27cso17623091fa.0 for ; Fri, 27 Mar 2026 02:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774604953; cv=none; d=google.com; s=arc-20240605; b=S4ut8G7dEIY8McR5giIxJWVQWV0ejLeD3h+lMUrUo1YzGZvTI5HwTLJpAEgdC+mKI5 3DNLG5R0fyj+SW20XdwqFuinbC9IZOBXPe7C5h+gD3QTqJmHZSAduZlh/BbekTCStSiM LFj4JIhIx8Wz+rjhI0EgTp7HVq66L6tSZQcCzbRDelhXXO7iRCNJL2AQnkee7WAIv3/P om9tkQf1yATZAHG6xXeaGsgfxxHDXYWL9Ridgnhwp01c+iDLae4kp2Iu8ucz2tFUjbLM +9NkbSbVzPdsFQTmNHP0y9ewgS/mpyX5gIHYMeIdsWDif971FhG2h79V7b/xEUv+dt4D veHA== 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=DNRbhW3k+0PJpXrTuYtRqQU3FouWDb+HjSYaWxpgJrM=; fh=lcE4fJCbT6qU9WRh7mTylSE5y2Zmcnks1SlUzIwZYsw=; b=V4VqhBHdL5iWjYFl07MXTN2V+RQz7f9KVgJm06p2tZb85I2yGH1PLshlKH1l7hv7Jq XDpO+hHvl/ZcBMrwRPEn1fsHBc4USmPZe8PxyP82x+ggffRvmciZFn4gMtinyqwvsU+1 ckFALfXYUDqaUUyXvqbfY7ksodc5b00CO2lDsoaWIEr+lC2k/TBitHTUEV5+7yB57DKi vh/9Q2KhfBLLi1yczXGmoGbU+bx84+aWhC4BFpllXAjenqK3Sl8viSnNoESByZj/u2T/ zDPEwmfWzoTk7KiG+Ii4lgAzWbaMjLrFKN758LucN+GEB7paiZjvjAw7AHdWdcsr62Gs AzGQ==; 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=20251104; t=1774604953; x=1775209753; 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=DNRbhW3k+0PJpXrTuYtRqQU3FouWDb+HjSYaWxpgJrM=; b=IdWPY1Y690a3clIC+M7hjisIUPEaCJ8y8zfIIzqjtBoTu+v6HYdwnHVZHEapvn/WDL eXUz12iMuUdfwnI95CMUS7lZ6+mHFpbkoW+ieKLEfYCx6MBuOjaBe7/VCcJQ3Z2mAZ/e I+xTZiZdb9neBBbWxdGoPyKIV6ft3cDW02Wyuhc20r5XbYNAmDWf3sgxULEWgIik60F4 8qfdf7jLPhKlekspbIy5iHWR6Rqx2f9P8S5y4LllpZgjMI6x3i2TTplUrRS8MfBWAi9/ +k1RZbGazqxXIsKdxTV8HKpjdq8fjMenlRc3uCTWXupuDXdoHSS5Ip5MresnSTs7Grs5 SSYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774604953; x=1775209753; 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=DNRbhW3k+0PJpXrTuYtRqQU3FouWDb+HjSYaWxpgJrM=; b=VF7BXcEjodFcGykYlbI1SrLmrjkIH33hWJmTYRZVhSCo8xuNUcLLsO6gIP7FMvtHbH nEEIHJKPzb7HhL/rnR90ZEiz53wNaOkNk/iA74wyeqosphp2rtPak/WHhopIHxaP7MEx pTrUR/KHbwa9gUpOnEoueewbcxOAwDWYv3cP/kjvFhYo/GRiwXZzWOpMVV3ErG3W7VZo UrlszOZiy6z1eifHgpjTbTYZvr+TrZ09u5ZNKHN7dKv6RT8687AAYF0p4UIcEV7CJgwm 3GWcF1YdFBFpkFgQTFXlfHfbm8l+g1RUCC2ioyl1ZFEbN8m96E0MRERaiJcxnOWU65IT iWJA== X-Forwarded-Encrypted: i=1; AJvYcCXanrzi1wZ0bQTMHK6s4kI43Tp0BuX8UgQF3pv7K20/wGy9znu1xjN5FLaqfTV5QNnVvwsFemgo3/GcNKwW@lists.postgresql.org X-Gm-Message-State: AOJu0YwTFYVRGaFWnO+RGRcNKy5jFhdOQBLbuA5IQLBLBbikHmKO1+g/ ++8AMbhO+MhnrrUswLcVemkUdNk478L/gbhvmqGrwlr2VkHecuVkK4KJUoEWuY0qfZvcyGfvMQU PHzrLodVL+/Vka0WOC01uADc8ujAQW78= X-Gm-Gg: ATEYQzykl+dPvL5oVc5u1xWA0MAOhyvMEUKYVmR3iSLuiIh2WC/E8s4ceWiGgei/9OC rpUIzl65zbg9JA4k4fZ77yNShuSMCTG6J5VDu9xOVNZl+uMpPvcMzBCN++O4iI9O/yd8OU79gOe mx+SpwmCxCZ4v21WrjMK+Q0LiheLy+AvTCqo+SFsJe7yd+hU6WikNdqBUqH7vAd4XxdP2aIc3Js N97qTiH0WDpEafyOhf0kLg2lHsxS6oP5LBznoeI5WmlUuIvQm3Wy0GYEaNFEd+Jj25f4FFLmuju arYXXjWTZGeBEdVGvjlA2tfAZS9Ve0g1Gk0lfvFbp+a93VabgCHF X-Received: by 2002:a05:651c:3057:b0:38b:d5f8:bdd8 with SMTP id 38308e7fff4ca-38c730e9db5mr6527601fa.9.1774604953030; Fri, 27 Mar 2026 02:49:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Fri, 27 Mar 2026 15:19:00 +0530 X-Gm-Features: AQROBzAtFvDX-0QxiCVHIjqJ3UaDCqWSo6siGyYk68bERgyilFr64haxnjHpNYI Message-ID: Subject: Re: Use SIGTERM instead of SIGUSR1 for slotsync worker to exit during promotion? To: Nisha Moond Cc: shveta malik , Fujii Masao , PostgreSQL Hackers 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 Fri, Mar 27, 2026 at 1:19=E2=80=AFPM Amit Kapila wrote: > > On Fri, Mar 27, 2026 at 10:27=E2=80=AFAM Nisha Moond wrote: > > > > On Fri, Mar 27, 2026 at 9:28=E2=80=AFAM shveta malik wrote: > > > > > > In ProcessSlotSyncInterrupts(), now we don't need the below logic rig= ht? > > > > > > if (SlotSyncCtx->stopSignaled) > > > { > > > if (AmLogicalSlotSyncWorkerProcess()) > > > { > > > ... > > > proc_exit(0); > > > } > > > else > > > { > > > /* > > > * For the backend executing SQL function > > > * pg_sync_replication_slots(). > > > */ > > > ereport(ERROR, > > > errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE)= , > > > errmsg("replication slot synchronization will sto= p > > > because promotion is triggered")); > > > } > > > } > > > > > > > Right. Attached patch with the suggested changes. > > > > After this change, why do we need to invoke > ProcessSlotSyncInterrupts() twice in SyncReplicationSlots? > Also, not sure if it is a good idea to name current function as ProcessSlotSyncInterrupts() because we remove most of its interrupt handling. Shall we copy paste its code at two places as we do similar handling at other places as well. Another comment: * + + if (SlotSyncShutdown) + HandleSlotSyncShutdown(); ... ... + if (CheckProcSignal(PROCSIG_SLOTSYNC_MESSAGE)) + HandleSlotSyncShutdownInterrupt(); Would it better if we name these functions as HandleSlotSyncMessage() and HandleSlotSyncMessageInterrupt() because for API, these simply lead to an ERROR and that would match with the ProcSignalReason name PROCSIG_SLOTSYNC_MESSAGE? --=20 With Regards, Amit Kapila.