Fix sync state machine issue for sharding case (#102)

* Fix sync state machine issue for sharding case

* Fix fmt lint
This commit is contained in:
Bo QIU 2024-07-01 16:35:27 +08:00 committed by GitHub
parent 2f3361fafc
commit 055d1fa32d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -561,7 +561,10 @@ impl SerialSyncController {
while !completed { while !completed {
match self.state { match self.state {
SyncState::Idle => { SyncState::Idle => {
if self.peers.count(&[Found, Connecting, Connected]) > 0 { if self
.peers
.all_shards_available(vec![Found, Connecting, Connected])
{
self.state = SyncState::FoundPeers; self.state = SyncState::FoundPeers;
} else { } else {
self.try_find_peers(); self.try_find_peers();
@ -569,7 +572,10 @@ impl SerialSyncController {
} }
SyncState::FindingPeers { since, .. } => { SyncState::FindingPeers { since, .. } => {
if self.peers.count(&[Found, Connecting, Connected]) > 0 { if self
.peers
.all_shards_available(vec![Found, Connecting, Connected])
{
self.state = SyncState::FoundPeers; self.state = SyncState::FoundPeers;
} else { } else {
// storage node may not have the specific file when `FindFile` // storage node may not have the specific file when `FindFile`