Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6c44ee

Browse files
committed
Fix off-by-one possibly leading to skipped XLOG_RUNNING_XACTS records.
Since6ef2eba ("Skip checkpoints, archiving on idle systems."),GetLastImportantRecPtr() is used to avoid performing superfluouscheckpoints, xlog switches, running-xact records when the system isidle. Unfortunately the check concerning running-xact records had aoff-by-one error, leading to such records being potentially skippedwhen only a single record has been inserted since the lastrunning-xact record.An alternative approach would have been to changeGetLastImportantRecPtr()'s definition to point to the end of records,but that would make the checkpoint code more complicated.Author: Andres FreundDiscussion:https://postgr.es/m/20170505012447.wsrympaxnfis6ojt@alap3.anarazel.deBackpatch: no, code only present in master
1 parent334b82c commite6c44ee

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

‎src/backend/postmaster/bgwriter.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,13 @@ BackgroundWriterMain(void)
325325

326326
/*
327327
* Only log if enough time has passed and interesting records have
328-
* been inserted since the last snapshot.
328+
* been inserted since the last snapshot. Have to compare with <=
329+
* instead of < because GetLastImportantRecPtr() points at the
330+
* start of a record, whereas last_snapshot_lsn points just past
331+
* the end of the record.
329332
*/
330333
if (now >=timeout&&
331-
last_snapshot_lsn<GetLastImportantRecPtr())
334+
last_snapshot_lsn <=GetLastImportantRecPtr())
332335
{
333336
last_snapshot_lsn=LogStandbySnapshot();
334337
last_snapshot_ts=now;

‎src/backend/postmaster/checkpointer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ CheckArchiveTimeout(void)
611611
{
612612
/*
613613
* Switch segment only when "important" WAL has been logged since the
614-
* last segment switch.
614+
* last segment switch (last_switch_lsn points to end of segment
615+
* switch occurred in).
615616
*/
616617
if (GetLastImportantRecPtr()>last_switch_lsn)
617618
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp