Application doesn't finish gracefully after client.disconnect
See original GitHub issueI expect that after a producer/consumer is disconnected it should destroy all RdKafka objects and let the application exit, however it doesn’t happen.
Code example:
const Kafka = require('node-rdkafka');
const producer = new Kafka.Producer({
'metadata.broker.list': 'localhost:9092'
});
producer.connect(undefined, () => {
producer.produce({
topic: 'test_dc.resource_change',
message: 'test'
}, () => {
producer.disconnect(() => {
console.log('Disconnected');
});
});
});
Versions: kafkaOS X El Capitan Expected behaviour: application sends one message to the topic and shuts down. Actual behaviour: application sends one message to the topic but continues running.
A bit of investigation: gdb
shows that we have 8 threads running after disconnect
was called:
Id Target Id Frame
* 1 Thread 0x1203 of process 55925 0x00007fff8f611eca in kevent () from /usr/lib/system/libsystem_kernel.dylib
2 Thread 0x1303 of process 55925 0x00007fff8f60afae in semaphore_wait_trap () from /usr/lib/system/libsystem_kernel.dylib
3 Thread 0x1403 of process 55925 0x00007fff8f60afae in semaphore_wait_trap () from /usr/lib/system/libsystem_kernel.dylib
4 Thread 0x1503 of process 55925 0x00007fff8f60afae in semaphore_wait_trap () from /usr/lib/system/libsystem_kernel.dylib
5 Thread 0x1603 of process 55925 0x00007fff8f60afae in semaphore_wait_trap () from /usr/lib/system/libsystem_kernel.dylib
6 Thread 0x1703 of process 55925 0x00007fff8f610db6 in __psynch_cvwait () from /usr/lib/system/libsystem_kernel.dylib
7 Thread 0x1803 of process 55925 0x00007fff8f61107a in select$DARWIN_EXTSN () from /usr/lib/system/libsystem_kernel.dylib
8 Thread 0x1903 of process 55925 0x00007fff8f61107a in select$DARWIN_EXTSN () from /usr/lib/system/libsystem_kernel.dylib
Threads 1-5 are normal, so whatever prevents shutdown is in threads 6-8, I suspect it’s on thread 6, here’s the backtrace:
#0 0x00007fff8f610db6 in __psynch_cvwait () from /usr/lib/system/libsystem_kernel.dylib
#1 0x00007fff9cd3f728 in _pthread_cond_wait () from /usr/lib/system/libsystem_pthread.dylib
#2 0x000000010079630b in uv_cond_wait ()
#3 0x000000010078a2ab in worker ()
#4 0x0000000100796000 in uv.thread_start ()
#5 0x00007fff9cd3e99d in _pthread_body () from /usr/lib/system/libsystem_pthread.dylib
#6 0x00007fff9cd3e91a in _pthread_start () from /usr/lib/system/libsystem_pthread.dylib
#7 0x00007fff9cd3c351 in thread_start () from /usr/lib/system/libsystem_pthread.dylib
#8 0x0000000000000000 in ?? ()
Any ideas where could the source of a problem be?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:22 (6 by maintainers)
Top Results From Across the Web
c++ - How can a client gracefully detect when a server ...
I am working on a client-server application. The client continuously reads data from server, so when a server is closed or disconnects then...
Read more >How to set Remote desktop session host to close an ... - TechNet
To curb this problem we end IDLE and disconnected sessions. ... close the application gracefully before ending the remote desktop session?
Read more >4.7. The Mysteries of Connection Close - HTTP
The HTTP specification counsels that when clients or servers want to close a connection unexpectedly, they should “issue a graceful close on the...
Read more >Can an Asynchronous appserver procedure run to completion ...
If the client has disconnected from the AppServer it's not guaranteed that a running asynchronous request will complete. Requests that have a ...
Read more >Detecting client disconnections in the server side
This is a chat application, so when a user disconnects you want to tell everybody else in the room that somebody left. That's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Been doing some testing. I can reproduce this issue in version 0.3.3. Using master, with #42 merged, my process finishes properly after calling
disconnect()
.So! Looking good to me!
I’ve created https://github.com/edenhill/librdkafka/issues/775 to understand what does Magnus think about this problem.