Background data clearing #284
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.
The issue
The main replication loop periodically checks whether there are new replication jobs that should be started, old ones to be stopped, or data to be cleared.
The issue is that the data clearing was a "blocking" operation, and would prevent the loop from running again until it completed. In most cases it's fine - the actual replication jobs would already be running, and continue fine in the background.
However, there is an edge case: If a replication job was not immediately due to a competing sync rules lock, but the clearing was started, then the replication job would not be retried until the clearing has completed. This could result in significant replication lag building up.
The fix
This removes the blocking behavior of the clearing jobs, resolving the issue.