fluent-bit icon indicating copy to clipboard operation
fluent-bit copied to clipboard

[ Error] epoll_ctl: File exists, errno=17 at lib/monkey/mk_core/mk_event_epoll.c:136

Open kantica opened this issue 7 years ago • 1 comments

Bug Report

Describe the bug Using tail + stackdriver plugin I get "File exists" from epoll_ctl(), used inside _mk_event_add(). It seems already registered file descriptor in epoll gets (re)used. Therefore log entries tailed by that task will not be written / pushed to stackdriver. Debug output:

Fluent Bit v1.2.0
Copyright (C) Treasure Data

[2019/06/12 10:08:30] [debug] [storage] [cio stream] new stream registered: tail.0
[2019/06/12 10:08:30] [ info] [storage] initializing...
[2019/06/12 10:08:30] [ info] [storage] in-memory
[2019/06/12 10:08:30] [ info] [storage] normal synchronization mode, checksum disabled
[2019/06/12 10:08:30] [ info] [engine] started (pid=26510)
[2019/06/12 10:08:30] [debug] [engine] coroutine stack size: 24576 bytes (24.0K)
[2019/06/12 10:08:30] [debug] [in_tail] inotify watch fd=19
[2019/06/12 10:08:30] [debug] [in_tail] scanning path /var/log/containers/*.log
[2019/06/12 10:08:30] [debug] [in_tail] add to scan queue /var/log/containers/test.log, offset=0
[2019/06/12 10:08:30] [debug] [in_tail] add to scan queue /var/log/containers/test1.log, offset=0
[2019/06/12 10:08:30] [debug] [out_stackdriver] JWT signature:
XXXXXXXXXXXXXXXXXXXX
[2019/06/12 10:08:30] [ info] [oauth2] HTTP Status=200
[2019/06/12 10:08:30] [debug] [oauth2] payload:
{
  "access_token": "XXXX",
  "expires_in": 3600,
  "token_type": "Bearer"
}
[2019/06/12 10:08:30] [ info] [oauth2] access token from 'www.googleapis.com:443' retrieved
[2019/06/12 10:08:30] [debug] [router] match rule tail.0:stackdriver.0
[2019/06/12 10:08:30] [ info] [sp] stream processor started
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test.log read=32767 lines=248
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test1.log read=32767 lines=173
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test.log read=32705 lines=249
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test1.log read=32745 lines=173
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test.log read=32707 lines=249
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test1.log read=32638 lines=173
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test.log read=32644 lines=250
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test1.log read=32597 lines=174
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test.log read=473 lines=4
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test1.log read=32700 lines=173
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test.log promote to TAIL_EVENT
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test1.log read=32741 lines=173
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test1.log read=1648 lines=9
[2019/06/12 10:08:30] [debug] [in_tail] file=/var/log/containers/test1.log promote to TAIL_EVENT
[2019/06/12 10:08:30] [debug] [task] created task=0x7f20c8e400c0 id=0 OK
[2019/06/12 10:08:30] [debug] [task] created task=0x7f20c8e40180 id=1 OK
[2019/06/12 10:08:31] [  Error] epoll_ctl: File exists, errno=17 at /root/fluent-bit/lib/monkey/mk_core/mk_event_epoll.c:136
[2019/06/12 10:08:31] [error] [io_tls] error changing mask to 4
[2019/06/12 10:08:31] [debug] [out_stackdriver] HTTP Status=200
[2019/06/12 10:08:31] [debug] [task] destroy task=0x7f20c8e400c0 (task_id=0)
^C[engine] caught signal (SIGINT)
[2019/06/12 10:09:14] [ info] [input] pausing tail.0
[2019/06/12 10:09:14] [debug] [task] destroy task=0x7f20c8e40180 (task_id=1)

To Reproduce To reproduce this bug please use config and logs from following gist: https://gist.github.com/kantica/952cd056cd2bdddd45aed6b95bc6aa60

I did test this against latest master (514f097c5b2be27117f7dff0465a807fa2f3a696) compiled with:

cmake -DFLB_DEBUG=Off -DFLB_TRACE=Off -DFLB_JEMALLOC=On -DFLB_BUFFERING=On -DFLB_TLS=On -DFLB_SHARED_LIB=Off -DFLB_EXAMPLES=Off -DFLB_HTTP_SERVER=On -DFLB_IN_SYSTEMD=On -DFLB_OUT_KAFKA=On ..
  • Steps to reproduce the problem: Use configs from gist, save log files inside /var/log/containers/ and then run fluent-bit. The logs should already be inside log folder before starting fluent-bit.

Expected behavior Expected successful log write into stackdriver.

Your Environment

  • Version used: master and latest release (1.1.2)
  • Environment name and version: tested inside docker (18.09.6) container and inside kubernetes env v1.13.5 with docker v18.09.3
  • Operating System and version: Ubuntu 18.04.2 LTS and Debian stretch 9.9
  • Filters and plugins: tail, kubernetes, stackdriver

Additional context Firstly I ran into another bug, running fluent-bit inside kubernetes, which returns: [ Error] epoll_ctl: Bad file descriptor, errno=9

I started investigating, because some logs don't get written into stackdriver. Running inside docker container (not kubernetes) I could not reliably reproduce [ Error] epoll_ctl: Bad file descriptor, errno=9. It was intermittent and somehow dependent on rate with which logs get written.

BUT I managed to reproduce "epoll_ctl: File exists, errno=17". I could also send lldb/gdb backtraces, register info, stack/frame info if needed.

kantica avatar Jun 12 '19 11:06 kantica

Fixed by:

  • a1518bf6
  • 39650cce

edsiper avatar Jun 13 '19 22:06 edsiper