You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
buffer: fix an enqueued unstaged file chunk being re-staged and flushed twice
FileChunk#enqueued! and FileSingleChunk#enqueued! did nothing for an
unstaged chunk, so a chunk pushed by Buffer#enqueue_unstaged_chunk stayed
:unstaged with its staged file name while it was in the queue. When
write_step_by_step unstages chunks on a single-record overflow,
Buffer#write re-staged that queued chunk because the `u.unstaged?` guard
could not tell it was already enqueued, and the same chunk object lived
in both @Queue and @stage. The second flush of that object raised
"closed stream" at FileChunk#open and ENOENT at FileChunk#purge, and the
buffer size gauges leaked.
Treat an unstaged chunk like a staged one in enqueued!: mark it as
:queued, write its metadata and rename its files to the queued path, so
resume also restores it as a queued chunk. The state changes before the
rename and the gauges are updated before enqueued!, so a chunk whose
rename fails stays a consistent queued chunk with its staged file name.
Buffer#write only warns about such a failure and keeps enqueueing the
other chunks: the records are already queued, and a chunk left unstaged
there would be purged with its committed records.
FileSingleBuffer#resume now enqueues a staged chunk file whose metadata
is already staged, as FileBuffer#resume does, so that two chunk files
with the staged name are both restored. file_rename reopens the old file
when the rename fails on Windows, so that the chunk stays readable.
Fixes#4662
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Copy file name to clipboardExpand all lines: lib/fluent/plugin/buf_file.rb
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -174,7 +174,7 @@ def resume
174
174
when:staged
175
175
# unstaged chunk created at Buffer#write_step_by_step is identified as the staged chunk here because FileChunk#assume_chunk_state checks only the file name.
# This case can happen when fluentd process is killed by signal or other reasons between creating unstaged chunks and changing them to staged mode in Buffer#write
177
+
# This case can happen when fluentd process is killed by signal or other reasons between creating unstaged chunks and enqueueing them (which renames them) in Buffer#write
178
178
# these chunks(unstaged chunks) has shared the same metadata
179
179
# So perform enqueue step again https://github.com/fluent/fluentd/blob/9d113029d4550ce576d8825bfa9612aa3e55bff0/lib/fluent/plugin/buffer.rb#L364
0 commit comments