jaeger-client-cpp icon indicating copy to clipboard operation
jaeger-client-cpp copied to clipboard

Client hangs when sending spans to collector directly(without agent) during Jaeger server restart

Open mirage111 opened this issue 6 years ago • 1 comments

Requirement - what kind of business use case are you trying to solve?

Client hangs when sending spans to collector directly(without agent) during Jaeger server restart.

Problem - what in Jaeger blocks you from solving the requirement?

During restart jaeger server, one thread of client hold mutex lock and send span to collector wait so long time:

#0 0x00007f20c7947bfb in send () from /lib64/libpthread.so.0 #1 0x00007f20c66ef8bb in jaegertracing::utils::HTTPTransporter::emitBatch(jaegertracing::thrift::Batch const&) () from /usr/local/lib/libjaegertracing.so.0 #2 0x00007f20c663daa3 in jaegertracing::ThriftSender::flush() () from /usr/local/lib/libjaegertracing.so.0 #3 0x00007f20c6695ce8 in jaegertracing::reporters::RemoteReporter::flush() () from /usr/local/lib/libjaegertracing.so.0 #4 0x00007f20c6695a00 in jaegertracing::reporters::RemoteReporter::sweepQueue() () from /usr/local/lib/libjaegertracing.so.0

while other client threads(working threads) have to wait the lock:

#0 0x00007f20c79474ed in __lll_lock_wait () from /lib64/libpthread.so.0 #1 0x00007f20c7942dcb in _L_lock_883 () from /lib64/libpthread.so.0 #2 0x00007f20c7942c98 in pthread_mutex_lock () from /lib64/libpthread.so.0 #3 0x00007f20c867e70c in pthread_mutex_lock_impl (mutex=0x3295a20) at /home/DEPLOY/shared_dependencies/brpc-master/src/bthread/mutex.cpp:545 #4 pthread_mutex_lock (__mutex=0x3295a20) at /home/DEPLOY/shared_dependencies/brpc-master/src/bthread/mutex.cpp:803 #5 0x00000000005f1284 in __gthread_mutex_lock(pthread_mutex_t*) () #6 0x00000000005f13ae in std::mutex::lock() () #7 0x00007f20c662d541 in std::unique_lockstd::mutex::lock() () from /usr/local/lib/libjaegertracing.so.0 #8 0x00007f20c662ad10 in std::unique_lockstd::mutex::unique_lock(std::mutex&) () from /usr/local/lib/libjaegertracing.so.0 #9 0x00007f20c6695698 in jaegertracing::reporters::RemoteReporter::report(jaegertracing::Span const&) () from /usr/local/lib/libjaegertracing.so.0 #10 0x00007f20c66103ef in jaegertracing::Tracer::reportSpan(jaegertracing::Span const&) const () from /usr/local/lib/libjaegertracing.so.0 #11 0x00007f20c660d4ad in jaegertracing::Span::FinishWithOptions(opentracing::v3::FinishSpanOptions const&) () from /usr/local/lib/libjaegertracing.so.0 #12 0x0000000000531c35 in opentracing::v3::Span::Finish (this=0x7f207c046d20, option_list=...) at /usr/local/include/opentracing/span.h:117

These lead to client hang(working threads wait the lock) about 15 mins

Proposal - what do you suggest to solve the problem or improve the existing situation?

Any open questions to address

mirage111 avatar Sep 14 '20 10:09 mirage111

There maybe two problems here.

  1. The _mutex in RemoteReporter is used control the _queue, but in sweepQueue, sending spans is also done holding lock. This means any network problem may also affect the report function, as the lock cannot be acquired.

During the restart of the collector, the connection between the client and the server would be broken, which would cause problem in sending. The network problem would also affect report.

Releasing the lock before doing network operations can solve the problem. see fefe982@69f23e9 (The change in RemoteReporter.h is not intended)

  1. I didn't find any reconnection code when the HTTP connection is broken. This means after the restart of the collector, the client will not be able to send spans anymore. Maybe I'm not looking carefully enough, can anyone point out when the client would reconnect to the server after connection is broken?

fefe982 avatar Sep 24 '20 08:09 fefe982