Bad file descriptor (errno 9) on very high load
Bug Report
This ticket is the continuation of issue #3058. Actually many problems found have been already fixed and the Errno 9 issue still persists.
This new ticket will focus on errno 9 specific issue.
Steps to reproduce it
The issue is only reproducible under very high load (200k records/sec) after running for some hours. To minimize the case the following steps needs to be performed:
-
Checkout branch
1.7.3-3058. This branch is on top of v1.7.3 which to help reproduce the problem, all upstream connection will fail intentionally, this is the easiest way to isolate the problem on removing the network I/O from the test. -
Run Fluent Bit under Valgrind. using Valgrind debugger it helps to highlight the issue after some seconds or a few minutes since it slowdown things.
$ valgrind fluent-bit -c conf
-
Use the following configuration file:
[SERVICE]
flush 0.5
daemon Off
log_level info
log_file /tmp/fluent.log
HTTP_Server On
HTTP_Listen 0.0.0.0
HTTP_PORT 2020
storage.metrics on
storage.path storage
storage.sync normal
storage.checksum off
storage.backlog.mem_limit 10G
storage.max_chunks_up 100
[INPUT]
Name tail
Path test.log
storage.type filesystem
Buffer_Chunk_Size 32000
Buffer_Max_Size 32000
[OUTPUT]
name http
match *
host anything
port 8443
format json_lines
tls on
tls.verify off
workers 20
net.keepalive false
-
Make sure that before every run the
storage/folder is empty and thetest.logfile size is 0. -
Use the log_generator.py.txt script (make sure to change the extension of the file) to write data to
test.logfile like this:
rm log_generator.log
truncate -s 0 test.log
python3 log_generator.py \
--log-size-in-bytes "1000" \
--log-rate "200000" \
--log-agent-input-type "tail" \
--tail-file-path "test.log" \
> log_generator.log
Due to the wrong file descriptor (or looks like a corruption) when doing I/O on the storage layer is common to see a crash like this one:
==50999==
==50999== Process terminating with default action of signal 7 (SIGBUS)
==50999== Non-existent physical address at address 0x20E7C000
==50999== at 0x4C3D29B: memmove (vg_replace_strmem.c:1289)
==50999== by 0x444F2A: cio_file_write (cio_file.c:824)
==50999== by 0x44156A: cio_chunk_write (cio_chunk.c:173)
==50999== by 0x19A332: flb_input_chunk_write (flb_input_chunk.c:68)
==50999== by 0x19BAD1: flb_input_chunk_append_raw (flb_input_chunk.c:836)
==50999== by 0x1B8A0A: process_content (tail_file.c:358)
==50999== by 0x1BA904: flb_tail_file_chunk (tail_file.c:981)
==50999== by 0x1B4C3E: in_tail_collect_event (tail.c:261)
==50999== by 0x1C00B7: tail_fs_event (tail_fs_inotify.c:268)
==50999== by 0x16CBA8: flb_input_collector_fd (flb_input.c:1004)
==50999== by 0x17D2BA: flb_engine_handle_event (flb_engine.c:352)
==50999== by 0x17D2BA: flb_engine_start (flb_engine.c:613)
==50999== by 0x161F06: flb_lib_worker (flb_lib.c:493)
Looks like the memory map or file descriptor has been corrupted so the storage layer fails/crash when copying data
cc: @agup006 @qingling128 @hsmatulisgoogle
cc @JeffLuoo
folks! (+ cc: @igorpeshansky)
you were right! looks like finally issue is gone, this fix the problem:
diff --git a/src/flb_scheduler.c b/src/flb_scheduler.c
index b24582de..1244afc8 100644
--- a/src/flb_scheduler.c
+++ b/src/flb_scheduler.c
@@ -336,11 +336,6 @@ int flb_sched_request_destroy(struct flb_sched_request *req)
*/
flb_sched_timer_invalidate(timer);
-#ifndef FLB_SYSTEM_WINDOWS
- /* Close pipe after invalidating timer */
- flb_pipe_close(req->fd);
-#endif
-
/* Remove request */
flb_free(req);
the sched request context fd is a mapping of timer->timer_fd, but that is already handled so the double close generate the problem on high concurrency
@hsmatulisgoogle
would you please re-test the branch fix-3058 that has the fix in place ?
Testing...
related issue: https://github.com/fluent/fluent-bit/issues/2933
Fixed by 272a609
We will continue troubleshooting the backpressure issue in a different ticket.
I got pretty similar exception on the latest 1.7.5 on Amazon Linux. The exception occurs also only on very high load and is easier reproducible with multiple inputs and outputs. https://github.com/fluent/fluent-bit/issues/3412
I got pretty similar exception on the latest 1.7.5 on Amazon Linux. The exception occurs also only on very high load and is easier reproducible with multiple inputs and outputs. #3412
Hey @jevgenimarenkov would you be able to create a new ticket with the exception and info?
Edit: Sorry, I missed the link to #3412, is this issue a new one with the same bad file descriptor (errno 9)?
I got pretty similar exception on the latest 1.7.5 on Amazon Linux. The exception occurs also only on very high load and is easier reproducible with multiple inputs and outputs. #3412
Hey @jevgenimarenkov would you be able to create a new ticket with the exception and info?
Edit: Sorry, I missed the link to #3412, is this issue a new one with the same bad file descriptor (errno 9)?
That is related to #3412