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 1w5hfX-003XS0-1H for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 10:10:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5hfV-0023Tp-2w for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 10:10:26 +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 1w5hfV-0023Th-22 for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2026 10:10:26 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w5hfU-000000017br-1BSi for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2026 10:10:25 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-38c51c8e055so6450531fa.2 for ; Thu, 26 Mar 2026 03:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774519823; cv=none; d=google.com; s=arc-20240605; b=TLKwLXXqFItEScsxhi/BPu03kq0vqUVTPjZVZtY5WO0qzoaqR7DmR3eCTe93Q94iGO 5Q+NY7CmNVhH37N+h/va1OvhmfXS/EUm3gvTs66H96/g27iBUzvr92SjPbza31nwc8+/ 0GQCcBbtH/qH7SF41cIAK4xvOX+SjQMvwjwFjCU4WAIG85+Z8PXbAuaFWuV1FxpIRWdd WIVNwP4vlQHevf+DuLxk9stcDwf/VeFmD2xAUeCVK/N5sL1pgRCUYoEkf1Cl3JGpT+6q nyLWpib1LDzXRkwk6MUCpJ0ZSulgSwq/Id9Ez8mixKYiY3d0DRVPg23LmW2CAPOajRh2 Eeow== 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=sJlW7oZfXPLtbq/nAfc0QXhJHKAEuZ+8WPwmwY8806c=; fh=x4xgi4tdDukVB0fBuAIe3vORvD36rbbTBlhrrGN8QbM=; b=TiPKvNQqwE8Mxf+KXU1INImhNhRiBf1bq7P22KCgWBG/JxNKKJ8ykBH0mHgFrePWmX uwKlDHppjsSmHMQJQ13RsKHFPALB9l3LJaaiMvdRtdJuz9kGoHrtwb73Wsd4F5eed8un h5ODU75d5Oeh9yLAVyNF60xg0tgPEzFjVA/kEpuzg4JJY/tbN73Tahel5lIFVpv2QdQj TNq2KEuK0HlhNwJdz5qU8kMT6WNAb3A1YlIXJpMbtl4jB52xj8wPLGJHnRVan27VR6tt j0CUGkQitXs7ydSI+O1GUg2LRDcWVqo8eLSlOH8cR2TTL0DlOMw6OfNSqgfKrOBWGtwt Yd6w==; 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=1774519823; x=1775124623; 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=sJlW7oZfXPLtbq/nAfc0QXhJHKAEuZ+8WPwmwY8806c=; b=QIh3A3Ov3IOS2e3EKwtllhzGyXbj7MzPrg91QlsaRJq2xhcCMMZSlu0lTel0nND1p5 uh8BZGCxBkZeRj/av3APQk3cctdAYk2nc3pzXS+yFpRDbiTZFj8LhFJXo0clv9jM+FqH EpDGQUFvQmilFXxIXFQ4lHk5kpYszECbvenum8pnZajpoZ1Lkpr2yZH4AxjtfVVp4hs1 3tpFJukOvnQI2FeqCJWF+LRs6q4h1gK5LBbP2LQt/QLRUuG4IW+SA0AR4t8O6VCqlISD QfhcsaCsRHS/YKaP01USGH3pJ8I+7hxwZrxhl7etJrvDs4yQOd/tBwgzrxGJMFs9HtHg pIIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774519823; x=1775124623; 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=sJlW7oZfXPLtbq/nAfc0QXhJHKAEuZ+8WPwmwY8806c=; b=Ep8PueI03usnejgXy0Rmhhm2NsWirI0cYWx2j7bj2uYga5+Pz7ZUVvbJVroaT7wT9D fBA8ZBK1uAOnuFg2gvKpfIrwQ0rfnekL5RaK2UHZ7Mu9w2gag2pwn3d1NjzHk0cwZ7dS DCiFxPXzdRbUofnP5sbf3zxOtYPXjagJt9TQYkEFvizdVfGzPqsxGYSv1ObEneHugbTK AjBKAyLiKc3/ngSqtsXJvRJygd4zAy6DIVhYb4tOiEP3bMTJb68DlJZZJJ5kZj4gZDi6 GdyvncsCMYuDb8o1CeWvkIs7V8+F8J/jXawkmFCaT4JmIdYjpbe1hmZSY8pjdPZ5yHC2 FKDw== X-Gm-Message-State: AOJu0YwnUX1hTRyQ7wV7HSnfFhTB1KjZuU7BbmYM7X8vpxAVTzXlqBOq dRX18hkhfleBfnvycqcFu1bTpJMqZ6QPr8F5+GpwxKLRwaGm5eOciGYO+uNK4a/QjaMUvLfhqE4 7KsZd2QbBs31TOX7QcHoRCzFKd+KdU5A= X-Gm-Gg: ATEYQzwPS4oWH5mxza2mnGa7AsUSIj0p9aSD6t9T6yEBP5KpsJCk2axp9tbC97JcTyc zABZBmRb5sa3qj8fWRnPcGUO/vJZQo7MDUvgCjSFvNxizg5e542cuEgS+S+pgybGvgKtbSNdmKq ox/yljO+KY0PL2U9VBWhV1voitvQ9b48QPyX7QLpP5FZ1G7vby1oEF8b3T3yOccIGczhGwgrErI 6nuDSQciSWFbJVESn1M7E0Opv1m0vE47vVkGAVN8+LeHW9YQSWVfaknIZVjejAy/mncMRwVgU3x v9fUs6lHniWE7eviM689lGOI6EGFzfRDcFL7EyWT X-Received: by 2002:a2e:bd08:0:b0:38c:6552:a602 with SMTP id 38308e7fff4ca-38c6552b5dcmr4535521fa.13.1774519822424; Thu, 26 Mar 2026 03:10:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Thu, 26 Mar 2026 15:40:10 +0530 X-Gm-Features: AQROBzCZgKKEyBbOuFe6SCHyc0y79OXjSc-X6usJ8eeVZltouhEgtA46iYe_JSI Message-ID: Subject: Re: Use SIGTERM instead of SIGUSR1 for slotsync worker to exit during promotion? To: Fujii Masao Cc: 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 Mon, Mar 23, 2026 at 11:21=E2=80=AFAM Fujii Masao wrote: > > On Sun, Mar 22, 2026 at 1:52=E2=80=AFAM Amit Kapila wrote: > > > > On Wed, Mar 18, 2026 at 9:35=E2=80=AFPM Fujii Masao wrote: > > > > > > I noticed that during standby promotion the startup process sends SIG= USR1 to > > > the slotsync worker to make it exit. Is there a reason for using SIGU= SR1? > > > > > > > IIRC, this same signal is used for both the backend executing > > pg_sync_replication_slots() and slotsync worker. We want the worker to > > exit and error_out backend. Using SIGTERM for backend could result in > > its exit. > > Why do we want the backend running pg_sync_replication_slots() to throw > an error here, rather than just exit? If emitting an error is really requ= ired, > another option would be to store the process type in SlotSyncCtx and send > different signals accordingly, for example, SIGTERM for the slotsync work= er > and another signal for a backend. But it seems simpler and sufficient to = have > the backend exit in this case as well. > As we want to retain the existing behavior for API, so instead of using two signals, we can achieve what you intend to achieve by one signal (SIGUSR1) only. We can use SendProcSignal mechanism as is used ParallelWorkerShutdown. On promotion, we send a SIGUSR1 signal to slotsync worker/backend via SendProcSignal. Then in procsignal_sigusr1_handler(), it will call HandleSlotSyncInterrupt. HandleSlotSyncInterrupt() will set the InterruptPending and SlotSyncPending flag. Then ProcessInterrupt() will call a slotsync specific function based on the flag and do what we currently do in ProcessSlotSyncInterrupts. I think this should address the issue you are worried about. --=20 With Regards, Amit Kapila.