Ensure sane filestore behaviour for edge cases #185
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.
This change was prompted by a comment on another PR.
So, why shouldn't filestore part
storeoperation idempotent? I consider storing the same part again a special case of overlapping parts which was already an error case. We could theoretically allow overlapping parts as long as they are consistent with each other but that significantly complicates the implementation and probably introduces a thousand different edge cases that I prefer not to deal with. We don't need idempotence because GRR flows are single-threaded and Fleetspeak guarantees message delivery so if the same part is sent twice it is a bug in the flow implementation and should be fixed server-side.This PR also disallows empty parts to be written. The reason here is to keep the behaviour consistent again: if we allocate an empty part at the given offset, it is not possible to store any non-overlapping part at this offset anymore. One could argue that an empty part is never overlapping with anything and from purely theoretical standpoint I agree with that. We could just drop empty parts.
But then again: why would a server ever send an empty part? That sounds like a wasted roundtrip and I think it is better to fail hard to notify the server that something is most likely not right.