-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SecondaryFileOutput
has race condition issues in multiple threads or workers
#4080
Comments
daipom
changed the title
Mar 3, 2023
SecondaryFileOutput
sometimes appends logs even when append false
in multiple workersSecondaryFileOutput
has race condition issues in multiple workers
Additional tests. Environment
Fix
|
workers | flush_thread_count | percentage (1st) | percentage (2nd) |
---|---|---|---|
1 | 16 | 54.2% (13/24) | 32.3% (10/31) |
3 | 1 | 32.5% (13/40) | 12.5% (3/24) |
append true
It seems that the same race condition can occur as
However, the timing is too severe to reproduce it.
In #3805, we could adopt the way of using flush_at_shutdown
and make the plugin output chunks at the same time, but it is difficult in this case.
I tried the following way, but I couldn't reproduce it.
<system>
workers 8
</system>
<source>
@type sample
tag test.hoge
sample {"message": "hogehogehogehogehogehogehogehogehogehoge"}
rate 100
</source>
<source>
@type sample
tag test.fuga
sample {"message": "fugafugafugafugafugafugafugafugafugafuga"}
rate 100
</source>
<source>
@type sample
tag test.foo
sample {"message": "foofoofoofoofoofoofoofoofoofoo"}
rate 100
</source>
<match test.**>
@type file
path /test/fluentd/log/${tag}/fluentd.log
<format>
@type single_value
</format>
<buffer tag>
@type file
path /test/fluentd/buffer
flush_thread_count 16
flush_mode interval
flush_interval 1s
flush_thread_interval 0.1
flush_thread_burst_interval 0.1
retry_max_times 1
</buffer>
<secondary>
@type secondary_file
directory /test/fluentd/error/
append true
</secondary>
</match>
daipom
changed the title
Mar 6, 2023
SecondaryFileOutput
has race condition issues in multiple workersSecondaryFileOutput
has race condition issues in multiple threads and workers
daipom
changed the title
Mar 6, 2023
SecondaryFileOutput
has race condition issues in multiple threads and workersSecondaryFileOutput
has race condition issues in multiple threads or workers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
SecondaryFileOutput
sometimes appends logs even whenappend false
in multiple threads or workersSince
SecondaryFileOutput
does not use any lock, race condition can occur.Especially, this logic causes race condition issues in multiple threads or workers when
append false
.fluentd/lib/fluent/plugin/out_secondary_file.rb
Lines 118 to 129 in e58fd66
To Reproduce
Run the fluentd with the following config for about 1 minute.
Somehow make
out_file
plugin's output error.I fixed the code for debugging.
bundle exec fluentd -c fluent.conf
Then we can find some files where logs with different tags are mixed in the same file although the chunk-key was
tag
andappend
wasfalse
.Expected behavior
Each chunk is separated into a file.
File-A
File-B
Your Environment
Your Configuration
Your Error Log
Additional context
No response
The text was updated successfully, but these errors were encountered: