summaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-12-20 15:00:41 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-12-20 15:00:41 -0500
commita63a7a5b091f8b833169476e8de18100fb1cb73d (patch)
treeb20cbd133d894d84b14ba7b345e5fda5fd476205 /src/backend/access
parentbb4cfebd64cb43b9002e6a748dd8d2a2eed8204b (diff)
downloadpostgresql-a63a7a5b091f8b833169476e8de18100fb1cb73d.tar.gz
Avoid crashing when we have problems unlinking files post-commit.
smgrdounlink takes care to not throw an ERROR if it fails to unlink something, but that caution was rendered useless by commit 3396000684b41e7e9467d1abc67152b39e697035, which put an smgrexists call in front of it; smgrexists *does* throw error if anything looks funny, such as getting a permissions error from trying to open the file. If that happens post-commit, you get a PANIC, and what's worse the same logic appears in the WAL replay code, so the database even fails to restart. Restore the intended behavior by removing the smgrexists call --- it isn't accomplishing anything that we can't do better by adjusting mdunlink's ideas of whether it ought to warn about ENOENT or not. Per report from Joseph Shraibman of unrecoverable crash after trying to drop a table whose FSM fork had somehow gotten chmod'd to 000 permissions. Backpatch to 8.4, where the bogus coding was introduced.
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/transam/twophase.c3
-rw-r--r--src/backend/access/transam/xact.c14
2 files changed, 5 insertions, 12 deletions
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 54176ee9df..6d496b5804 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -1343,8 +1343,7 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
for (fork = 0; fork <= MAX_FORKNUM; fork++)
{
- if (smgrexists(srel, fork))
- smgrdounlink(srel, fork, false);
+ smgrdounlink(srel, fork, false);
}
smgrclose(srel);
}
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 2ca1c14549..7bdf38636b 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -4532,11 +4532,8 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn)
for (fork = 0; fork <= MAX_FORKNUM; fork++)
{
- if (smgrexists(srel, fork))
- {
- XLogDropRelation(xlrec->xnodes[i], fork);
- smgrdounlink(srel, fork, true);
- }
+ XLogDropRelation(xlrec->xnodes[i], fork);
+ smgrdounlink(srel, fork, true);
}
smgrclose(srel);
}
@@ -4637,11 +4634,8 @@ xact_redo_abort(xl_xact_abort *xlrec, TransactionId xid)
for (fork = 0; fork <= MAX_FORKNUM; fork++)
{
- if (smgrexists(srel, fork))
- {
- XLogDropRelation(xlrec->xnodes[i], fork);
- smgrdounlink(srel, fork, true);
- }
+ XLogDropRelation(xlrec->xnodes[i], fork);
+ smgrdounlink(srel, fork, true);
}
smgrclose(srel);
}