Skip to content

Commit 85656bc

Browse files
committed
In XLogFileInit(), fix *use_existent postcondition to suit callers.
Infrequently, the mismatch caused log_checkpoints messages and TRACE_POSTGRESQL_CHECKPOINT_DONE() to witness an "added" count too high by one. Since that consequence is so minor, no back-patch. Discussion: https://postgr.es/m/20210202151416.GB3304930@rfd.leadboat.com
1 parent c53c6b9 commit 85656bc

File tree

1 file changed

+6
-7
lines changed
  • src/backend/access/transam

1 file changed

+6
-7
lines changed

src/backend/access/transam/xlog.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3261,8 +3261,8 @@ XLogNeedsFlush(XLogRecPtr record)
32613261
* logsegno: identify segment to be created/opened.
32623262
*
32633263
* *use_existent: if true, OK to use a pre-existing file (else, any
3264-
* pre-existing file will be deleted). On return, true if a pre-existing
3265-
* file was used.
3264+
* pre-existing file will be deleted). On return, false iff this call added
3265+
* some segment on disk.
32663266
*
32673267
* Returns FD of opened file.
32683268
*
@@ -3431,8 +3431,10 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent)
34313431
* CheckPointSegments.
34323432
*/
34333433
max_segno = logsegno + CheckPointSegments;
3434-
if (!InstallXLogFileSegment(&installed_segno, tmppath,
3435-
*use_existent, max_segno))
3434+
if (InstallXLogFileSegment(&installed_segno, tmppath,
3435+
*use_existent, max_segno))
3436+
*use_existent = false;
3437+
else
34363438
{
34373439
/*
34383440
* No need for any more future segments, or InstallXLogFileSegment()
@@ -3442,9 +3444,6 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent)
34423444
unlink(tmppath);
34433445
}
34443446

3445-
/* Set flag to tell caller there was no existent file */
3446-
*use_existent = false;
3447-
34483447
/* Now open original target segment (might not be file I just made) */
34493448
fd = BasicOpenFile(path, O_RDWR | PG_BINARY | get_sync_bit(sync_method));
34503449
if (fd < 0)

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