mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-20 15:05:19 +00:00
Terminate file sync if connecting peers too long (#136)
This commit is contained in:
parent
7d73ccd1e1
commit
ae9c52c0e6
@ -126,7 +126,7 @@ impl Batcher {
|
|||||||
Ok(Some(SyncResult::Failed))
|
Ok(Some(SyncResult::Failed))
|
||||||
}
|
}
|
||||||
|
|
||||||
// file sync timeout
|
// finding peers timeout
|
||||||
Some(SyncState::FindingPeers { origin, .. })
|
Some(SyncState::FindingPeers { origin, .. })
|
||||||
if origin.elapsed() > self.config.find_peer_timeout =>
|
if origin.elapsed() > self.config.find_peer_timeout =>
|
||||||
{
|
{
|
||||||
@ -135,6 +135,15 @@ impl Batcher {
|
|||||||
Ok(Some(SyncResult::Timeout))
|
Ok(Some(SyncResult::Timeout))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// connecting peers timeout
|
||||||
|
Some(SyncState::ConnectingPeers { origin, .. })
|
||||||
|
if origin.elapsed() > self.config.find_peer_timeout =>
|
||||||
|
{
|
||||||
|
debug!(%tx_seq, "Terminate file sync due to connecting peers timeout");
|
||||||
|
self.terminate_file_sync(tx_seq, false).await;
|
||||||
|
Ok(Some(SyncResult::Timeout))
|
||||||
|
}
|
||||||
|
|
||||||
// others
|
// others
|
||||||
_ => Ok(None),
|
_ => Ok(None),
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ pub enum SyncState {
|
|||||||
},
|
},
|
||||||
FoundPeers,
|
FoundPeers,
|
||||||
ConnectingPeers {
|
ConnectingPeers {
|
||||||
|
origin: InstantWrapper,
|
||||||
since: InstantWrapper,
|
since: InstantWrapper,
|
||||||
},
|
},
|
||||||
AwaitingOutgoingConnection {
|
AwaitingOutgoingConnection {
|
||||||
@ -253,6 +254,7 @@ impl SerialSyncController {
|
|||||||
info!(%self.tx_seq, %num_peers_dailed, "Connecting peers");
|
info!(%self.tx_seq, %num_peers_dailed, "Connecting peers");
|
||||||
|
|
||||||
self.state = SyncState::ConnectingPeers {
|
self.state = SyncState::ConnectingPeers {
|
||||||
|
origin: self.since,
|
||||||
since: Instant::now().into(),
|
since: Instant::now().into(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -632,6 +634,7 @@ impl SerialSyncController {
|
|||||||
SyncState::FoundPeers => {
|
SyncState::FoundPeers => {
|
||||||
if self.peers.all_shards_available(vec![Connecting, Connected]) {
|
if self.peers.all_shards_available(vec![Connecting, Connected]) {
|
||||||
self.state = SyncState::ConnectingPeers {
|
self.state = SyncState::ConnectingPeers {
|
||||||
|
origin: self.since,
|
||||||
since: Instant::now().into(),
|
since: Instant::now().into(),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user