Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73d14cf

Browse files
authored
Merge branch 'postgres:master' into master
2 parents ab5bdd2 + 7195c80 commit 73d14cf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/backend/replication/slot.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,7 @@ void
20792079
CheckPointReplicationSlots(bool is_shutdown)
20802080
{
20812081
int i;
2082+
bool last_saved_restart_lsn_updated = false;
20822083

20832084
elog(DEBUG1, "performing replication slot checkpoint");
20842085

@@ -2123,15 +2124,23 @@ CheckPointReplicationSlots(bool is_shutdown)
21232124
SpinLockRelease(&s->mutex);
21242125
}
21252126

2127+
/*
2128+
* Track if we're going to update slot's last_saved_restart_lsn. We
2129+
* need this to know if we need to recompute the required LSN.
2130+
*/
2131+
if (s->last_saved_restart_lsn != s->data.restart_lsn)
2132+
last_saved_restart_lsn_updated = true;
2133+
21262134
SaveSlotToPath(s, path, LOG);
21272135
}
21282136
LWLockRelease(ReplicationSlotAllocationLock);
21292137

21302138
/*
2131-
* Recompute the required LSN as SaveSlotToPath() updated
2132-
* last_saved_restart_lsn for slots.
2139+
* Recompute the required LSN if SaveSlotToPath() updated
2140+
* last_saved_restart_lsn for any slot.
21332141
*/
2134-
ReplicationSlotsComputeRequiredLSN();
2142+
if (last_saved_restart_lsn_updated)
2143+
ReplicationSlotsComputeRequiredLSN();
21352144
}
21362145

21372146
/*

0 commit comments

Comments
 (0)