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 1w31Ww-000pEV-22 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 00:46:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w31Wv-00FfPL-1d for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 00:46:29 +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 1w31Wv-00FfPC-0a for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 00:46:29 +0000 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w31Ws-000000012Ic-2SLZ for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 00:46:28 +0000 Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-509101189edso3678321cf.3 for ; Wed, 18 Mar 2026 17:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773881185; cv=none; d=google.com; s=arc-20240605; b=koDTM/LdqVxeNmlJMc8vUXemgtpk2qHsVzPVN5UXcF8TviaZcEbi1W2O0mqBDQx47h huo5FC3BnBY8XDcX8PoUcBonUQo3NbFMjFBms0SXRMqtxvWdYpUACdz8CGnwzrmSd9to RMXpg+Iya7BcTzWW/dnQ7TESt2IyxJhIN2JUGEIDCiIQusKVng2fGsJsZDeNomL3byEn 96+wfBQplqd4c5ChUXm+R8D2kuy4EMC2CP9A1avS0sONVjbbj2QfdcUDGsrqCia7hplR jcY/xnGK621qk7h+u/Ih6I8BoEHXG459RLvDjN0NqeohJ63voGS2bZBRvWDBLzkGIwUt 5ZxQ== 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=2ZMnX6Pa6Bs/E+17l7AeWuNeOFIm6/vA5DSP0Cls7f0=; fh=CNUNDb1I8j3h1u2DuuD7qLNc9uzHc/3XEHNfEjsmV6A=; b=c2Bjr+Ll4Tw+KPHF1IMlSo74Bdp2Gtsr4sDjA36hK6tYuvgAzkcBBQHvRlxk5d485N HubJSW8WObJNw/bPm9chSrfdVOyovOdb6LZTfCOzm2jMcxz5aTAP8ee98hY3+ExbqM9T BgdSfFlQxXkQw4xozCp3j1vE8rRDBte3b8m5wq0ewv81BqrjnQc0HkDTCevNSggjvbN+ UXUo/INsDIhM54SOSVGYIXvrhtQYhAdRSbjcDU8YWcONnG9VaEX2j7L3xM6Xc7f9VzE2 meHEVUNeD0cWilpPLOClFLq2FqBK9QbIRfMFbLkdXgWqGRyZNRCXgxszkzcf9ieCeWsB fLcg==; 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=fittl.com; s=google; t=1773881185; x=1774485985; 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=2ZMnX6Pa6Bs/E+17l7AeWuNeOFIm6/vA5DSP0Cls7f0=; b=TlpnXs8rkhPIURQGbobFaPuoHmoELTAVURk9lZt2uOl1ENhF0EuPLxPG1MWLqQ8RhY YPz5Vun0kCkL8UaNslq9GRWnoEam2dAtxxcUF7wSlrBwmuEXxGm7/rRr+aEBgoD/7daS 7ExOq6V9eaPqGgfpHtfBMyAqL/OSRrRSy6T8I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773881185; x=1774485985; 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=2ZMnX6Pa6Bs/E+17l7AeWuNeOFIm6/vA5DSP0Cls7f0=; b=aCpnGbkPBSrtLjGjRjnvoakBB1vhoJHIwBAIlsQj7K3MIyGAF+TJ4CTz4/y1K6DXoD r/nlYsW54Ko10lUsJP3A9PijqD2FM7IJBwkcPlePX0as9a6mYmqwyuiRxsLwgx3zmdM6 BMwGOvujfasHhlhMfMNP3puKBT8voesXh9mMTPtdJlX16u5iwvedRy9C+agrjBxkj84/ 6sJDWuwqzcyVqOsF1TjIFIzxj0eFme5sOwOxzp9vXutLHvy2Txb0dKDN8R5TTlWCK3jG rxgi9V30F5KyGR2E0fgSC1+O548qvP4IGIF47Qc/PrV3UA4doa4GcAGZOWr/J9BANpeq yDQg== X-Forwarded-Encrypted: i=1; AJvYcCWgf62qO1B2X26ibDAv7PA7bCSuxiNHnEHtu7vSrrWCeD/U+jObucBLeYfZnfMgmcTSqLt587ixfbwvHY2K@lists.postgresql.org X-Gm-Message-State: AOJu0YyKWlLDqBMN12KcCwlZ4mk9o74Jz+COXh+xA8Z+HlkSfFV2FwQ6 tgQIdyICDSB9AkE6Mvnz0UHjKHrc5eACp9z7PUchvtMZSwvRSORhB0DMNLhRBm95DFcx9fMRo1J P7psSZnUS7VfyfKnBumEbT8Ej5xJ99RhJ4+HpkhT6 X-Gm-Gg: ATEYQzx3MG9mnrkp0scSw5MGSYLJV8Su11pXEDoFLJtGF2YOfYgz6lyyU8Bhmc5dSm+ QwmsmsZNz0xGg5saEmb93GoKS5u6puSLVOBNKL1vQOs46R5yWBpxvHEytApZgANbbaILH9jnvXH KqCvsCbEKPXsEhh3sphDYws7CjDWB7bF52f3dq4sHetXAZMFYYK3Xr5qfGUuJShhu+/4hkhsvXb CKO5oQ3U9G7TztirBVez3eIoMlJlTRmeH9aTHBd4YIjUFFNod8RkwUk+zVFCa8B+GkIF1QnQVm4 ftVrN5q7bEZVem8aZrDGQFJt7rwjtQUUbk7WJKbrQndCaYyp+X0WlJc1Vcj07bWTNmGUuVMP X-Received: by 2002:ac8:7fcf:0:b0:509:4b11:6d02 with SMTP id d75a77b69052e-50b14742dd2mr70935211cf.7.1773881185432; Wed, 18 Mar 2026 17:46:25 -0700 (PDT) MIME-Version: 1.0 References: <06086cb4-881b-4f5a-96af-f275220ff52d@vondra.me> In-Reply-To: From: Lukas Fittl Date: Wed, 18 Mar 2026 17:45:49 -0700 X-Gm-Features: AaiRm51THswdb0V8C6lVMzXAu9U9QM2x3k2whltZ7N4Bp45Q6IXaGWXT-hDWZ4w Message-ID: Subject: Re: Stack-based tracking of per-node WAL/buffer usage To: Zsolt Parragi Cc: Tomas Vondra , PostgreSQL Hackers , Andres Freund , Peter Smith 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 Wed, Mar 18, 2026 at 4:36=E2=80=AFPM Lukas Fittl wrote= : > On Wed, Mar 18, 2026 at 1:49=E2=80=AFPM Zsolt Parragi wrote: > > There seems to be one more bug in this: > > > > 1. EXPLAIN ANALYZE fires a trigger > > 2. The trigger function throws ERROR, InstrStopTrigger never runs > > 3. ResOwnerReleaseInstrumentation runs but only checks > > unfinalized_children, not triggers > > 4. InstrStopFinalize discards the trigger entry > > 5. Trigger instrumentation information shows 0 > > Hmm, so I think you're correct that a trigger function error would > cause any stack-based instrumentation from the trigger to get lost. > > In practice that doesn't matter today, since triggers never capture > WAL/buffer usage data (only timing), After twisting and turning this in my head more, I realize that's actually not correct - as it stands, trigger instrumentation is inheriting the instrumentation options from the overall query, and so that will cause a typical EXPLAIN (ANALYZE) to also capture Buffer/WAL usage for triggers - it just won't be shown in EXPLAIN. Since its not used in practice, we could fix that by explicitly setting INSTRUMENT_TIMER for triggers, but AFAIR Andres had noted on a prior iteration that special casing this doesn't seem right, since we should probably output buffer/WAL usage for triggers anyway. So I guess that brings us back to, we should fix it with one of the ways I mentioned. FWIW, I was able to create a test case in the pg_session_buffer_usage module to that effect, so there is indeed a current issue where activity during triggers gets lost and won't be added to the overall totals on abort. Thanks, Lukas --=20 Lukas Fittl