-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
I encounter the thread created by fluentbit exist all the time even invoking flb_stop(ctx), flb_destory(ctx).
I was wondering how to exit the thread related to fluentbit properly. Please help me on this
Issue : an orphan thread created by fluentbit exist all the time.
Version: fluent-bit-0.12.16
OS: CentOS 7
-----------following is the source code -------------------
#include <fluent-bit.h>
#define JSON_1 "[1449505010, {"key1": "some value"}]"
#define JSON_2 "[1449505620, {"key1": "some new value"}]"
int main()
{
int ret;
int in_ffd;
int out_ffd;
flb_ctx_t *ctx;
/* Create library context */
ctx = flb_create();
in_ffd = flb_input(ctx, "lib", NULL);
flb_input_set(ctx, in_ffd, NULL);
out_ffd = flb_output(ctx, "stdout", NULL);
/* Start the engine */
ret = flb_start(ctx);
/* Ingest data manually */
flb_lib_push(ctx, in_ffd, JSON_1, sizeof(JSON_1) - 1);
flb_lib_push(ctx, in_ffd, JSON_2, sizeof(JSON_2) - 1);
sleep(5);
/* Stop the engine (5 seconds to flush remaining data) */
flb_stop(ctx);
flb_destroy(ctx);
return 0;
}
-----------Debug output----------------
40 ret = flb_start(ctx);
[New Thread 0x7ffff6c61700 (LWP 30677)]
[New Thread 0x7ffff6460700 (LWP 30678)]
(gdb) i thread
Id Target Id Frame
3 Thread 0x7ffff6460700 (LWP 30678) "a.out" 0x00007ffff7683701 in clone () from /lib64/libc.so.6
2 Thread 0x7ffff6c61700 (LWP 30677) "a.out" 0x00007ffff6c6d6d5 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
- 1 Thread 0x7ffff7fdb740 (LWP 30564) "a.out" main () at fluentbit.c:41
(gdb) n
47 flb_lib_push(ctx, in_ffd, JSON_1, sizeof(JSON_1) - 1);
(gdb) n
[1449505010, {"key1": "some value"}]48 flb_lib_push(ctx, in_ffd, JSON_2, sizeof(JSON_2) - 1);
(gdb) n
[1449505620, {"key1": "some new value"}][New Thread 0x7ffff5c5f700 (LWP 30928)]
[2018/06/01 14:22:17] [ info] [engine] started
(gdb) i thread
Id Target Id Frame
4 Thread 0x7ffff5c5f700 (LWP 30928) "a.out" 0x00007ffff7683d13 in epoll_wait () from /lib64/libc.so.6
3 Thread 0x7ffff6460700 (LWP 30678) "a.out" 0x00007ffff7683d13 in epoll_wait () from /lib64/libc.so.6
2 Thread 0x7ffff6c61700 (LWP 30677) "a.out" 0x00007ffff7683d13 in epoll_wait () from /lib64/libc.so.6 - 1 Thread 0x7ffff7fdb740 (LWP 30564) "a.out" main () at fluentbit.c:50
(gdb) n
53 flb_stop(ctx);
(gdb) n
[2018/06/01 14:22:46] [ info] [input] pausing lib.0
[2018/06/01 14:22:46] [ warn] [engine] service will stop in 5 seconds
[2018/06/01 14:22:50] [ info] [engine] service stopped
[Thread 0x7ffff5c5f700 (LWP 30928) exited]
[Thread 0x7ffff6c61700 (LWP 30677) exited]
(gdb) i thread
Id Target Id Frame
3 Thread 0x7ffff6460700 (LWP 30678) "a.out" 0x00007ffff7683d13 in epoll_wait () from /lib64/libc.so.6
- 1 Thread 0x7ffff7fdb740 (LWP 30564) "a.out" main () at fluentbit.c:57
(gdb) t 3
[Switching to thread 3 (Thread 0x7ffff6460700 (LWP 30678))]
#0 0x00007ffff7683d13 in epoll_wait () from /lib64/libc.so.6
[call stack of orphan fluentbit thread ]
(gdb) bt
#0 0x00007ffff7683d13 in epoll_wait () from /lib64/libc.so.6
#1 0x00007ffff7998ead in _mk_event_wait () from /lib/libfluent-bit.so
#2 0x00007ffff7999197 in mk_event_wait () from /lib/libfluent-bit.so
#3 0x00007ffff797c4f4 in log_worker_collector () from /lib/libfluent-bit.so
#4 0x00007ffff79900b7 in step_callback () from /lib/libfluent-bit.so
#5 0x00007ffff6c69dc5 in start_thread () from /lib64/libpthread.so.0
#6 0x00007ffff768373d in clone () from /lib64/libc.so.6