pgsql: Avoid using a fake relcache entry to own an SmgrRelation. - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: Avoid using a fake relcache entry to own an SmgrRelation.
Date
Msg-id E1oMUCq-000QeC-9t@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Avoid using a fake relcache entry to own an SmgrRelation.

If an error occurs before we close the fake relcache entry, the the
fake relcache entry will be destroyed by the SmgrRelation will
survive until end of transaction. Its smgr_owner pointer ends up
pointing to already-freed memory.

The original reason for using a fake relcache entry here was to try
to avoid reusing an SMgrRelation across a relevant invalidation. To
avoid that problem, just call smgropen() again each time we need a
reference to it. Hopefully someday we will come up with a more
elegant approach, but accessing uninitialized memory is bad so let's
do this for now.

Dilip Kumar, reviewed by Andres Freund and Tom Lane. Report by
Justin Pryzby.

Discussion: http://postgr.es/m/20220802175043.GA13682@telsasoft.com
Discussion: http://postgr.es/m/CAFiTN-vSFeE6_W9z698XNtFROOA_nSqUXWqLcG0emob_kJ+dEQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/76733b399c490885564a560718de23d98bb5e66d

Modified Files
--------------
src/backend/commands/dbcommands.c   | 15 +++--------
src/backend/storage/buffer/bufmgr.c | 51 +++++++++++++++++--------------------
2 files changed, 28 insertions(+), 38 deletions(-)


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: MERGE docs adjustments
Next
From: Bruce Momjian
Date:
Subject: pgsql: doc: clarify DROP EXTENSION dependent members text