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 1w7nkG-005hmX-1T for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 05:04:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7nkE-00ErAy-2v for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 05:03:59 +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 1w7nkE-00ErAn-1a for pgsql-hackers@lists.postgresql.org; Wed, 01 Apr 2026 05:03:59 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7nkC-000000025GW-2vYv for pgsql-hackers@lists.postgresql.org; Wed, 01 Apr 2026 05:03:57 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5a10d130b37so633141e87.0 for ; Tue, 31 Mar 2026 22:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775019835; cv=none; d=google.com; s=arc-20240605; b=CJrJ6qii6q4iFvNnVA/TsxMxHVWakpj42xb/O2DpgW7N79eGMfZ9vjc5B5To9JlImm pMIlOIm+OzOIGASNqnkFf6PwyQrQoBh2qvQfuXVmOX7zOyT2dGM16ewXuVR4O9jkWi+w znSZqDDerWmkpiWnLjG+eggXFnNee5JcI7c/R3V7lS5hQ7eLfQahLuyfBoD99bAWhtqM MUpAXIfsl9udn7M/tCiBj+HWw+RMKECJdUNIeZNBHaswV3nTOT+BBYbKm8GzwoH9dyat 7uLpRATPPwEXQ/bB+f1VegQVn15+KmY/rd47k2VE9/75TMJDUs8x8aRvuX0oc+hv1WGR qubA== 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=pHzAj5eLK8/aSIzV+AacoA9ytLL3jETOUANGeVaVPqc=; fh=YsGgslZaPRF9K5Pn6O25cEnef651plUo1lsoDOGJygk=; b=YSkdqM6LUOxDXxV+EKfi29zpevlT4+qZ7S5uolCkeFHOkGx1fLNjFWPlT7au7j8pVT 7tJ9qci/3yuEUMS3r/kmYztQCl7DLJhqjNuoONnQ8YfQe3h/KKVLjWWbmIb6A4vKq412 Pti8FkBtBKav1bewc9pNC06zwR9tV23o91PdtjHQ7sPWsusl4qZQRmXW8xVqI7dpzY+X Zyn7/VhF6AP/xMm2AhjmhlSr5cMP92dkG4YyrCavYRF+Rbl3GRul0iYZbSyu8BKUvw9B QkFEdAHBjhmindKl1MI8I+LfG1Nmlgd5+K61sFuL4fo7QZoie35tvFcjZTwXHlVgnHv0 81EA==; 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=1775019835; x=1775624635; 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=pHzAj5eLK8/aSIzV+AacoA9ytLL3jETOUANGeVaVPqc=; b=L837dOQ3Gz36H2FFcgYagfz/feeat++NZDKs/U2VmhAwqI/2o8AkLJs6NTbZnHRFJs Oz8q/aGC1CyyDRiyv16jdggN2D2hkiimg1s/Zzaxv6iO8fxPLRc4qpSUwdq6dw/tiLzJ FYont+c/xYjBewBI/rV+b8Tw9WSRgy9YrTfY5b+VK7UCRRqiZOCsd3mfQFBjjj4GGfC8 ub/vYeiNNmhKvK7I1LWhrw39tpbMwjQ0NpDmI2iInQG4WrvzQI6S+5lWYnlXrN8gZfwa anhrty4qxLgozxf88GAAIPtE/TyGcnRfMy1cmB/yiZ+tXmvk5yoWjl7bOAi27rdpzQqy JvvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775019835; x=1775624635; 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=pHzAj5eLK8/aSIzV+AacoA9ytLL3jETOUANGeVaVPqc=; b=FFEOFX3jYEOl4jobWryN6L3jFU8oiVE/4Rk3wyrJg0hCb3QG1fyR31og+YI/R3EmLn +ANsw4rfj5Q/c5nxQC+zGPnHTHFi2LJjb+SADsrlRXqBCm8QVw3xHIwuiBCAyw0BvpQK 6sBMW+vLEoKcofiWRUTrt/djYBVAfHNcfotc0IKdYYCUXQVVpS5ZhH0Acgu49A761Bom kkWkgf5g+zsLfjf1wooBI0W/lPBwEiN5wgS0VOVRoUwjQzU1DtL6Tcgg7JWkMb1QlxaY 0SPvkfK5c3MW+dU+HMd7gQZ6DbbJQ8aInFqkrtgj9CjT5QRsCHY8uIRxdDI9MvYLEnbp hbqA== X-Forwarded-Encrypted: i=1; AJvYcCVgg5lceDPwNNuiJkZJs0BBN4miguZeTucyFDlC6cipjPLuuhU9v57oxVdh9pNu30DSwak/JhvG+NKVkg3g@lists.postgresql.org X-Gm-Message-State: AOJu0YxsMP1A76jgILPfoH34OHvB0U9oRb/Dmor6sfTTjE3FumU0fmKr FZLhE6dWnz2WVpSU1jvq+uPlJynr/6WZC1kZkafb2HGQDr5KpKvjBzmrJFyia2wlqtVN9Wd3VSy 4AB/5iTdLNK97qSJauUHRP3FbaAsPGw== X-Gm-Gg: ATEYQzydo1FjlH9ilQAyHan49RbOBlIUwnLeif3FXRpIvlUv6mEqCwcIUtVeTMosuHD DxXR+UJoZmFmlHM3bqJGXbdQ6T6MHucVpkPt/3r9PyKetyAUadT7mPHd3b2pZrgctAtRQE3Z+xn AfeiFwsHfJQnzZRPs8eflzztWB3Mj1wyNRx8eIGaMQGCbr6X210mu0ku7X9V8X39szL+Fd5A86S 0R43Fc077ZCiTUYkei/vyOaDM5mIEZDr7r1BXplpq7fnBgIMp2h9MmzpTaWjpzC9J0xP2rXdI+5 cpTxMlZUlRfQqQ== X-Received: by 2002:a05:6512:4023:b0:5a2:c0b8:26e with SMTP id 2adb3069b0e04-5a2c220b4afmr571550e87.21.1775019834805; Tue, 31 Mar 2026 22:03:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nisha Moond Date: Wed, 1 Apr 2026 10:33:43 +0530 X-Gm-Features: AQROBzBguETpn7SXIy_J-DYjQZw0fm3j9VzIMo9lSgKXbU2taRBcXYWIuqstof0 Message-ID: Subject: Re: Use SIGTERM instead of SIGUSR1 for slotsync worker to exit during promotion? To: Fujii Masao Cc: shveta malik , Amit Kapila , 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 Tue, Mar 31, 2026 at 9:03=E2=80=AFPM Fujii Masao = wrote: > > On Tue, Mar 31, 2026 at 7:42=E2=80=AFPM shveta malik wrote: > > > > 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 ret= urn > > > > false (i.e., prevent postmater from starting up slotsync worker) wh= en > > > > it sees that. Alternatively, SlotSyncWorkerCanRestart() could simpl= y > > > > 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->las= t_start_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 lo= ck since > > > the postmaster accesses it only when the worker is not alive. > > > > > > > I agree. > > Could you clarify what issue might arise from checking > SlotSyncCtx->stopSignaled without holding a spinlock in > SlotSyncWorkerCanRestart()? Is it actually problematic? > We might not see issues in practice since stopSignaled changes only once (false -> true), so value corruption is unlikely. But, without a lock or memory barrier, correct value-read is not guaranteed, e.g., on weakly ordered systems (like ARM64) the postmaster may still see a stale value. This means the worker could be restarted again, and the same unwanted log may still appear. > That said, since the postmaster should generally avoid > touching shared memory, it doesn't seem like a good idea > for it to check SlotSyncCtx->stopSignaled. So I'm fine with > instead lowering the log level for the "worker will not start" > message to DEBUG1. > Okay, thanks. I'll share the updated patch soon. -- Thanks, Nisha