| From: | Rucha Kulkarni <rirukool(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Backend goes in infinite loop when a GUC_REPORT value can’t be converted to client_encoding |
| Date: | 2026-11-26 20:27:14 |
| Message-ID: | CAPsneqrNPWd8gQyip+=v7AO2wizN5TC=hsUzm5WxDxyep5X0+w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi PostgreSQL Community,
Any authenticated, unprivileged user can put a backend into an infinite
retry loop with two commands:
SET client_encoding = 'LATIN1';
SET search_path = U&"\20AC"; -- a euro sign, which has no equivalent in
LATIN1
Reproduction:
postgres=# SET client_encoding = 'LATIN1';
SET
postgres=# SET search_path = U&"\20AC";
SET
ERROR: character with byte sequence 0xe2 0x82 0xac in encoding "UTF8" has
no equivalent in encoding "LATIN1"
ERROR: character with byte sequence 0xe2 0x82 0xac in encoding "UTF8" has
no equivalent in encoding "LATIN1"
ERROR: character with byte sequence 0xe2 0x82 0xac in encoding "UTF8" has
no equivalent in encoding "LATIN1"
[... repeats forever; no prompt returns ...]
It never comes back to a prompt, and the backend keeps running in the
background regardless, taking up CPU and writing to the server log nonstop,
which can eventually fill up the disk.
This happens because search_path became GUC_REPORT in PG 18 (commit
<https://github.com/postgres/postgres/commit/28a1121fd91235e09793c9ce64cb5539719afa30>).
ReportChangedGUCOptions() only clears GUC_NEEDS_REPORT and removes the
entry from guc_report_list after calling ReportGUCOption(). When the value
can’t be converted to the client’s encoding, that call throws, skipping the
cleanup, so the entry stays pending and gets retried every ReadyForQuery
cycle, forever. The backend never reaches ReadyForQuery or reads from the
client, so it outlives a disconnect and logs unboundedly. Confirmed on
master and PG 18.7.
Attached is a patch that fixes the retry loop and downgrades the encoding
failure to a WARNING instead of an ERROR, since the SET itself had already
succeeded.
Thanks,
Rucha Kulkarni
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Avoid-infinite-retry-loop-when-a-GUC_REPORT-value.patch | application/octet-stream | 8.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2026-11-26 20:58:21 | Re: Fix assert failure in composite type dependency check for index expr |
| Previous Message | Antonin Houska | 2026-11-26 20:16:46 | Re: Allow progress tracking of sub-commands |