Skip to content

Write the How to Write Buffer Plugin page - #724

Merged
Watson1978 merged 4 commits into
fluent:1.0from
NopeCharon:buffer-plugin-guide
Nov 25, 2026
Merged

Watson1978 merged 4 commits into
fluent:1.0from
NopeCharon:buffer-plugin-guide

Conversation

@NopeCharon

@NopeCharon NopeCharon commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The How to Write Buffer Plugin page has been a heading and TODO: Write, with only the evacuate_chunk description under it. This fills it in, following the layout of the storage and service discovery pages:

  • An example plugin, buf_my_dir, that keeps each chunk in a data file and a meta file in a directory and restores the staged and queued chunks on #resume. It handles rollback, data written after the last commit at a crash, empty chunks on close, and compress gzip/zstd. A paragraph lists what a real plugin should add (multiple workers, broken files and so on) and links to buf_file/FileChunk.
  • The methods a buffer implements (#resume, #generate_chunk, #persistent?), with the existing #evacuate_chunk description kept as is. Also the methods a chunk implements (#concat, #commit, #rollback, #bytesize, #size, #read, #open) and the ones with default implementations.
  • The chunk metadata and the concat/commit/rollback transaction.
  • How to test a buffer plugin. There is no test driver for buffer plugins, so the test sets a dummy output plugin as the owner.

The page's description in llms.txt is updated in the same style as the other plugin development pages.

How I checked it:

  • I extracted the plugin and test code from this page. At dd3ec77, the tests (5 tests, 13 assertions) pass on Fluentd v1.19.3, v1.20.1 and the current master. With the truncation on restore removed, the rollback test fails as expected.
  • I ran Fluentd with the configuration on the page (flush_at_shutdown false) and stopped it before a flush. The chunk files stayed. After a restart, the buffered events were written out with their original timestamps and the files were removed. I also checked this with compress gzip.
  • I built the page with HonKit. Every link and anchor on it resolves.

Fixes #522

The page has been a heading and TODO: Write, with only a description of
evacuate_chunk below it. Fill it in following the layout of the storage
and service discovery pages:

* an example plugin which keeps each chunk in a data file and a meta
  file, and restores the staged and queued chunks on resume
* the methods a buffer plugin implements (#resume, #generate_chunk,
  #persistent? and the existing #evacuate_chunk description), and the
  methods a chunk implements (#concat, #commit, #rollback, #bytesize,
  #size, #read, #open and the ones with default implementations)
* the chunk metadata and the concat/commit/rollback transaction
* how to test a buffer plugin, which has no test driver

The example and its tests were checked against Fluentd v1.19.0 and the
current master, including compress gzip and a restart with unflushed
chunks.

Also fill in the llms.txt description in the same style as the other
plugin development pages.

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@netlify

netlify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

👷 Deploy request for fluentd-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit dd3ec77

@Watson1978 Watson1978 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for filling in this page. The layout follows the other plugin development pages. I ran the tests on the page against v1.19.0 and the current master, and the restart example worked as you described.

Plugin authors will copy the example, so I also tried it with other configurations and failures. I left inline comments on the problems I could reproduce. The most important one is #commit: when writing the meta file fails, #rollback can no longer drop the added data. The others are about the JSON meta file, short or missing data files, decompression_size_limit, the path used as a glob pattern, and two things to add to the paragraph about a real plugin. The comments marked NIT are small suggestions.

Comment thread plugin-development/api-plugin-buffer.md Resolved
Comment thread plugin-development/api-plugin-buffer.md Resolved
Comment thread plugin-development/api-plugin-buffer.md Resolved
Comment thread plugin-development/api-plugin-buffer.md Resolved
Comment thread plugin-development/api-plugin-buffer.md Resolved
Comment thread plugin-development/api-plugin-buffer.md Resolved
Comment thread plugin-development/api-plugin-buffer.md Resolved
Comment thread plugin-development/api-plugin-buffer.md Resolved
Comment thread plugin-development/api-plugin-buffer.md Resolved
Write the meta file before updating the state in #commit, keep the meta
file in MessagePack, check the data file on restore, pass
decompression_size_limit, glob relative to path, and note path and
permission handling for real plugins.

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>

@Watson1978 Watson1978 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the quick update. You addressed all nine requests from my previous review, and I checked each change on this commit. The tests on the page pass on v1.19.3, v1.20.1 and the current master. I also ran my earlier reproductions again. When #commit cannot write the meta file, #rollback now removes the new data. A non-UTF-8 chunk key survives a restart, a short data file is not restored, decompression_size_limit works, and the glob issue is gone.

I found two new problems, and both come from my own suggestions in the last review. I am sorry about that. I suggested thread_local_msgpack_packer in this comment, and it can break a meta file on the released versions up to v1.20.1. I also wrote that decompression_size_limit is for v1.20.0 or later in this comment, but it was also backported to v1.19.3. The inline comments have the details and tested fixes.

Comment thread plugin-development/api-plugin-buffer.md Resolved
Comment thread plugin-development/api-plugin-buffer.md Resolved
Use a new MessagePack packer for each meta file so a failed pack does not
leak bytes into the next one, and correct the version that accepts the
decompression_size_limit keyword to v1.19.3.

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>

@Watson1978 Watson1978 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for applying both suggestions. I checked this commit. With v1.20.1, a chunk written on the same thread after a failed pack is now restored after a restart. v1.19.2 rejects the decompression_size_limit keyword and v1.19.3 accepts it, as the paragraph now says. The tests on the page pass on v1.19.3, v1.20.1 and the current master. This addresses my earlier review comments. LGTM. Thank you for working through three rounds of review.

@Watson1978
Watson1978 merged commit 814b3d4 into fluent:1.0 Nov 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The page "How to Write Buffer Plugin" does not have any content

2 participants