Remove conservative deletes on restarts #63
Merged
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.
When the daemon restarts, it acts conservatively and deletes the latest entry found in the db, in order to recheck that block. This aims to catch cases where the daemon crashed in the middle of writing in the db. Given that current error handling is not great, this has resulted in cases where the daemon starts crashes and actually starts deleting entries, one by one, ending up in deleting days of data.
This PR proposes to remove this deletion step until we make the daemon very robust, and until we are convinced it is needed. Moreover, it forces the daemon to not look too far back in the past (at most 1 day), and if latest data is older than 1 day, then it ignores the gaps and continues from latest block. In practice, we should not expect downtimes of more than 1 day, so this should be fine in most cases.