-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
RdKafka::Message blocking the RdKafka:KafkaConsumer.close #775
Comments
This is exactly what librdkafka also tries to avoid. There doesnt seem to be a quick fix for this on either side (librdkafka or V8). |
Just to give a little insight into how the C++ bindings for
I verified that the free callback is getting called and it still appears to hang when it's in the process of disconnecting. Part of the issue is v8's scoping - the buffer could be attached to a scope that is still active when someone calls Any advice on how we can avoid this problem? I can't just deallocate memory that is in |
Instead of having In your close() wrapper you make a copy of the |
I could implement that if I was sure it would fix the issue. I'll take a look and see. |
@webmakersteve, any luck with this? |
@ottomata Haven't had time to write up some tests to ensure this would fix the issue. Am hoping to get to it soon. |
Just tried to make a test case for my own sanity to make sure this was the issue. I made it so the underlying Is there any other way to debug why this is happening? I can verify that this only happens after a successful read from Kafka. After it happens this is what debug is telling me, if it helps at all:
It never gets passed that last logged entry. |
Do you if you get that final rebalance callback with err==PARTITIONS_REVOKED? Are you closing the client with rd_kafka_consumer_close()? |
Just for reference I believe I ran into another manifestation of this problem while using I just wanted to include this test case as a specific reproduction in case it helps to find a way to track down the apparent awkwardness around the https://gist.github.com/petermelias/17f276f4bdc73eafa6c3741697f62d71 This test will show the process hanging indefinitely despite the |
Description
The bug manifests itself in Blizzard/node-rdkafka#5
In my (pretty limited) understanding, here's what's happening. The node driver wrapping the
RdKafka::Message
into the V8 object and passes it to JavaScript. So now the memory is managed by JS GC, so we don't have control over when the JS object is going to be destroyed, thus no control when the nativeRdKafka::Message
is going to be destroyed.As I understand, internally,
RdKafka::Message
holds a reference to the consumer it was consumed by, so until all the messages are deleted, the consumer disconnect never finishes - the background thread is stuck onpoll
call until ref_count reaches 0 and it happens only after a very significant delay because node.js GC might not be called.So, the question is why does the still existing message need to hold disconnecting the consumer and why does the message need a reference to the original consumer?
It's possible to fix it in the driver, but that would require one unnecessary
memcpy
of the message payload which would be wonderful to avoid.How to reproduce
Consume a message, don't delete the message, try to disconnect the consumer - it hangs.
I can post backtraces or create some small reproducible test case if you think that's an issue in
librdkafka
.Checklist
Please provide the following information:
debug=..
as necessary) from librdkafkaThe text was updated successfully, but these errors were encountered: