Skip to content

Commit c5baa70

Browse files
committed
Ensure unlogged tables are reset even if crash recovery errors out.
Unlogged relations are reset at the end of crash recovery as they're only synced to disk during a proper shutdown. Unfortunately that and later steps can fail, e.g. due to running out of space. This reset was, up to now performed after marking the database as having finished crash recovery successfully. As out of space errors trigger a crash restart that could lead to the situation that not all unlogged relations are reset. Once that happend usage of unlogged relations could yield errors like "could not open file "...": No such file or directory". Luckily clusters that show the problem can be fixed by performing a immediate shutdown, and starting the database again. To fix, just call ResetUnloggedRelations(UNLOGGED_RELATION_INIT) earlier, before marking the database as having successfully recovered. Discussion: 20140912112246.GA4984@alap3.anarazel.de Backpatch to 9.1 where unlogged tables were introduced. Abhijit Menon-Sen and Andres Freund
1 parent 86673a4 commit c5baa70

File tree

1 file changed

+10
-8
lines changed
  • src/backend/access/transam

1 file changed

+10
-8
lines changed

src/backend/access/transam/xlog.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7006,6 +7006,16 @@ StartupXLOG(void)
70067006
*/
70077007
ShutdownWalRcv();
70087008

7009+
/*
7010+
* Reset unlogged relations to the contents of their INIT fork. This is
7011+
* done AFTER recovery is complete so as to include any unlogged relations
7012+
* created during recovery, but BEFORE recovery is marked as having
7013+
* completed successfully. Otherwise we'd not retry if any of the post
7014+
* end-of-recovery steps fail.
7015+
*/
7016+
if (InRecovery)
7017+
ResetUnloggedRelations(UNLOGGED_RELATION_INIT);
7018+
70097019
/*
70107020
* We don't need the latch anymore. It's not strictly necessary to disown
70117021
* it, but let's do it for the sake of tidiness.
@@ -7226,14 +7236,6 @@ StartupXLOG(void)
72267236
*/
72277237
PreallocXlogFiles(EndOfLog);
72287238

7229-
/*
7230-
* Reset initial contents of unlogged relations. This has to be done
7231-
* AFTER recovery is complete so that any unlogged relations created
7232-
* during recovery also get picked up.
7233-
*/
7234-
if (InRecovery)
7235-
ResetUnloggedRelations(UNLOGGED_RELATION_INIT);
7236-
72377239
/*
72387240
* Okay, we're officially UP.
72397241
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy