-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancel sync properly on shutdown #4380
Conversation
Not sure about this, how much time docker gives the application to gracefully terminate before it terminates it hard? I know its configurable but there is some default. I think default is 10s: https://docs.docker.com/engine/reference/commandline/stop/ |
What happens if not all data is flushed? How much time is needed on average to flush data? Which feed is the most problematic? |
1d39214
to
6b7180f
Compare
|
Nevermind, seems to have already been accounted for. |
6b7180f
to
0077cbb
Compare
0077cbb
to
a84437b
Compare
a84437b
to
6ee5d18
Compare
src/Nethermind/Nethermind.Synchronization/FastBlocks/FastHeadersSyncFeed.cs
Show resolved
Hide resolved
src/Nethermind/Nethermind.Synchronization/ParallelSync/SyncDispatcher.cs
Show resolved
Hide resolved
@@ -113,6 +106,11 @@ public async Task Start(CancellationToken cancellationToken) | |||
if (Logger.IsWarn) Logger.Warn($"Failure when executing request {t.Exception}"); | |||
} | |||
|
|||
if (cancellationToken.IsCancellationRequested) | |||
{ | |||
if (Logger.IsInfo) Logger.Info("Ignoring sync response as shutdown is requested."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be Debug/Trace?
if (cancellationToken.IsCancellationRequested) | ||
{ | ||
if (Logger.IsDebug) Logger.Debug("Ignoring sync response as shutdown is requested."); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this inside the below try to still have call to Free(allocation)
. It probably won't matter for shutdown but potentially if we have other places where we would like to cancel the sync - yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixing
Fixes | Closes | Resolves #4049
Fast headers sync requires heavy database writes on request preparation which was not interruptible before this fix
Changes:
Types of changes
What types of changes does your code introduce?
Put an
x
in the boxes that applyTesting
Requires testing
In case you checked yes, did you write tests??