Skip to content

out_file: events except those in the first chunk are not written to files when append is true #3569

Description

@yaojingguo

Describe the bug

Events except those in the first chunk are not written to files when append is true for out_file plugin.

To Reproduce

  1. Run fluentd --setup to generate fluent.conf.
  2. Put the following content into fluent.conf.
<match hack.**>
  @type file
  path hack
  append true
  <format>
    @type json
  </format>
  <buffer>
    flush_mode immediate
  </buffer>
</match>
  1. Run the following command in a terminal:
$ curl -X POST http://localhost:8888/hack.access  -d 'json={"no":"1"}'
$ cat hack.20211202.log
{"no":"1"}
$ curl -X POST http://localhost:8888/hack.access  -d 'json={"no":"2"}'
$ cat hack.20211202.log
{"no":"1"}

Expected behavior

The content of hack.20211202.log should be:

{"no":"1"}
{"no":"2"}

but was:

{"no":"1"}

Your Environment

  • Fluentd version: 1.14.3
  • TD Agent version: 1.14.3
  • Operating system: macOS 10.15.5
  • Kernel version: 19.5.0
  • Ruby version: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin19]

I have used Ruby gem to install Fluentd.

Your Configuration

<match hack.**>
  @type file
  path hack
  append true
  <format>
    @type json
  </format>
  <buffer>
    flush_mode immediate
  </buffer>
</match>

Your Error Log

No error log

Additional context

I have verified that fluentd 1.14.3 which uses ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux] does not have this prolem on CentOS Linux release 7.5.1804 (Core). On macOS, I have tried two Ruby 2.x versions. Here is the result:

  • ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19] does not have this problem.
  • ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-darwin19] has this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions