fluent / fluent/fluentd

Keep receiving messages even after recieveing SIGTERM and lost data

Open
#1,985 2 comments 0 reactions 1 assignee Claimed by @ganmacs View on GitHub
v1
Dominant language
Ruby
Stars
13.6k
Forks
1.4k
Avg merge
1d 3h
Merged PRs (30d)
20

Description

Even after fluentd receives SIGTERM and closes, fluentd seems to keep recieving messages for a while.
So, even if `flush_at_shutdown` is `true`,
* buffer remains after shutdown
* some messages seem to be lost

------------

Environment:

commit `9738a421c2fe9f001b723ce86e4a6e47412c4baf`
ruby 2.3.1p112
Mac OS 10.13.4

Preparation:
```
gem install fluent-logger

vi fluentd.conf
vi post.rb # source is as follows
```

fluentd.conf is
```fluentd.conf

@type forward

@type file
path tmp/file
flush_at_shutdown true

```

post.rb is
```post.rb
require 'fluent-logger'
log = Fluent::Logger::FluentLogger.new

cnt = 0
while log.post('debug', { message: cnt+1 })
cnt += 1
sleep 0.00001
end
puts "finished at #{Time.now}, post-count: #{cnt}"
```

Run commands below:
```
bundle exec ./bin/fluentd -c ./fluent.conf &
# => [1] 61688
ruby post.rb &
kill 61688
# => ....
# => finished at 2018-05-16 13:39:10 +0900, post-count: 111296
```

After that, you can find a buffer file.
```
tail -n 1 tmp/file.20180516_0.log
# => 2018-05-16T13:39:07+09:00 debug {"message":79760}
tail -n 1 tmp/file/buffer.b56c4b4cd48555a7da3dd7abe659bf157.log
# => 2018-05-16T13:39:07+09:00 debug {"message":79763}
```
In this case, messages between 79763 and 111296 seem to be lost.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.