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 1wgc5d-006I3x-0H for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2026 05:41:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wgc5a-00F3vS-17 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2026 05:41:54 +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 1wgc5Z-00F3vF-2o for pgsql-hackers@lists.postgresql.org; Mon, 06 Jul 2026 05:41:54 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wgc5Y-00000001l8l-0AHZ for pgsql-hackers@postgresql.org; Mon, 06 Jul 2026 05:41:53 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-6983d3dae7aso5366111a12.0 for ; Sun, 05 Jul 2026 22:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783316509; cv=none; d=google.com; s=arc-20260327; b=Zl2TS4EOlGP4gtg6s37QckSB6EZ5ZN32TbWkPCq1mpxukQ3okTrjWP1PJ7KR7lddnj anfWXLHJ0fdI8N7GPE5YReQYrDsIskqx4z6fuBvs3SeqUXGU4//nGWKCcbmy30QRBb9h 2hS9GQusliFHM7dombVtnFRmZwk2+eKZvZNgq/vw7G9u2i5uzWgU7XO/BIYiaveCg7bO fbN3HeeKH8dsgCjPFwsDLPP5C0VfpxN6nw29VQ1V3rtJCRONBSwHKovGKYnsolNXOuXT vtp7AF6WDeDjS0SuV3/I01A6YvP2NZUBpBVJEw10ngsN/0uckpKX6TI/TrKQiFtPaFUN sgGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pRAYvNPLBEY7ODOtczgn0KSiMALhfFLd95WNZdeULhA=; fh=0MXLZXneWHPGi6vmL6uyMpuTzmSrmio2Z/3TXalEuB4=; b=dgVWJiLZXo7XxKjqlRpcWPQR5g5K3hxDvvLY6QrKdQ5Qrlo1fDRqhnhVkZ//SCHyVS N/YL/sy7C4Aasdu/goVqVkoTDUVtZlsAzUG6uYchr4ibMo7luGi6JJtRJCbCtACGDiMh BZY5FIMn0L8GVBHGtl9HWZBlINV6FGj3Av8UGUTw4nRyrdtOrNzDlvCN8ZXtDBOmt5Oj BV/iljk/zXHP+QBzBvRuM6h8aH7WTd9TxIOAI3272nEt17zcqG+JwD4fDUF16a+9iG6C OdcZL93ZwSCcABVl9LPi9BgRdvlCX0wovI8G8pB5+uQBqRFV4+EsGZ/+dJdKQIdOIE7+ ingQ==; darn=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=1783316509; x=1783921309; darn=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=pRAYvNPLBEY7ODOtczgn0KSiMALhfFLd95WNZdeULhA=; b=OQQHBJslPJDfHE8fe91lb0yD1wlg7qFrzTZcZv90EsPbYAyNA13q9G5FNgiXaHUegT EhKNWYKoQ1E60JEX+Ip+bPni3NvSVdUToGOiLz1Zm3tuZ4ammrP6IJhX08pQ/qZWjqOW S47yBhyn1HM8ZVwzrt4yfQevL0HOgIts70wVBpRebQBACbrpfDyk7TZFlaL3pMEidNHE YybJTHgfgBxwX+sDadHhFmuuc8bOOZ2ujHMBlxcs0a2NXYnSvebDg4FTY/u5Sr8Toy/z Lveofttwjhz3QavAaHQt3OoTZIcOYyV98uown+wcwhv6mLTzFgQ59R+inCwrj/YonHWZ EZhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783316509; x=1783921309; 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=pRAYvNPLBEY7ODOtczgn0KSiMALhfFLd95WNZdeULhA=; b=TXcEHcKc+C6AwzVEpNn+GbyWbL/hUonTrIBLFN0P7NpWEYN4oKjCr4prSTbkStL8NR z3S5+evRpw0evPmQyv1+YwwSGiG0YBPTj45PC8inmSgs+efcAeA+g8wRZHRkagwZDWxd vkvHnedqEELatHfY5kTy6RnwRDDOwoNV5fSAT2pc0FhWBqP6kE+3cWKr6qUNzAcUDyIj IgYVDWxuLDNsW9Qcg5n14C0ib1lIzRczNV/KbTXJzvtF9Jl9wNFOzNn4qemV0jW/vvpm MSLUo7v/VwzH/d8RMvs1EKUCDsR81NeRCkO6rrfebUWfpz4IuwKMJwma+umYMBOIo9uT N9LQ== X-Forwarded-Encrypted: i=1; AHgh+RrvxNnPXKrHWHFACWeRF2sJb1yaFy51/dk6XN7gQe5u8Mu9OjcrtVyt1C6WzAxn5yJ5T2Rc1QuH9mDIb6b/@postgresql.org X-Gm-Message-State: AOJu0Yy8TKxH1/Iuhmkv3l27WMuvTRUCgjNFJgz6AdE4mzE/RMVBgNN7 kbMvpkr3IaJD8Khvr5571lA5CJY0DUaHUGRh3E5R3niLnN3bUmLnm2B4L0hIcVk2Vl7LDEMq7cm +h3rSEfRQ8uISrMJr4gbNJYEMqeIFgx8= X-Gm-Gg: AfdE7cmraWXg2W7a4tw1AGSuBIifAc2JSDxX+7cKvmMNzAFOl8w7IiDfc8dqTuJKrKm QACg0Abckd74NwGxbJBZ8Ro7I3BDFT1K+dg+sg9E2ozhQFB2rWWCGjlxLokN1bNuJDAyZ7xzppo wUIj2sU9xllKdYU+bGWoe1WZD4BmfFnzAgWtjQVxTHe+uGP2XfCcREo/KHCOkaJMlof2qFwjvlm WFwd7fEiNFiGyeg5dlWLQlgGA+PtnINeRoWYmj3Hf1B5e/StH30KULLst0R0wlsdZYwUQrV1+Nz 9YL0M+NW8UC1ewWLotn99vbcXCGhQFjgXn4k7Id4n0bLzsrPIaU8Lwhxm72WtIGhVymuqvwqrq0 1QtFAU4HUAy+ENg8S/zEm/PK2Udk= X-Received: by 2002:a17:907:3fa6:b0:c12:3cbf:9f6d with SMTP id a640c23a62f3a-c12e624eb96mr361801866b.1.1783316508075; Sun, 05 Jul 2026 22:41:48 -0700 (PDT) MIME-Version: 1.0 References: <20260706012642.f9.noahmisch@microsoft.com> In-Reply-To: <20260706012642.f9.noahmisch@microsoft.com> From: Xuneng Zhou Date: Mon, 6 Jul 2026 13:41:35 +0800 X-Gm-Features: AVVi8Cfz2LYZdV4qDWjMcyieBwDPAzVRakF2SOW-LgMVl162zhEkuQjnR2LysRo Message-ID: Subject: Re: wait_event_type for WAIT FOR LSN To: Noah Misch Cc: aekorotkov@gmail.com, pgsql-hackers@postgresql.org 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 Hi Noah, On Mon, Jul 6, 2026 at 9:26=E2=80=AFAM Noah Misch wrote= : > > commit 7a39f43 wrote: > > --- a/src/backend/utils/activity/wait_event_names.txt > > +++ b/src/backend/utils/activity/wait_event_names.txt > > @@ -76,34 +76,35 @@ ABI_compatibility: > > # Wait Events - Client > > # > > # Use this category when a process is waiting to send data to or recei= ve data > > # from the frontend process to which it is connected. This is never u= sed for > > # a background process, which has no client connection. > > # > > > > Section: ClassName - WaitEventClient > > > > CLIENT_READ "Waiting to read data from the client." > > CLIENT_WRITE "Waiting to write data to the client." > > GSS_OPEN_SERVER "Waiting to read data from the client while estab= lishing a GSSAPI session." > > LIBPQWALRECEIVER_CONNECT "Waiting in WAL receiver to establish con= nection to remote server." > > LIBPQWALRECEIVER_RECEIVE "Waiting in WAL receiver to receive data = from remote server." > > SSL_OPEN_SERVER "Waiting for SSL while attempting connection." > > WAIT_FOR_STANDBY_CONFIRMATION "Waiting for WAL to be received a= nd flushed by the physical standby." > > -WAIT_FOR_WAL_FLUSH "Waiting for WAL flush to reach a target LSN on a= primary." > > +WAIT_FOR_WAL_FLUSH "Waiting for WAL flush to reach a target LSN on a= primary or standby." > > WAIT_FOR_WAL_REPLAY "Waiting for WAL replay to reach a target LSN on = a standby." > > +WAIT_FOR_WAL_WRITE "Waiting for WAL write to reach a target LSN on a= standby." > > WAL_SENDER_WAIT_FOR_WAL "Waiting for WAL to be flushed in WAL sen= der process." > > WAL_SENDER_WRITE_DATA "Waiting for any activity when processing= replies from WAL receiver in WAL sender process." > > > > ABI_compatibility: > > WaitEventClient is about waiting for a socket to become readable or writa= ble, > so I think WAIT_FOR_WAL_* events don't fit in its scope. Sockets are jus= t one > of the ways to be in WAIT_FOR_WAL_*; other delay sources include local fs= ync > and local replay, which could be disk-bound or CPU-bound. > > I think WAIT_FOR_WAL_* belong in WaitEventIPC. In the absence of objecti= ons, > I'll change it that way: Thanks for raising this. It makes sense to me to move these events to the WaitEventIPC session. I'm wondering whether this reasoning also applies to WAIT_FOR_STANDBY_CONFIRMATION. > --- a/src/backend/utils/activity/wait_event_names.txt > +++ b/src/backend/utils/activity/wait_event_names.txt > @@ -91,5 +91,2 @@ SSL_OPEN_SERVER "Waiting for SSL while attempting= connection." > WAIT_FOR_STANDBY_CONFIRMATION "Waiting for WAL to be received and flush= ed by the physical standby." > -WAIT_FOR_WAL_FLUSH "Waiting for WAL flush to reach a target LSN on a= primary or standby." > -WAIT_FOR_WAL_REPLAY "Waiting for WAL replay to reach a target LSN on = a standby." > -WAIT_FOR_WAL_WRITE "Waiting for WAL write to reach a target LSN on a= standby." > WAL_SENDER_WAIT_FOR_WAL "Waiting for WAL to be flushed in WAL sen= der process." > @@ -164,2 +161,5 @@ SAFE_SNAPSHOT "Waiting to obtain a valid snapsh= ot for a READ ONLY DEFER > SYNC_REP "Waiting for confirmation from a remote server during syn= chronous replication." > +WAIT_FOR_WAL_FLUSH "Waiting for WAL flush to reach a target LSN on a= primary or standby." > +WAIT_FOR_WAL_REPLAY "Waiting for WAL replay to reach a target LSN on = a standby." > +WAIT_FOR_WAL_WRITE "Waiting for WAL write to reach a target LSN on a= standby." > WAL_RECEIVER_EXIT "Waiting for the WAL receiver to exit." > > > As further rationale, WaitEventClient says "never used for a background > process". By xlogwait.c sizing its shmem to include NUM_AUXILIARY_PROCS,= it's > reserving the right to accept calls from background processes. As a side= note > related to that, the placement of WaitLSNCleanup() in ProcKill() but not > AuxiliaryProcKill() would also need to change before welcoming auxiliary > process use. Perhaps better than adding to AuxiliaryProcKill(), a separa= te > on_shmem_exit callback for xlogwait.c would make it harder to miss caller= s > needing it. Good catch! Currently, we have no actual background processes to make use of the wait-for facility, but things could change in the upcoming releases. A dedicated on_shmem_exit callback for xlogwait.c also makes sense to me. I'll prepare a patch for that. -- Regards, Xuneng Zhou HighGo Software Co., Ltd.