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 1w6AqW-0041iU-1V for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 17:19:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6AqT-00B16M-34 for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 17:19:42 +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 1w6AqT-00B16D-24 for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 17:19:42 +0000 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w6AqR-00000001W6J-1UP2 for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 17:19:41 +0000 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-679f6ee3fb0so1017547eaf.2 for ; Fri, 27 Mar 2026 10:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774631978; cv=none; d=google.com; s=arc-20240605; b=E16B7EBBHRrhhr08myDqYzCj1xQZOETzrmtCYApb68XWc8XsUYqxwP4VE0dAz0Wb/v MqxYAKkI12uFGpsjoFCWUf8+caRBM55l5lZSHgeNww5uNmhBfnlauoKzlESfOnqU5yiF RuFiuf6sUteo5iy52Dr1TpkwtR2VhQmvonFylPl+spP+H9ijuYU653eI2qP9HHc6w4HJ Vsj6EQQp9TvQOx0StBu8+e+kpKo3pH3NclcT/rbsm19wUIP/+MVW59qo/9lKevh+tvAL ymHFjUIxS1x22gbDECgWe4FZmUWocABuXr60lKx3aX3p5hYtlQ6zGGZ43DyNSHJ8AfJi UNZg== 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=Vyv+5x9rd4f3qujZFBba0Q29THffov4UpG4Tjg6v/wA=; fh=7GYfPotT81wCfW/sXsEwqIGJG9NUFKRYeuPda1qV/5M=; b=SqOOnnCISoNoN3bB1h10Jx5/tr49IPAR4IP3MGidHlgD75RmN4BB6nzjZY5rA9uEqs twTZvhpIvuzD0PZAxEELGKuixn6lqsrXBOcSnCJ+VW0e0VKUcKCETK4FwVGLS8xLFIpU 6RWHSgUdzFz36vABWTRiHirv/WKNQZgbvV/EK7JostACjnNr3x8oMmI3LsDLWg9h1qNV 7q3Su9rvvbDd4UGER+QOv58l+goYQruu2wGX730qWiQTbeXnzQdgB6t2SW6B//0H767Q nL6FTMIOPEFf0gWH6yu+e3KzjN7Fm3PVX9NPg+cL3LCatuhc2U+R55jWof7fJYhDknd9 kWTQ==; 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=1774631978; x=1775236778; 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=Vyv+5x9rd4f3qujZFBba0Q29THffov4UpG4Tjg6v/wA=; b=b9nJaM6Zjm+AwhfpOwwVhHs3TT61r2AfqoYVcvdy/hSw+9UshE9+75xYbobj2yKhz9 CHkLzeqO+MCw0/qLQr0MMhC+J1vdZEdtmE4twcaMNRlQpwdvkeQh7qZ64cmR2h4z/Nqs akLGKiw/SKXERn0L7ZfYX7dEkbeQVBhjblaIk+AJTdNBG9xH8AElNC2gx0Sob88kPBgy tXtkknt0yoVcvGb4YxWPigeX51Ru1YD8g2NhUVS1OZF3NWSQ9T2PdAw6UXdT9Z1EVanA 86Bustlvqt/njkv4g5xSFiS/KBXImP9lxewzMFYgJXVXwhjl3Slnlwzp0XyMhchj9UYe Ht4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774631978; x=1775236778; 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=Vyv+5x9rd4f3qujZFBba0Q29THffov4UpG4Tjg6v/wA=; b=HSX1bJXTYjkZqsKeya6eUfxDgB/9wgWsLmixBCihN8OjMM96zM5zT3y77kYv0YdfL9 pOEI3a3pzCYIMJL7LxzEZ3LHwY+BUidSydBS+4PTGm9zCBg3OwJ5vxrB5ydM5lOoK7em fQBPBCZoJqFgl0vzGYG/6Nq9GM10um8fGaSMWiueAyUV00cS+Jj9ffbkFB0kQgwy8WoW SbZ7YVIs3qBP88F8npmNGbqZoVmSZeBWwxv2eforbEAaI2/ygZ1R2cF95LeiOA38mYkp lBlP813azYY8iwa3VzLB7kwoUh6sOisQZYoEY4cB72UxNYJQphToNv4dcp8/uIqhibzI i8AA== X-Forwarded-Encrypted: i=1; AJvYcCU7Ly+7DSa9Q/gtFKoplEoEgqOkAzcZKyQiYhiQHGwt1uiMnh8OOEfZGGcswu0R9PsvdNRdNHobw6OqKMEV@lists.postgresql.org X-Gm-Message-State: AOJu0YzJ43EsF60p4ax69ODo1DZ4BhiUXmWJtPf+xOj8Td8ULUgukgp3 xxjeR3NEbQB3zi4ykDcH6OldnDBP9V6Ux0VaswZdsYboS3XcWoPX9uUMhshuOI5PCiTSW+pipVz gph4V+d9XZ1HlVJtVFMw86xmdz29KSr0= X-Gm-Gg: ATEYQzyR0vA9CQn0f63whq8McCCQzm4mE16/oVIv+Uf/nWLCoq7bXsCnQXyr3Y0suoj 7uvboyA2aGs7kG9UWt943VywjkHcpjZap2fNV5sydR2YQuT+jYfrPoGZY2J/iDNbI4ID11OYe/N aecPvV3fPHZemykZ6GsKCQByO4mzZmBSY4LUWh3vDWz7p+3pjXOFWG+iovClaDskg4L4TvxyvVB 9qYCApb8O9iwEGGdxEmQEdSR/wh7BwqcS7ZYTdyanDMHxlte0CkhHy4A86Q1gF2D6M4n9jo4A/X eqLbcZVBD8n57SrCUY2zQqyi7SRrCfeZbb/RgAKP6w== X-Received: by 2002:a05:6820:1507:b0:67d:f8c8:e389 with SMTP id 006d021491bc7-67e1863f310mr1631536eaf.18.1774631978028; Fri, 27 Mar 2026 10:19:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Fujii Masao Date: Sat, 28 Mar 2026 02:19:26 +0900 X-Gm-Features: AQROBzABg-V0JD2_os3mc_pCyTx3QkMtqwczhVM5GdXyMpLfV1y47dxfucVwu5w Message-ID: Subject: Re: Use SIGTERM instead of SIGUSR1 for slotsync worker to exit during promotion? To: Nisha Moond Cc: Amit Kapila , shveta malik , 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 9:38=E2=80=AFPM Nisha Moond wrote: > Attached the updated patch. Thanks for updating the patch! It looks good overall. Regarding the comments in SlotSyncCtxStruct, since the role of stopSignaled field has changed, those comments should be updated accordingly? For example, ------------------------- - * the SQL function pg_sync_replication_slots(). When the startup process = sets - * 'stopSignaled' during promotion, it uses this 'pid' to wake up the curr= ently - * synchronizing process so that the process can immediately stop its - * synchronizing work on seeing 'stopSignaled' set. - * Setting 'stopSignaled' is also used to handle the race condition when t= he + * the SQL function pg_sync_replication_slots(). On promotion, + * the startup process sets 'stopSignaled' and uses this 'pid' to wake up + * the currently synchronizing process so that the process can + * immediately stop its synchronizing work. + * Setting 'stopSignaled' is used to handle the race condition when the ------------------------- +/* + * Interrupt flag set when PROCSIG_SLOTSYNC_MESSAGE is received, asking th= e + * slotsync worker or pg_sync_replication_slots() to stop because + * standby promotion has been triggered. + */ +volatile sig_atomic_t SlotSyncShutdown =3D false; For the interrupt flag set in procsignal_sigusr1_handler(), other flags use a *Pending suffix (e.g., ProcSignalBarrierPending, ParallelApplyMessagePending), so SlotSyncShutdownPending would be more consistent. +void +HandleSlotSyncMessage(void) Functions called from ProcessInterrupts() typically use the Process* prefix (e.g., ProcessProcSignalBarrier(), ProcessParallelApplyMessages()), so ProcessSlotSyncMessage would be more consistent than HandleSlotSyncMessa= ge. + ereport(LOG, + errmsg("replication slot synchronization worker will stop because promotion is triggered")); + + 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 stop because promotion is triggered")); The log messages say "will stop", but since sync hasn't started yet, "will not start" seems clearer here. For example, "replication slot synchronization worker will not start because promotion was triggered" and "replication slot synchronization will not start because promotion was triggered". Thought? Regards, --=20 Fujii Masao