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

[v0.25.3] Failed to deserialize data of EventHeaderV4. Possible fixes included. #363

Open
qidian99 opened this issue Dec 4, 2023 · 0 comments

Comments

@qidian99
Copy link

qidian99 commented Dec 4, 2023

I went over the history issues and discovered some similiar issues. I am using v0.25.3, and the error message was:

Caused by: com.github.shyiko.mysql.binlog.event.deserialization.EventDataDeserializationException: Failed to deserialize data of EventHeaderV4{timestamp=1699588796000, eventType=TABLE_MAP, serverId=1, headerLength=19, dataLength=196, nextPosition=16345945, flags=0}

Unsupported table metadata field type 0.

I debugged the program and grabbed all the bytes of event header:

# remaining bytes:
[1, 5, -74, -39, -101, 97, 0, 3, 32, 33, 33, 63, 33, 63, 63, 63, 63, -4, -1, 0, -4, -1, 0, -4, -1, 0, -4, -1, 0, -4, -1, 0, -4, -1, 0, -4, -1, 0, -4, -1, 0]

nColumns = 59
nNumericColumns = 32

It first read the byte 1 for signedness type, which is 1, and after that the length of signedness bytes, which is 5.

// SIGNEDNESS
1,
5, // should read 5 bytes
-74, -39, -101, 97, 0,

However, the readBooleanList method actually read 4 bytes instead of 5, missing the 0 as in [...74, -39, -101, 97, 0...], causing the exception when the program tries to read the next type.

private static BitSet readBooleanList(ByteArrayInputStream inputStream, int length) throws IOException {
    BitSet result = new BitSet();
    byte[] bytes = inputStream.read(length + 7 >> 3);

    for(int i = 0; i < length; ++i) {
        if ((bytes[i >> 3] & 1 << 7 - i % 8) != 0) {
            result.set(i);
        }
    }

    return result;
}
actually read: 32+7>>3=4 bytes. missed the 0 byte

Possible fixes

Single line fix:

 case SIGNEDNESS:
     result.setSignedness(readBooleanList(inputStream, nNumericColumns));

to

 case SIGNEDNESS:
     result.setSignedness(readBooleanList(inputStream, fieldLength));

or simply call skipToEndOfTheBlock after reading each metadata

qidian99 pushed a commit to qidian99/flink-cdc-connectors-1 that referenced this issue Dec 5, 2023
qidian99 pushed a commit to qidian99/flink-cdc-connectors-1 that referenced this issue Dec 5, 2023
qidian99 pushed a commit to qidian99/flink-cdc-connectors-1 that referenced this issue Dec 5, 2023
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

No branches or pull requests

1 participant