Repository navigation
Write the How to Write Buffer Plugin page - #724
Conversation
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>
👷 Deploy request for fluentd-docs pending review.Visit the deploys page to approve it
|
Watson1978
left a comment
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
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.
The How to Write Buffer Plugin page has been a heading and
TODO: Write, with only theevacuate_chunkdescription under it. This fills it in, following the layout of the storage and service discovery pages: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, andcompress gzip/zstd. A paragraph lists what a real plugin should add (multiple workers, broken files and so on) and links tobuf_file/FileChunk.#resume,#generate_chunk,#persistent?), with the existing#evacuate_chunkdescription kept as is. Also the methods a chunk implements (#concat,#commit,#rollback,#bytesize,#size,#read,#open) and the ones with default implementations.The page's description in
llms.txtis updated in the same style as the other plugin development pages.How I checked it:
master. With the truncation on restore removed, the rollback test fails as expected.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 withcompress gzip.Fixes #522