diff options
author | Robert Haas <rhaas@postgresql.org> | 2021-11-05 12:50:01 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2021-11-05 12:50:01 -0400 |
commit | e997a0c642860a96df0151cbeccfecbdf0450d08 (patch) | |
tree | c869dbcbe3a67ddc6a7c2ad5cd0029bc1af0c233 /src/include | |
parent | caf1f675b88d1aa67ea3fb642e8f38b470cc911e (diff) | |
download | postgresql-e997a0c642860a96df0151cbeccfecbdf0450d08.tar.gz postgresql-e997a0c642860a96df0151cbeccfecbdf0450d08.zip |
Remove all use of ThisTimeLineID global variable outside of xlog.c
All such code deals with this global variable in one of three ways.
Sometimes the same functions use it in more than one of these ways
at the same time.
First, sometimes it's an implicit argument to one or more functions
being called in xlog.c or elsewhere, and must be set to the
appropriate value before calling those functions lest they
misbehave. In those cases, it is now passed as an explicit argument
instead.
Second, sometimes it's used to obtain the current timeline after
the end of recovery, i.e. the timeline to which WAL is being
written and flushed. Such code now calls GetWALInsertionTimeLine()
or relies on the new out parameter added to GetFlushRecPtr().
Third, sometimes it's used during recovery to store the current
replay timeline. That can change, so such code must generally
update the value before each use. It can still do that, but must
now use a local variable instead.
The net effect of these changes is to reduce by a fair amount the
amount of code that is directly accessing this global variable.
That's good, because history has shown that we don't always think
clearly about which timeline ID it's supposed to contain at any
given point in time, or indeed, whether it has been or needs to
be initialized at any given point in the code.
Patch by me, reviewed and tested by Michael Paquier, Amul Sul, and
Álvaro Herrera.
Discussion: https://postgr.es/m/CA+TgmobfAAqhfWa1kaFBBFvX+5CjM=7TE=n4r4Q1o2bjbGYBpA@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/xlog.h | 9 | ||||
-rw-r--r-- | src/include/access/xlogarchive.h | 2 | ||||
-rw-r--r-- | src/include/access/xlogutils.h | 4 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index c0a560204b4..f188c41bedf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -29,8 +29,6 @@ #define SYNC_METHOD_OPEN_DSYNC 4 /* for O_DSYNC */ extern int sync_method; -extern PGDLLIMPORT TimeLineID ThisTimeLineID; /* current TLI */ - /* * Recovery target type. * Only set during a Point in Time recovery, not when in standby mode. @@ -262,7 +260,7 @@ extern XLogRecPtr XLogInsertRecord(struct XLogRecData *rdata, extern void XLogFlush(XLogRecPtr RecPtr); extern bool XLogBackgroundFlush(void); extern bool XLogNeedsFlush(XLogRecPtr RecPtr); -extern int XLogFileInit(XLogSegNo segno); +extern int XLogFileInit(XLogSegNo segno, TimeLineID tli); extern int XLogFileOpen(XLogSegNo segno); extern void CheckXLogRemoved(XLogSegNo segno, TimeLineID tli); @@ -274,7 +272,7 @@ extern void xlog_redo(XLogReaderState *record); extern void xlog_desc(StringInfo buf, XLogReaderState *record); extern const char *xlog_identify(uint8 info); -extern void issue_xlog_fsync(int fd, XLogSegNo segno); +extern void issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli); extern bool RecoveryInProgress(void); extern RecoveryState GetRecoveryState(void); @@ -312,7 +310,8 @@ extern void UpdateFullPageWrites(void); extern void GetFullPageWriteInfo(XLogRecPtr *RedoRecPtr_p, bool *doPageWrites_p); extern XLogRecPtr GetRedoRecPtr(void); extern XLogRecPtr GetInsertRecPtr(void); -extern XLogRecPtr GetFlushRecPtr(void); +extern XLogRecPtr GetFlushRecPtr(TimeLineID *insertTLI); +extern TimeLineID GetWALInsertionTimeLine(void); extern XLogRecPtr GetLastImportantRecPtr(void); extern void RemovePromoteSignalFiles(void); diff --git a/src/include/access/xlogarchive.h b/src/include/access/xlogarchive.h index 3edd1a976c1..7dcf1bd2dd2 100644 --- a/src/include/access/xlogarchive.h +++ b/src/include/access/xlogarchive.h @@ -24,7 +24,7 @@ extern void ExecuteRecoveryCommand(const char *command, const char *commandName, bool failOnSignal); extern void KeepFileRestoredFromArchive(const char *path, const char *xlogfname); extern void XLogArchiveNotify(const char *xlog); -extern void XLogArchiveNotifySeg(XLogSegNo segno); +extern void XLogArchiveNotifySeg(XLogSegNo segno, TimeLineID tli); extern void XLogArchiveForceDone(const char *xlog); extern bool XLogArchiveCheckDone(const char *xlog); extern bool XLogArchiveIsBusy(const char *xlog); diff --git a/src/include/access/xlogutils.h b/src/include/access/xlogutils.h index a5cb3d322c5..eebc91f3a50 100644 --- a/src/include/access/xlogutils.h +++ b/src/include/access/xlogutils.h @@ -98,7 +98,9 @@ extern void wal_segment_open(XLogReaderState *state, extern void wal_segment_close(XLogReaderState *state); extern void XLogReadDetermineTimeline(XLogReaderState *state, - XLogRecPtr wantPage, uint32 wantLength); + XLogRecPtr wantPage, + uint32 wantLength, + TimeLineID currTLI); extern void WALReadRaiseError(WALReadError *errinfo); |