Skip to content
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

eth, les: wait for the downloads to be complete before stopping #16200

Conversation

mandrigin
Copy link

When stopping a node, and the list of headers to rollback is full (in downloader.go:1160) the database might be closed before the rollback changes are written there.

That causes the crashes like status-im/status-go#652 and might be a source of a potential data loss/corruption.

This PR adds a method to wait for the downloads to be actually processed before proceeding forward and closing the DB.

@mandrigin mandrigin requested a review from karalabe as a code owner February 26, 2018 21:18
@karalabe
Copy link
Member

Hmm, good catch on the issue. Regarding the solution, I'm wondering if we could reuse the already present downloader.Cancel and downloader.Terminate mechanisms to have those properly wait instead of introducing further new methods?

@mandrigin
Copy link
Author

mandrigin commented Feb 27, 2018

@karalabe Yeah, that is a good idea.
Though, downloader.Terminate() is being called from a different goroutine than protocolManager.Stop() (syncer in les/handler.go:224).

I guess I could just move pm.downloader.Terminate() from syncer() to Stop().

Does that sound like a better approach?

UPD: and waiting should be done in downloader.Cancel then, as I understand
UPD2: putting it in downloader.Cancel deadlocks, so I'll put it in Terminate.

@mandrigin mandrigin force-pushed the igorm/wait-for-downloads-when-stopping-node branch from 1f48951 to c7f4965 Compare February 27, 2018 11:05
@mandrigin
Copy link
Author

@karalabe updated the PR. Terminate now blocks until the downloads are finished.

@mandrigin
Copy link
Author

@karalabe is there anything else that needs to be changed in this change?

@mandrigin
Copy link
Author

@karalabe is there anything else needs to be fixed in this review?
we have a patch for that in our code, but I'll be glad to see this fixed upstream too...

@mandrigin
Copy link
Author

mandrigin commented Nov 20, 2018

@karalabe I just wanted to follow-up on this specific PR. It's been a while and we (at Status) still have this patch to keep our CI stable. It would be amazing to get more feedback on it and, if possible, to merge it upstream, so we can have one patch less for LES 😆

@holiman
Copy link
Contributor

holiman commented Aug 1, 2019

This PR touches some fairly "deep" internal stuff, hence why it's taking so long. Someone needs to review it properly, which will take quite some time.
One thing that would help is if you could create a test which reproduces the original bug.

@fjl
Copy link
Contributor

fjl commented Apr 8, 2020

The underlying issue was finally resolved for eth.Ethereum in this recent PR: #20695
Still need to fix it for LES.

@fjl fjl closed this Apr 8, 2020
@fjl
Copy link
Contributor

fjl commented Apr 8, 2020

Closed this now because the PR was quite old and les has changed a lot since it was opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants