Commit 1bc8a75
authored
file_chunk: add stricter checks for broken meta files (#4998)
**Which issue(s) this PR fixes**:
* Related to #3970
**What this PR does / why we need it**:
This PR improves meta file corruption checking.
The meta file contains at least the following field values.
https://github.com/fluent/fluentd/blob/fa2eb58922e1c36f83bf1d5243b325a860f72864/lib/fluent/plugin/buffer/file_chunk.rb#L249-L254
This PR reinforces #1874.
Without this changes, it might causes following error when launch
fluentd every time with broken meta file:
```
2025-06-06 12:11:26 +0900 [error]: unexpected error while checking flushed chunks. ignored. error_class=NoMethodError error="undefined method '<' for nil"
2025-06-06 12:11:26 +0900 [error]: /Users/watson/src/fluentd/lib/fluent/plugin/output.rb:1479:in 'block in Fluent::Plugin::Output#enqueue_thread_run'
2025-06-06 12:11:26 +0900 [error]: /Users/watson/src/fluentd/lib/fluent/plugin/buffer.rb:548:in 'block in Fluent::Plugin::Buffer#enqueue_all'
2025-06-06 12:11:26 +0900 [error]: /Users/watson/src/fluentd/lib/fluent/plugin/buffer.rb:542:in 'Array#each'
2025-06-06 12:11:26 +0900 [error]: /Users/watson/src/fluentd/lib/fluent/plugin/buffer.rb:542:in 'Fluent::Plugin::Buffer#enqueue_all'
2025-06-06 12:11:26 +0900 [error]: /Users/watson/src/fluentd/lib/fluent/plugin/output.rb:1479:in 'Fluent::Plugin::Output#enqueue_thread_run'
2025-06-06 12:11:26 +0900 [error]: /Users/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:78:in 'block in Fluent::PluginHelper::Thread#thread_create'
```
If the timekey value is corrupted, the above error occurs.
Since there is no appropriate way to check timekey directly, check `id`,
`c`, and `m` fields instead. This is because when timekey is broken,
other fields may also be broken.
It might be possible that the `@size` is 0.
`@unique_id`, `@created_at`, and `@modified_at` are set when FileChunk
is initialized, so they definitely have some values.
I think these fields should be written in meta file.
So, this PR adds the `id`, `c`, and `m` fields check.
Previously, it operates using default value if metadata was broken.
However, it can miss the corruption and result in unexpected errors.
So, this PR enhances the detection of broken metadata files instead of
using defalut value.
This change has backward compatible with v0.14 behavior.
**Docs Changes**:
Not necessarily required.
**Release Note**:
buf_file: reinforce buffer file corruption check
---------
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>1 parent 1a773b0 commit 1bc8a75
File tree
2 files changed
+37
-3
lines changed- lib/fluent/plugin/buffer
- test/plugin
2 files changed
+37
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
222 | 226 | | |
223 | 227 | | |
224 | 228 | | |
225 | | - | |
| 229 | + | |
226 | 230 | | |
227 | | - | |
228 | | - | |
| 231 | + | |
| 232 | + | |
229 | 233 | | |
230 | 234 | | |
231 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1322 | 1322 | | |
1323 | 1323 | | |
1324 | 1324 | | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
1325 | 1355 | | |
1326 | 1356 | | |
1327 | 1357 | | |
| |||
0 commit comments