Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

workeatsleep
Copy link
Contributor

@workeatsleep workeatsleep commented Nov 16, 2023

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.

long expectedToVersion = transition.getToVersion();
Long actualToVersion = null;
String actualToVersionStr = stateEngine.getHeaderTag(HEADER_TAG_PRODUCER_TO_VERSION);
if (actualToVersionStr != null) {
Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

@Sunjeet Sunjeet Nov 17, 2023

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not apply anymore

Copy link
Contributor

@Sunjeet Sunjeet left a 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).

@Sunjeet Sunjeet requested a review from davesu November 21, 2023 00:36
@workeatsleep workeatsleep force-pushed the consumer-read-metadata-blob-version branch from 5e4cb58 to 3df6e33 Compare November 30, 2023 05:42
@workeatsleep workeatsleep force-pushed the consumer-read-metadata-blob-version branch 2 times, most recently from e7b81cb to d4493aa Compare March 6, 2024 20:00
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);
Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

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) {
Copy link
Contributor

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

@workeatsleep workeatsleep force-pushed the consumer-read-metadata-blob-version branch from d4493aa to 4810852 Compare March 21, 2024 21:10
@workeatsleep workeatsleep force-pushed the consumer-read-metadata-blob-version branch from 4810852 to f3a6b1e Compare March 27, 2024 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants