Add missing wrlock around rd_kafka_metadata_cache_hint call#5055
Closed
Marcin Krystianc (marcin-krystianc) wants to merge 1 commit intoconfluentinc:masterfrom
Closed
Add missing wrlock around rd_kafka_metadata_cache_hint call#5055Marcin Krystianc (marcin-krystianc) wants to merge 1 commit intoconfluentinc:masterfrom
Marcin Krystianc (marcin-krystianc) wants to merge 1 commit intoconfluentinc:masterfrom
Conversation
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
Contributor
|
Thanks for the fix Marcin Krystianc (@marcin-krystianc) ! Could you rebase/update the PR? |
3f5f281 to
f1e7efa
Compare
Contributor
Author
I've rebased it, feel free to push any other necessary changes or rebase again if needed. |
Marcin Krystianc (marcin-krystianc)
added a commit
to marcin-krystianc/librdkafka
that referenced
this pull request
Apr 29, 2025
- confluentinc#4972 (Avoid unnecessary producer epoch bumps) - confluentinc#4989 (Fully utilize the max.in.flight.requests.per.connection parameter on the idempotent producer) - confluentinc#5055 (Add missing wrlock around rd_kafka_metadata_cache_hint call)
Marcin Krystianc (marcin-krystianc)
added a commit
to marcin-krystianc/librdkafka
that referenced
this pull request
Apr 29, 2025
- confluentinc#4972 (Avoid unnecessary producer epoch bumps) - confluentinc#4989 (Fully utilize the max.in.flight.requests.per.connection parameter on the idempotent producer) - confluentinc#5055 (Add missing wrlock around rd_kafka_metadata_cache_hint call)
Marcin Krystianc (marcin-krystianc)
added a commit
to marcin-krystianc/librdkafka
that referenced
this pull request
Apr 29, 2025
- confluentinc#4972 (Avoid unnecessary producer epoch bumps) - confluentinc#4989 (Fully utilize the max.in.flight.requests.per.connection parameter on the idempotent producer) - confluentinc#5055 (Add missing wrlock around rd_kafka_metadata_cache_hint call)
Marcin Krystianc (marcin-krystianc)
added a commit
to G-Research/librdkafka
that referenced
this pull request
Apr 30, 2025
- confluentinc#4972 (Avoid unnecessary producer epoch bumps) - confluentinc#4989 (Fully utilize the max.in.flight.requests.per.connection parameter on the idempotent producer) - confluentinc#5055 (Add missing wrlock around rd_kafka_metadata_cache_hint call)
Contributor
|
moved to the internal branch in #5066 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5051
This PR addresses a heap-use-after-free error detected by AddressSanitizer within the
rd_kafka_metadata_cache_topics_to_listfunction. The issue was particularly reproducible during tests involving frequent topic deletion and recreation, which heavily exercises the metadata cache logic.The root cause was identified as missing write lock protection when invoking the rd_kafka_metadata_cache_hint. Without proper locking, concurrent threads (e.g., the broker communication thread handling metadata updates and potentially other threads accessing metadata) could race to modify or read the hint, leading to metadata cache corruption. This corruption could manifest as accessing freed memory when iterating through the cache, resulting in the observed heap-use-after-free.
With this change, the previously reported ASan error is resolved when running the test case involving rapid topic recreation.