File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -2079,6 +2079,7 @@ void
2079
2079
CheckPointReplicationSlots (bool is_shutdown )
2080
2080
{
2081
2081
int i ;
2082
+ bool last_saved_restart_lsn_updated = false;
2082
2083
2083
2084
elog (DEBUG1 , "performing replication slot checkpoint" );
2084
2085
@@ -2123,15 +2124,23 @@ CheckPointReplicationSlots(bool is_shutdown)
2123
2124
SpinLockRelease (& s -> mutex );
2124
2125
}
2125
2126
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
+
2126
2134
SaveSlotToPath (s , path , LOG );
2127
2135
}
2128
2136
LWLockRelease (ReplicationSlotAllocationLock );
2129
2137
2130
2138
/*
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 .
2133
2141
*/
2134
- ReplicationSlotsComputeRequiredLSN ();
2142
+ if (last_saved_restart_lsn_updated )
2143
+ ReplicationSlotsComputeRequiredLSN ();
2135
2144
}
2136
2145
2137
2146
/*
You can’t perform that action at this time.
0 commit comments