Limit length of queryies in pg_stat_statement extension

From: 赵庭海(庭章) <zhaotinghai(dot)zth(at)alibaba-inc(dot)com>
To: "pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Limit length of queryies in pg_stat_statement extension
Date: 2025-01-16 02:19:49
Message-ID: 9750ddc4-7864-424c-8d26-c52b702a0d99.zhaotinghai.zth@alibaba-inc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,
Recently, I have noticed a potential problem in the pg_stat_statements extension.
When the garbage collection is triggered within this extension, if there is a significant
amount of data to be written to the pgss_query_texts.stat file (for example, when
tracking very long SQL queries), the corresponding backend process holds the pgss->lock
for an extended period. This causes all other backend processes to wait for this
lock in the extension's hook during all SQL executions, and these processes do not
respond to interrupts during this time.
To temporarily address this issue, I have written a patch that introduces a parameter
to control the maximum length of tracked SQL queries.
It seems like this is not an ideal solution, at least, I think it is necessary to
log messages at the log level before and after the garbage collection process.
This would help us diagnose similar issues in the future.I spent a considerable
amount of time investigating this issue due to the lack of relevant logs.
I believe adding these logs would be beneficial for troubleshooting.
Thanks for your attention to this issue.
Best regards,
Zhao

Attachment Content-Type Size
0001-limit-length-of-queries.patch application/octet-stream 5.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2025-01-16 02:47:32 Re: Issue with markers in isolation tester? Or not?
Previous Message Melanie Plageman 2025-01-16 01:45:15 Re: Confine vacuum skip logic to lazy_scan_skip