Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
What does this PR do? Why is it needed?
Fixes the issue where --clear-db in Windows leads to an error quoted in #7401 :
This is in the validator, beacon-chain, as well as the slasher.
This is because on Linux, you can indeed os.Remove a file in use without the OS complaining-- this unlinks it from the containing directory but since a process has it open, the actual data on disk will remain until the process ends. At the time the process exits, if there is no other reference to that data, it'll be moved to the chopping block. On Windows, you cannot delete a file in use. In master, the clearing DB code calls a function to delete the .db file and then soon afterwards, creates a new DB [file] which will indeed persist after the process ends. But before it does the delete, it has a database with that file to-be-deleted DB file still open.
Example in the beacon-chain:
Which issues(s) does this PR fix?
Fixes #7401
Other notes for review