pgsql: Fix failure to ignore leftover temp tables after a server crash. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix failure to ignore leftover temp tables after a server crash.
Date
Msg-id E1Tklmx-0006lZ-UN@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix failure to ignore leftover temp tables after a server crash.

During crash recovery, we remove disk files belonging to temporary tables,
but the system catalog entries for such tables are intentionally not
cleaned up right away.  Instead, the first backend that uses a temp schema
is expected to clean out any leftover objects therein.  This approach
requires that we be careful to ignore leftover temp tables (since any
actual access attempt would fail), *even if their BackendId matches our
session*, if we have not yet established use of the session's corresponding
temp schema.  That worked fine in the past, but was broken by commit
debcec7dc31a992703911a9953e299c8d730c778 which incorrectly removed the
rd_islocaltemp relcache flag.  Put it back, and undo various changes
that substituted tests like "rel->rd_backend == MyBackendId" for use
of a state-aware flag.  Per trouble report from Heikki Linnakangas.

Back-patch to 9.1 where the erroneous change was made.  In the back
branches, be careful to add rd_islocaltemp in a spot in the struct that
was alignment padding before, so as not to break existing add-on code.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/ed98b48bf437ae8f8a9dfa53b1f8b9bb235cb089

Modified Files
--------------
src/backend/catalog/toasting.c     |    2 +-
src/backend/commands/copy.c        |    2 +-
src/backend/commands/sequence.c    |    4 ++--
src/backend/commands/tablecmds.c   |   33 +++++++++++++++++++++++++++++----
src/backend/utils/adt/dbsize.c     |    3 +++
src/backend/utils/cache/relcache.c |   25 +++++++++++++++++++++----
src/include/utils/rel.h            |   17 ++++++-----------
7 files changed, 63 insertions(+), 23 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix failure to ignore leftover temp tables after a server crash.
Next
From: Peter Eisentraut
Date:
Subject: pgsql: doc: Put PL/pgSQL RAISE USING keywords into a list