Skip to content

Commit e67ad99

Browse files
committed
More graceful shutdown logs (#9177)
More graceful shutdown
1 parent 177889d commit e67ad99

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/Nethermind/Nethermind.Merge.Plugin/Synchronization/PeerRefresher.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class PeerRefresher : IPeerRefresher, IAsyncDisposable
2828
private (Hash256 headBlockhash, Hash256 headParentBlockhash, Hash256 finalizedBlockhash) _lastBlockhashes = (Keccak.Zero, Keccak.Zero, Keccak.Zero);
2929
private readonly ITimer _refreshTimer;
3030
private readonly ILogger _logger;
31+
private bool _disposed;
3132

3233
public PeerRefresher(IPeerDifficultyRefreshPool syncPeerPool, ITimerFactory timerFactory, ILogManager logManager)
3334
{
@@ -40,6 +41,7 @@ public PeerRefresher(IPeerDifficultyRefreshPool syncPeerPool, ITimerFactory time
4041

4142
public void RefreshPeers(Hash256 headBlockhash, Hash256 headParentBlockhash, Hash256 finalizedBlockhash)
4243
{
44+
if (_disposed) return;
4345
_lastBlockhashes = (headBlockhash, headParentBlockhash, finalizedBlockhash);
4446
TimeSpan timePassed = DateTime.UtcNow - _lastRefresh;
4547
if (timePassed > _minRefreshDelay)
@@ -79,6 +81,10 @@ Hash256 finalizedBlockhash
7981
{
8082
await RefreshPeerForFcu(syncPeer, headBlockhash, headParentBlockhash, finalizedBlockhash, delaySource.Token);
8183
}
84+
catch (OperationCanceledException)
85+
{
86+
if (_logger.IsDebug) _logger.Debug($"Peer refresh timed out.");
87+
}
8288
catch (Exception exception)
8389
{
8490
if (_logger.IsError) _logger.Error($"Exception in peer refresh. This is unexpected. {syncPeer}", exception);
@@ -199,7 +205,11 @@ private static bool TryGetHeadAndParent(Hash256 headBlockhash, Hash256 headParen
199205

200206
public ValueTask DisposeAsync()
201207
{
202-
_refreshTimer.Dispose();
208+
if (!_disposed)
209+
{
210+
_disposed = true;
211+
_refreshTimer.Dispose();
212+
}
203213
return default;
204214
}
205215
}

src/Nethermind/Nethermind.State/VerifyTrieStarter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public bool TryStartVerifyTrie(BlockHeader stateAtBlock)
4343
}
4444
catch (OperationCanceledException)
4545
{
46-
if (_logger.IsError) _logger.Error($"Verify trie cancelled");
46+
if (_logger.IsInfo) _logger.Info($"Verify trie cancelled");
4747
}
4848
catch (Exception e)
4949
{

src/Nethermind/Nethermind.Synchronization/SnapSync/SnapSyncDownloader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public async Task Dispatch(PeerInfo peerInfo, SnapSyncBatch batch, CancellationT
4646
batch.AccountsToRefreshResponse = await handler.GetTrieNodes(batch.AccountsToRefreshRequest, cancellationToken);
4747
}
4848
}
49+
catch (OperationCanceledException)
50+
{
51+
if (Logger.IsDebug) Logger.Debug($"Snap sync request cancelled. Request: {batch}");
52+
}
4953
catch (Exception e)
5054
{
5155
if (Logger.IsDebug)

0 commit comments

Comments
 (0)