Re: Enhancing Memory Context Statistics Reporting

From: Rahila Syed <rahilasyed90(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Enhancing Memory Context Statistics Reporting
Date: 2026-01-09 11:22:25
Message-ID: CAH2L28vqKDTogugPnr54hY8k6enP02U_qMBUtnmo7CbA6OfhHQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

>> *Error Reported in Thread [2]*: This issue has been fixed by switching
>> to a NULL resource owner before attaching
>> to DSM in the CFI handler.
>>
>>
> This error mentioned in thread [2] is triggered during CFI() call from
> secure_read() when a
> backend is waiting for commands and it has an open transaction which is
> going to abort
>
> Below are some details about this fix.
>
> It is safe to temporarily set the resource owner to NULL before attaching
> to the DSA
> and DSHASH, since these segments are intended to be attached for the full
> session
> and are detached only when the session ends.
> We also restore the original resource owner immediately after the attach
> completes.
>
>
After further discussion and reviewing Robert's email[1] on this topic, a
safer solution
is to avoid running ProcessGetMemoryContextInterrupt during an aborted
transaction.
This should help prevent additional errors when the transaction is already
in error handling
state. Also, reporting memory context statistics from an aborting
transaction won't
be very useful as some of that memory usage won't be valid after abort
completes.
Attached is the updated patch that addresses this.

> Other possible fixes include:
> 1.Adjusting resource‑owner behavior
> Either allow resource‑owner enlargement during release, or delay marking
> it as releasing until
> the abort actually begins.
>

Sorry, this point is invalid as resource-owner is already being marked as
releasing from
AbortTransaction.

Thank you,
Rahila Syed

[1].
https://www.postgresql.org/message-id/CA%2BTgmoapJ6erjT21uPO12wTtoOmj6w-dp6T3qySN%2BNSc1cdEKw%40mail.gmail.com

>

Attachment Content-Type Size
v47-0002-Test-module-to-test-memory-context-reporting-wit.patch application/octet-stream 8.8 KB
v47-0001-Add-function-to-report-memory-context-statistics.patch application/octet-stream 57.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-01-09 11:26:40 Re: Use IsA() macro instead of nodeTag comparison
Previous Message Dilip Kumar 2026-01-09 11:18:52 Re: Proposal: Conflict log history table for Logical Replication