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

Commit38b38fb

Browse files
committed
pg_stat_replication.sync_state was displayed incorrectly at page boundary.
XLogRecPtrIsInvalid() only checks the xrecoff field, which is correct whenchecking if a WAL record could legally begin at the given position, but WALsending can legally be paused at a page boundary, in which case xrecoff is0. Use XLByteEQ(..., InvalidXLogRecPtr) instead, which checks that bothxlogid and xrecoff are 0.9.3 doesn't have this problem because XLogRecPtr is now a single 64-bitinteger, so XLogRecPtrIsInvalid() does the right thing. Apply to 9.2, and9.1 where pg_stat_replication view was introduced.Kyotaro HORIGUCHI, reviewed by Fujii Masao.
1 parent806e6d1 commit38b38fb

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

‎src/backend/replication/syncrep.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ SyncRepReleaseWaiters(void)
375375
intnumprocs=0;
376376
intpriority=0;
377377
inti;
378+
XLogRecPtrInvalidXLogRecPtr= {0,0};
378379

379380
/*
380381
* If this WALSender is serving a standby that is not on the list of
@@ -384,7 +385,7 @@ SyncRepReleaseWaiters(void)
384385
*/
385386
if (MyWalSnd->sync_standby_priority==0||
386387
MyWalSnd->state<WALSNDSTATE_STREAMING||
387-
XLogRecPtrIsInvalid(MyWalSnd->flush))
388+
XLByteEQ(MyWalSnd->flush,InvalidXLogRecPtr))
388389
return;
389390

390391
/*
@@ -405,7 +406,7 @@ SyncRepReleaseWaiters(void)
405406
walsnd->sync_standby_priority>0&&
406407
(priority==0||
407408
priority>walsnd->sync_standby_priority)&&
408-
!XLogRecPtrIsInvalid(walsnd->flush))
409+
!XLByteEQ(walsnd->flush,InvalidXLogRecPtr))
409410
{
410411
priority=walsnd->sync_standby_priority;
411412
syncWalSnd=walsnd;

‎src/backend/replication/walsender.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,7 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
14031403
intpriority=0;
14041404
intsync_standby=-1;
14051405
inti;
1406+
XLogRecPtrInvalidXLogRecPtr= {0,0};
14061407

14071408
/* check to see if caller supports us returning a tuplestore */
14081409
if (rsinfo==NULL|| !IsA(rsinfo,ReturnSetInfo))
@@ -1448,14 +1449,14 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
14481449
* which always returns an invalid flush location, as an
14491450
* asynchronous standby.
14501451
*/
1451-
sync_priority[i]=XLogRecPtrIsInvalid(walsnd->flush) ?
1452+
sync_priority[i]=XLByteEQ(walsnd->flush,InvalidXLogRecPtr) ?
14521453
0 :walsnd->sync_standby_priority;
14531454

14541455
if (walsnd->state==WALSNDSTATE_STREAMING&&
14551456
walsnd->sync_standby_priority>0&&
14561457
(priority==0||
14571458
priority>walsnd->sync_standby_priority)&&
1458-
!XLogRecPtrIsInvalid(walsnd->flush))
1459+
!XLByteEQ(walsnd->flush,InvalidXLogRecPtr))
14591460
{
14601461
priority=walsnd->sync_standby_priority;
14611462
sync_standby=i;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp