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

FLINK-36891: MySQL CDC connector produces corrupted state in case of serialization failure #3794

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

morozov
Copy link
Contributor

@morozov morozov commented Dec 11, 2024

Given that the output buffer is reused between calls to serialize(), it should be cleared in a finally block to account for potential exceptions.

final byte[] result = out.getCopyOfBuffer();
// optimization: cache the serialized from, so we avoid the byte work during repeated
// serialization
state.serializedFormCache = result;
Copy link

Choose a reason for hiding this comment

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

assertThrows(IOException.class, () -> serializer.serialize(unsupportedState));

final byte[] ser2 = serializer.serialize(state);
assertEquals(ser1.length, ser2.length);
Copy link

Choose a reason for hiding this comment

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

Is it better to assert that ser1 and ser2 are the same, since there shouldn't be any changes to the state if an error happens based on my understanding.

Copy link
Contributor Author

@morozov morozov Dec 12, 2024

Choose a reason for hiding this comment

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

For some reason, they aren't the same regardless of the fix.

UPD: you're right. They are equal, they just need to be compared as arrays, not objects.

Copy link

@sharonx sharonx left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@leonardBang leonardBang left a comment

Choose a reason for hiding this comment

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

Thanks @morozov for the contribution and @sharonx for the review work, LGTM

@leonardBang leonardBang merged commit b50d172 into apache:master Dec 14, 2024
25 checks passed
@morozov morozov deleted the FLINK-36891 branch December 14, 2024 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants