Fix sk->ps walsender shutdown on sk side on caughtup.

This will fix many threads issue, but code around awfully still wants
improvement.

https://github.com/neondatabase/neon/issues/2722
This commit is contained in:
Arseny Sher
2022-11-03 08:30:07 +04:00
committed by Arseny Sher
parent d7eeb73f6f
commit 63221e4b42

View File

@@ -555,13 +555,20 @@ impl Timeline {
if self.is_cancelled() {
return true;
}
let mut shared_state = self.write_shared_state();
if shared_state.num_computes == 0 {
let replica_state = shared_state.replicas[replica_id].unwrap();
let reported_remote_consistent_lsn = replica_state
.pageserver_feedback
.map(|f| Lsn(f.ps_applylsn))
.unwrap_or(Lsn::INVALID);
info!(
"checking should ws stop ttid {} lsn {} rcl {}",
self.ttid, reported_remote_consistent_lsn, shared_state.sk.inmem.commit_lsn
);
let stop = shared_state.sk.inmem.commit_lsn == Lsn(0) || // no data at all yet
(replica_state.remote_consistent_lsn != Lsn::MAX && // Lsn::MAX means that we don't know the latest LSN yet.
replica_state.remote_consistent_lsn >= shared_state.sk.inmem.commit_lsn);
(reported_remote_consistent_lsn!= Lsn::MAX && // Lsn::MAX means that we don't know the latest LSN yet.
reported_remote_consistent_lsn >= shared_state.sk.inmem.commit_lsn);
if stop {
shared_state.update_status(self.ttid);
return true;