diff options
-rw-r--r-- | src/backend/postmaster/bgwriter.c | 7 | ||||
-rw-r--r-- | src/backend/postmaster/checkpointer.c | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index dcb4cf249c5..48efe15e825 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -325,10 +325,13 @@ BackgroundWriterMain(void) /* * Only log if enough time has passed and interesting records have - * been inserted since the last snapshot. + * been inserted since the last snapshot. Have to compare with <= + * instead of < because GetLastImportantRecPtr() points at the + * start of a record, whereas last_snapshot_lsn points just past + * the end of the record. */ if (now >= timeout && - last_snapshot_lsn < GetLastImportantRecPtr()) + last_snapshot_lsn <= GetLastImportantRecPtr()) { last_snapshot_lsn = LogStandbySnapshot(); last_snapshot_ts = now; diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c index fe9041f748c..d12db0d5a7b 100644 --- a/src/backend/postmaster/checkpointer.c +++ b/src/backend/postmaster/checkpointer.c @@ -611,7 +611,8 @@ CheckArchiveTimeout(void) { /* * Switch segment only when "important" WAL has been logged since the - * last segment switch. + * last segment switch (last_switch_lsn points to end of segment + * switch occurred in). */ if (GetLastImportantRecPtr() > last_switch_lsn) { |