diff --git a/safekeeper/src/send_wal.rs b/safekeeper/src/send_wal.rs index 4a4a74a0fd..738f4fc3c6 100644 --- a/safekeeper/src/send_wal.rs +++ b/safekeeper/src/send_wal.rs @@ -1019,6 +1019,8 @@ impl ReplyReader { self.ws_guard .walsenders .record_ps_feedback(self.ws_guard.id, &ps_feedback); + // This here is the principal spot that updates remote_consistent_lsn. + // The other spot where it's updated from peers will go away. self.tli .update_remote_consistent_lsn(ps_feedback.remote_consistent_lsn) .await; diff --git a/safekeeper/src/timeline.rs b/safekeeper/src/timeline.rs index 4341f13824..31e5c01674 100644 --- a/safekeeper/src/timeline.rs +++ b/safekeeper/src/timeline.rs @@ -222,11 +222,13 @@ impl StateSK { state.inmem.backup_lsn = max(Lsn(sk_info.backup_lsn), state.inmem.backup_lsn); sync_control_file |= state.backup_lsn + wal_seg_size < state.inmem.backup_lsn; + // This will go away in the new world. state.inmem.remote_consistent_lsn = max( Lsn(sk_info.remote_consistent_lsn), state.inmem.remote_consistent_lsn, ); sync_control_file |= + // WTF is this criteria? state.remote_consistent_lsn + wal_seg_size < state.inmem.remote_consistent_lsn; state.inmem.peer_horizon_lsn = diff --git a/safekeeper/src/timeline_manager.rs b/safekeeper/src/timeline_manager.rs index a33994dcab..60cff771d8 100644 --- a/safekeeper/src/timeline_manager.rs +++ b/safekeeper/src/timeline_manager.rs @@ -503,7 +503,8 @@ impl Manager { ) { let is_active = is_wal_backup_required || num_computes > 0 - || state.remote_consistent_lsn < state.commit_lsn; + // state.remote_consistent_lsn is the inmemo remote consistent lsn + || state.remote_consistent_lsn < state.commit_lsn; // this here changes with the design; // update the broker timeline set if self.tli_broker_active.set(is_active) { @@ -516,7 +517,7 @@ impl Manager { MANAGER_ACTIVE_CHANGES.inc(); } - // update the state in Arc + // update the state in Arc (which is only used for informational APIs) self.tli .broker_active .store(is_active, std::sync::atomic::Ordering::Relaxed);