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-0006lY-Tu@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_2_STABLE

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

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     |    5 ++++-
src/backend/utils/cache/relcache.c |   25 +++++++++++++++++++++----
src/include/utils/rel.h            |   17 ++++++-----------
7 files changed, 64 insertions(+), 24 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix filling of postmaster.pid in bootstrap/standalone mode.
Next
From: Tom Lane
Date:
Subject: pgsql: Fix failure to ignore leftover temp tables after a server crash.