-
Notifications
You must be signed in to change notification settings - Fork 1.4k
buffer: add feature to evacuate chunk files when retry limit #4986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
daipom
merged 1 commit into
fluent:master
from
daipom:buffer-add-feature-to-evacuate-chunk-files-when-retry-limit
Jun 4, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -625,6 +625,7 @@ def clear_queue! | |
until @queue.empty? | ||
begin | ||
q = @queue.shift | ||
evacuate_chunk(q) | ||
log.trace("purging a chunk in queue"){ {id: dump_unique_id_hex(chunk.unique_id), bytesize: chunk.bytesize, size: chunk.size} } | ||
q.purge | ||
rescue => e | ||
|
@@ -636,6 +637,25 @@ def clear_queue! | |
end | ||
end | ||
|
||
def evacuate_chunk(chunk) | ||
# Overwrite this on demand. | ||
# | ||
# Note: Difference from the `backup` feature. | ||
# The `backup` feature is for unrecoverable errors, mainly for bad chunks. | ||
# On the other hand, this feature is for normal chunks. | ||
# The main motivation for this feature is to enable recovery by evacuating buffer files | ||
# when the retry limit is reached due to external factors such as network issues. | ||
# | ||
# Note: Difference from the `secondary` feature. | ||
# The `secondary` feature is not suitable for recovery. | ||
# It can be difficult to recover files made by `out_secondary_file` because the metadata | ||
# is lost. | ||
# For file buffers, the easiest way for recovery is to evacuate the chunk files as is. | ||
# Once the issue is recovered, we can put back the chunk files, and restart Fluentd to | ||
# load them. | ||
# This feature enables it. | ||
end | ||
daipom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def chunk_size_over?(chunk) | ||
chunk.bytesize > @chunk_limit_size || (@chunk_limit_records && chunk.size > @chunk_limit_records) | ||
end | ||
|
@@ -925,8 +945,6 @@ def backup(chunk_unique_id) | |
return | ||
end | ||
|
||
safe_owner_id = owner.plugin_id.gsub(/[ "\/\\:;|*<>?]/, '_') | ||
backup_base_dir = system_config.root_dir || DEFAULT_BACKUP_DIR | ||
backup_file = File.join(backup_base_dir, 'backup', "worker#{fluentd_worker_id}", safe_owner_id, "#{unique_id}.log") | ||
backup_dir = File.dirname(backup_file) | ||
|
||
|
@@ -945,6 +963,14 @@ def optimistic_queued?(metadata = nil) | |
[email protected]? | ||
end | ||
end | ||
|
||
def safe_owner_id | ||
owner.plugin_id.gsub(/[ "\/\\:;|*<>?]/, '_') | ||
end | ||
|
||
def backup_base_dir | ||
system_config.root_dir || DEFAULT_BACKUP_DIR | ||
end | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.