Review
Report no unpinned buffers as insufficient resources
- Base commit
- 26a3c0a45cc6017ee7f334c0ef63292d5e101b58
Summary
Changes the "no unpinned buffers available" failure in StrategyGetBuffer() from elog(ERROR) to ereport() with ERRCODE_INSUFFICIENT_RESOURCES (SQLSTATE 53000).
Assessment
The motivation is clear. All shared buffers being pinned is resource exhaustion, not an internal error, yet clients get XX000. The local-buffer path ("no empty local buffer available") already uses ERRCODE_INSUFFICIENT_RESOURCES, so this removes an inconsistency. ereport() also makes the message translatable.
The patch is minimal and correct as written. The message text is unchanged, so nothing that matches on it is affected. I reviewed the diff only and did not build or run it. Other reviewers report the SQLSTATE changing from XX000 to 53000 with passing tests.
Open points
- Fujii Masao (2026-10-15) suggests naming "shared" in the message, e.g. "could not find an unpinned shared buffer", and changing the local-buffer message to match. Reasonable, since the two messages are otherwise easy to confuse. It touches a second translatable string, so the author should decide whether to fold it in.
- Matthias van de Meent: if an errhint is added, the local-buffer path should get the same. Pin leaks, many connections, or bad plans can also cause this, so a shared_buffers hint could mislead. Omitting a hint is fine.
- No regression test. Reaching the error needs a tiny shared_buffers and many pins, which is hard to do reliably. Acceptable.
Verdict
Ready apart from the wording question above.