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

Commitbf08f22

Browse files
Avoid archiving XLOG_RUNNING_XACTS on idle server
If archive_timeout > 0 we should avoid logging XLOG_RUNNING_XACTS if idle.Bug 13685 reported by Laurence Rowe, investigated in detail by Michael Paquier,though this is not his proposed fix.20151016203031.3019.72930@wrigleys.postgresql.orgSimple non-invasive patch to allow later backpatch to 9.4 and 9.5
1 parenta75a418 commitbf08f22

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

‎src/backend/postmaster/bgwriter.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,11 @@ BackgroundWriterMain(void)
330330
if (now >=timeout&&
331331
last_snapshot_lsn!=GetXLogInsertRecPtr())
332332
{
333-
last_snapshot_lsn=LogStandbySnapshot();
333+
XLogRecPtrlog_standby_lsn=LogStandbySnapshot();
334+
334335
last_snapshot_ts=now;
336+
if (!XLogRecPtrIsInvalid(log_standby_lsn))
337+
last_snapshot_lsn=log_standby_lsn;
335338
}
336339
}
337340

‎src/backend/storage/ipc/standby.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ LogStandbySnapshot(void)
902902
RunningTransactionsrunning;
903903
xl_standby_lock*locks;
904904
intnlocks;
905+
staticboollast_snapshot_overflowed= false;
905906

906907
Assert(XLogStandbyInfoActive());
907908

@@ -932,8 +933,28 @@ LogStandbySnapshot(void)
932933
* only a shared lock.
933934
*/
934935
if (wal_level<WAL_LEVEL_LOGICAL)
936+
{
935937
LWLockRelease(ProcArrayLock);
936938

939+
/*
940+
* Don't bother to log anything if nothing is happening, if we are
941+
* using archive_timeout > 0 and we didn't overflow snapshot last time.
942+
*
943+
* This ensures that we don't issue an empty WAL record, which can
944+
* be annoying when used in conjunction with archive timeout.
945+
*/
946+
if (running->xcnt==0&&
947+
nlocks==0&&
948+
XLogArchiveTimeout>0&&
949+
!last_snapshot_overflowed)
950+
{
951+
LWLockRelease(XidGenLock);
952+
returnInvalidXLogRecPtr;
953+
}
954+
955+
last_snapshot_overflowed=running->subxid_overflow;
956+
}
957+
937958
recptr=LogCurrentRunningXacts(running);
938959

939960
/* Release lock if we kept it longer ... */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp