-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change consumer to read metadata in blob header for version number #650
base: master
Are you sure you want to change the base?
Conversation
long expectedToVersion = transition.getToVersion(); | ||
Long actualToVersion = null; | ||
String actualToVersionStr = stateEngine.getHeaderTag(HEADER_TAG_PRODUCER_TO_VERSION); | ||
if (actualToVersionStr != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can collapse the two if blocks that are checking the same condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not apply anymore
|
||
if (actualToVersion != null) { | ||
if (actualToVersion.longValue() != expectedToVersion) { | ||
LOG.warning("toVersion in blob didn't match toVersion seen in metadata; actualToVersion=" + actualToVersion + ", expectedToVersion=" + expectedToVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the terms blob and metadata dont apply in the context of this class as we want them to, we can rephrase the msg to something like
toVersion encoded in incoming blob header did not match toVersion requested in transition; the one from blob header will be assumed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not apply anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed offline, there may be some side effects from updating the toVersion in one place (with the consumer) but continuing to use the bad toVersion later (for e.g. signaling to listeners).
5e4cb58
to
3df6e33
Compare
e7b81cb
to
d4493aa
Compare
private final long actualVersion; | ||
|
||
public VersionMismatchException(long expectedVersion, long actualVersion) { | ||
super("toVersion in blob didn't match toVersion seen in metadata; actualToVersion=" + actualVersion + ", expectedToVersion=" + expectedVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: metadata doesn't really mean apply in this context, we can drop it from the error msg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change to "did not match toVersion requested in transition"
@@ -261,6 +267,59 @@ private static void addActor(HollowWriteStateEngine stateEngine, int id) { | |||
stateEngine.add("Actor", rec); | |||
} | |||
|
|||
@Test | |||
public void testReadBlobVersionInitialInconsistent() throws IOException { | |||
testReadBlobVersion(2, 3, 1, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: (as discussed) can we add some asserts corresponding to versions that the consumer transitioned to
HollowBlobHeader header = headerReader.readHeader(in); | ||
if (expectedVersion != 0 && !isInitialUpdate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(as discussed), maybe better approach to parse headers in HollowDataHolder before applying delta, so that we dont have to pass isInitialUpdate and expectedVersion context all the way down here
d4493aa
to
4810852
Compare
4810852
to
f3a6b1e
Compare
When the consumer apply a delta transition, it will check the blob version in blob metadata. If this is a transition happen during the app start up, keep the existing behavior, otherwise, throw an exception when there is a mismatch of blob metadata to version and delta to version.