pgsql: Fix bug in bulk extending temp relation after failure - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: Fix bug in bulk extending temp relation after failure
Date
Msg-id E1rVzH7-004OC5-8N@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix bug in bulk extending temp relation after failure

A ResourceOwnerEnlarge() call was missing. That led to an error:

ERROR:  ResourceOwnerRemember called but array was full

and an assertion failure, if you tried to extend a temp relation again
after a failure. Alexander's test case used running out of disk space
to trigger the original failure.

This bug was introduced in the large ResourceOwner rewrite commit
b8bff07daa. Before that, the UnpinLocalBuffer() call guaranteed that
the subsequent PinLocalBuffer() will succeed, but after the rewrite,
releasing an old resource doesn't guarantee that there is space for a
new one.

Add a comment explaining why the UnpinBuffer + PinBuffer calls in
BufferAlloc(), with no ResourceOwnerEnlarge() in between, are safe.

Reported-by: Alexander Lakhin
Discussion: https://www.postgresql.org/message-id/dc574fea-c83e-a600-08cd-10881762e4fa@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d212957254de85aad934e2601e5a07661db268fb

Modified Files
--------------
src/backend/storage/buffer/localbuf.c | 5 +++++
src/backend/utils/resowner/resowner.c | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: First-draft release notes for 16.2.
Next
From: Tom Lane
Date:
Subject: pgsql: Translate ENOMEM to ERRCODE_OUT_OF_MEMORY in errcode_for_file_ac