Skip to content

KAFKA-8570: Grow buffer to hold down converted records if it was insufficiently sized#7071

Merged
hachikuji merged 2 commits intoapache:1.1from
dhruvilshah3:downconversion-1.1
Jul 12, 2019
Merged

KAFKA-8570: Grow buffer to hold down converted records if it was insufficiently sized#7071
hachikuji merged 2 commits intoapache:1.1from
dhruvilshah3:downconversion-1.1

Conversation

@dhruvilshah3
Copy link
Copy Markdown
Contributor

Backport #6974 to 1.1

When the log contains out of order message formats (for example v2 message followed by v1 message) and consists of compressed batches typically greater than 1kB in size, it is possible for down-conversion to fail. With compressed batches, we estimate the size of down-converted batches using:

    private static int estimateCompressedSizeInBytes(int size, CompressionType compressionType) {
        return compressionType == CompressionType.NONE ? size : Math.min(Math.max(size / 2, 1024), 1 << 16);
    }

This almost always underestimates size of down-converted records if the batch is between 1kB-64kB in size. In general, this means we may under estimate the total size required for compressed batches.

Because of an implicit assumption in the code that messages with a lower message format appear before any with a higher message format, we do not grow the buffer we copy the down converted records into when we see a message <= the target message format. This assumption becomes incorrect when the log contains out of order message formats, for example because of leaders flapping while upgrading the message format.

@hachikuji
Copy link
Copy Markdown
Contributor

retest this please

1 similar comment
@hachikuji
Copy link
Copy Markdown
Contributor

retest this please

@dhruvilshah3
Copy link
Copy Markdown
Contributor Author

Thanks for looking @hachikuji. Looks like we have 2 green builds. The test failure in the JDK 7 build seems unrelated to the changes - I ran the test locally to verify.

Copy link
Copy Markdown
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

Thanks for the backport!

@hachikuji hachikuji merged commit 8c93b7e into apache:1.1 Jul 12, 2019
@dhruvilshah3 dhruvilshah3 deleted the downconversion-1.1 branch July 12, 2019 17:28
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.

2 participants