Fix race condition in scan / watch setup #33
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.
I set up a watch by:
To avoid missing data, it's essential that all the scanning is done at the same revision. Otherwise, if the scan requires multiple requests, and some data is written between the two requests, the second request could miss it.
Unfortunately, that's what seemed to be happening.
I was able to track it down by adding a bit more logging of revision numbers: each scan used the following revision, rather than using the same revision! Turns out that I had misinterpreted the meaning of the
revision
field of the response header. The documentation says:Which is terse, but made me think that:
RangeRequest
(ie,revision: 0
) it returns the latest revision.RangeRequest
, it uses that.That's not right. The header
revision
is actually the latest revision at the time the request was answered, and has no relation to the revision specified in the request.So the correct thing to do is, on the very first request, to not supply a revision - and then use the header
revision
returned from that first request for all subsequent requests.Closes #32