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 1w7SDw-005KlE-02 for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 06:05:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7SDu-0083fi-1W for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 06:05:10 +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 1w7SDu-0083fa-0V for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 06:05:10 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7SDr-000000027d7-46Lv for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 06:05:10 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-38cb7ce7fd4so2281031fa.3 for ; Mon, 30 Mar 2026 23:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774937107; cv=none; d=google.com; s=arc-20240605; b=EdzAb0XyOPOoIWn9TtwybCXAZdFXkxilBxx8sWBVsZSa5+mtp+rMnl54tlyM5Xhc9P jeL4x4Id12YzGwHs+Sf3sKJBJjdNpBLpGMhU9NLLqwENPjVI3gLBuFm5qdTB8YcRlPy0 c/yaKfCuwtumpK+CSPUkZrWg+2JOX62ntauVTGMkqD0jV9mKF672QkqOIC0x4VCpN9gP /tbQQsIVyZBoF2dVhWZjz+4wxyMGVobEfMUMnslZN/na0rb24FTLbUFkTBd6ZmlTV3zg R9K06UwKujYrB/DveOWpP4HHwBHmhaTrgW6XVQvAT7wKieaz3oWEbf/+X9/QuDT5IbnB 9hBw== 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=y1kvkOjcBOMYRv28ShMY6wGP70oHov8rBONQt1vi5e8=; fh=Gipnf1qU+FztkdNhIP+QtKAGimdqSl9Awr5TcS5hses=; b=EdHnLl9QEUJmVDnwfCXZBvuDJa8kFNNBLMd3+SV6EeZRddL5h0YrKUzEYDG1+2ZeZR hgsyrjhIqH8ZrIn+1d3KL0y5biip3b7elHvnhNsPjo9ufV6vIjmkScsBDyFaPvsYS6s2 1sgvGv0ZiSIo/N5pPEIRh25Qf6BRwYsHDF/0yQ6GpX8/iAl2mgEdLphO/mTtkh+MVwx4 0PE/wpwNJxpG0hHUDUc5yrYWPXNMG4941sykCRRqbCWvtEjPNlrzSo1YpjwkFc+bkmQZ ZlKqQ6wjoYiG5JltV9eVeVx+QvcjCCm+J4KzxD9pqsB9MGjkioWfTinks5QdLx0fftwg Y0Sw==; 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=1774937107; x=1775541907; 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=y1kvkOjcBOMYRv28ShMY6wGP70oHov8rBONQt1vi5e8=; b=WdV3GpFhJIr4AJyjpNOk0w9zDVrRqyxaDs83iFU9rKmbFUzpyrTWXqqVQY+qhdQykx z1Wa9wRO9ZA169DQtz8LJO4Vzj2Yo/VHdyYr05Dy45vy2XWkRED9OFmaO3Xmv+1hNPQq 0T4ycfj7r48uh8KJlWuC5WjTdwVh8VRnCSMJJgRqm3BDXJwDVqyN0Ws2JUWOKRH+8M+c aWLy6Ez0LJvXVSC0xknyMSnRkYS3P8ELMQKDFjBHCv76qXiJWKN+UimwnSu9hbJAdsuZ 0r1BIrs6xEHYAzB92PgKEH8j0S/eCYFEP/EzOzQjwJCKGCZ6uySV3K+8o6AxOJp3qfFg 9u/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774937107; x=1775541907; 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=y1kvkOjcBOMYRv28ShMY6wGP70oHov8rBONQt1vi5e8=; b=bvbtR5stwWETK5xoHeULvpjhrGpaHfOqrl65S/ES829CJU85Tzwg3eawhryuPRTEr3 caYjkzhDpBZxe2ZX9bc8keHwafkWyT5eRnJlQ2NBv/yboRR+KNPixPDQaN68C8aqyk58 xw2rz/emPbvVywWrkNJyEwd5n/jNqDdlYpyZYd1R9w21b4TZSfiSzmtvP5aBz9MY7Lih KhzyxJKVr0olIGLaGbimxifzhvuZGS/nWnOER07H2v5qHIvdZH6ggfCKjyXIt8iPdy0h enmGk/r62nQeLehIpVJ0k8g3j4VA8QZ3jmQ2egjUIWpUFulND95I44JrJx88mTxa8D1r xMzQ== X-Forwarded-Encrypted: i=1; AJvYcCUhNJK5gOKiPzf+5fYQKriDnXiO1TZFBqbPt9OF2IMCQM5KE30jmhdwP0hBSmcoFIg81rVbPlJAdgXc9tHA@lists.postgresql.org X-Gm-Message-State: AOJu0YwPIwNYm55SQBumkMUUzLND+Gs6iAB4n0RtywQbnF4lFujwEm6K hb5wJQTHsyvWXUfCvylHc95FuIVQE5hsNVQhTJE6vMJJfse2oZ56Vcb+EHUy6F7b0qNePr98qpD XNEMXJL2JTGVJacEm3F0GviB/7MRIyA== X-Gm-Gg: ATEYQzyOJo15yVcd292JicornRh9rd5JQcZfY6QlKyDGVXANtGvKpP6ygtJf9bAONK1 xREvS2BDf6rSIExwIoVWkAu9JDjRTO4z18F5Mwb7xoPRcB5Y/DXcxsScsrUqVuJ7cfNExm0JsYP p8pb920HAg/SM6whKgvdLJ+r7BUE0rDbcHqMGv2+2RtAntgBDteXPzDlp5O26QQjeHcZzaDbP49 2EL7JGQsK+IT4xyqtZLQHy7JHO6Rdzw9Q08C2+dMGYRiGcByFzIm/eOtJraUxNn2maZPuxY/x46 c6wKnB4TtTl9O+xzuaEuugX5eFwMz6GqZis= X-Received: by 2002:a05:651c:3253:b0:38a:8b97:7e94 with SMTP id 38308e7fff4ca-38c7308647fmr49984221fa.5.1774937107301; Mon, 30 Mar 2026 23:05:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nisha Moond Date: Tue, 31 Mar 2026 11:34:55 +0530 X-Gm-Features: AQROBzBabAi9hqkOytp5922ymvluoXEqEnGSm6oVCtTb4dhRdUj9cE87ujepvOI Message-ID: Subject: Re: Use SIGTERM instead of SIGUSR1 for slotsync worker to exit during promotion? To: Fujii Masao 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 Mon, Mar 30, 2026 at 4:39=E2=80=AFPM Fujii Masao = wrote: > > On Mon, Mar 30, 2026 at 1:18=E2=80=AFPM Nisha Moond wrote: > > We were using the same log message in two places: > > check_and_set_sync_info() and HandleSlotSyncMessage(). > > I think =E2=80=9Cwill not start=E2=80=9D fits better in the first case,= while =E2=80=9Cwill > > stop=E2=80=9D makes sense to keep in the second. > > Thanks for updating the patch! > > With the patch, in my testing, standby promotion always produces > the following logs: > > LOG: replication slot synchronization worker will stop because > promotion is triggered > LOG: replication slot synchronization worker will not start > because promotion was triggered > > It looks like the postmaster immediately restarts the slotsync worker aft= er > promotion terminates it, and that new worker then exits on seeing > SlotSyncCtx->stopSignaled. > > IMO, always emitting both messages is a bit confusing. It would be nice t= o > suppress the second one if possible. > > One idea would be to prevent the restart altogether. For example, > ProcessSlotSyncMessage() could set SlotSyncCtx->last_start_time to > a special value (like -1), and SlotSyncWorkerCanRestart() could return > false (i.e., prevent postmater from starting up slotsync worker) when > it sees that. Alternatively, SlotSyncWorkerCanRestart() could simply > check SlotSyncCtx->stopSignaled. > > That said, as far as I remember correctly, postmaster is generally not > supposed to touch shared memory (per the comments in postmaster.c), > so I'm not sure this approach is acceptable. On the other hand, > postmaster and the slotsync worker already rely on SlotSyncCtx->last_star= t_time, > so perhaps there's some precedent here. > IIUC, checking SlotSyncCtx->stopSignaled in SlotSyncWorkerCanRestart() may not be ideal, as it requires a spinlock to avoid races with the startup process and it is disallowed to take lock in postmaster main loop. Whereas, SlotSyncCtx->last_start_time doesn=E2=80=99t need a lock sin= ce the postmaster accesses it only when the worker is not alive. Another option could be to log in check_and_set_sync_info() at DEBUG1 instead of LOG level. This message appears only after stopSignaled is set, when promotion is already in progress and the first worker has logged =E2=80=9Cwill stop=E2=80=A6=E2=80=9D. The second worker doesn=E2=80= =99t do any real work. Since there=E2=80=99s nothing actionable for users, using DEBUG1 would keep it useful for debugging (e.g., noticing immediate restarts) while avoiding extra log noise. Thoughts? -- Thanks, Nisha