{"record":{"id":"f88b7b52ec7c9cff","repo":"fluent/fluentd","slug":"enqueued-file-chunk-is-empty-f88b7b","errorCode":null,"errorMessage":"enqueued file chunk is empty","messagePattern":"enqueued file chunk is empty","errorType":"exception","errorClass":"FileChunkError","httpStatus":null,"severity":"critical","filePath":"lib/fluent/plugin/buffer/file_single_chunk.rb","lineNumber":294,"sourceCode":"\n          @chunk = File.open(@path, 'rb+')\n          @chunk.set_encoding(Encoding::ASCII_8BIT)\n          @chunk.sync = true\n          @chunk.binmode\n          @chunk.seek(0, IO::SEEK_END)\n\n          restore_metadata\n\n          @state = :staged\n          @bytesize = @chunk.size\n          @commit_position = @chunk.pos\n          @adding_bytes = 0\n          @adding_size = 0\n        end\n\n        def load_existing_enqueued_chunk(path)\n          @path = path\n          raise FileChunkError, \"enqueued file chunk is empty\" if File.size(@path).zero?\n\n          @chunk = File.open(@path, 'rb')\n          @chunk.set_encoding(Encoding::ASCII_8BIT)\n          @chunk.binmode\n          @chunk.seek(0, IO::SEEK_SET)\n\n          restore_metadata\n\n          @state = :queued\n          @bytesize = @chunk.size\n          @commit_position = @chunk.size\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":276,"sourceCodeEnd":311,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/buffer/file_single_chunk.rb#L276-L311","documentation":"The single-file buffer plugin re-opens already-enqueued chunks at startup via FileSingleChunk#load_existing_enqueued_chunk. An enqueued chunk holds committed data awaiting flush; if File.size(path) is zero it raises FileChunkError 'enqueued file chunk is empty' and fluentd startup aborts.","triggerScenarios":"A queued chunk file (name containing .q<hex>.) of 0 bytes: the enqueue rename completed but no data was ever written, a crash or disk-full interrupted the write, or the file was truncated externally.","commonSituations":"Hard crashes during enqueue; full or read-only buffer partition; incomplete copies of buffer directories; leftover files after changing the buffer path configuration.","solutions":["Stop fluentd, remove or quarantine the zero-byte queued chunk file reported at startup, restart.","Diagnose the write failure (disk space, dmesg/OOM, concurrent writers) so it does not recur.","If multiple files are affected, consider draining to a fresh buffer directory rather than deleting piecemeal."],"exampleFix":"# before: startup fails on 'enqueued file chunk is empty'\n# after: remove empty queued chunks and restart\nsudo systemctl stop fluentd\nfind /var/log/fluent/buffer -name '*q*.buf*' -size 0 -print -delete\nsudo systemctl start fluentd","handlingStrategy":"validation","validationCode":"# preflight: zero-size enqueued chunk files (single-mode buffer)\nDir.glob('/var/log/fluent/buffer/*q*.buf*').each do |f|\n  warn \"empty queued chunk: #{f}\" if File.size(f).zero?\nend","typeGuard":null,"tryCatchPattern":"begin\n  chunk = Fluent::Plugin::Buffer::FileSingleChunk.new(metadata, path, :queued, key)\nrescue Fluent::Plugin::Buffer::FileChunkError => e\n  log.error \"removing empty queued chunk #{path}: #{e.message}\"\n  File.delete(path) if File.size(path).zero?\nend","preventionTips":["Graceful shutdown with flush to avoid empty queued files.","Keep the buffer partition healthy and monitored.","Never hand-edit or partially copy the buffer directory.","Clean the directory when changing buffer path configuration."],"tags":["fluentd","ruby","file-buffer","empty-file","startup-failure"],"backgroundTag":"empty-buffer-chunk-file","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}