From 4b2b4078ecb549871f19c52bac66365016d13a34 Mon Sep 17 00:00:00 2001 From: Xueting-Ma Date: Fri, 18 Sep 2026 15:56:40 +0900 Subject: [PATCH v2] Report unpinned buffer errors as insufficient resources Use an appropriate SQLSTATE for shared buffer exhaustion. Clarify which buffer type each error concerns, and make the shared- and local-buffer messages consistent. --- src/backend/storage/buffer/freelist.c | 4 +++- src/backend/storage/buffer/localbuf.c | 2 +- src/test/regress/expected/temp.out | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index fdb5bad7910..53910f952f2 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -271,7 +271,9 @@ StrategyGetBuffer(BufferAccessStrategy strategy, uint64 *buf_state, bool *from_r * one eventually, but it's probably better to fail than * to risk getting stuck in an infinite loop. */ - elog(ERROR, "no unpinned buffers available"); + ereport(ERROR, + errcode(ERRCODE_INSUFFICIENT_RESOURCES), + errmsg("could not find an unpinned shared buffer")); } break; } diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c index 4870c8e13d0..dd5351552d1 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -271,7 +271,7 @@ GetLocalVictimBuffer(void) else if (--trycounter == 0) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_RESOURCES), - errmsg("no empty local buffer available"))); + errmsg("could not find an unpinned local buffer"))); } /* diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/temp.out index a50c7ae88a9..1f64b7e6316 100644 --- a/src/test/regress/expected/temp.out +++ b/src/test/regress/expected/temp.out @@ -456,7 +456,7 @@ SELECT test_temp_pin(0, 9); -- should fail, too many buffers pinned SELECT test_temp_pin(10, 105); -ERROR: no empty local buffer available +ERROR: could not find an unpinned local buffer ROLLBACK; BEGIN; -- have some working cursors to test after errors @@ -475,7 +475,7 @@ FETCH NEXT FROM c_3; -- exhaust buffer pins in subtrans, check things work after SAVEPOINT rescue_me; SELECT test_temp_pin(10, 105); -ERROR: no empty local buffer available +ERROR: could not find an unpinned local buffer ROLLBACK TO SAVEPOINT rescue_me; -- pre-subtrans cursors continue to work FETCH NEXT FROM c_3; -- 2.43.0