Logstash file input sincedb_path interoperability with pipeline restart offset recovery
0 reputation · 25 Dec 2021, 23:44 UTC
0 reputation · 25 Dec 2021, 23:44 UTC
In current Logstash releases, the file input plugin maintains a sincedb checkpoint to track byte offsets per file path, resuming from saved positions upon pipeline restart. When sincedb_path is configured to an externally mounted volume, the interoperability between the configured checkpoint location and the pipeline's offset recovery mechanism becomes critical for data integrity in containerized environments.
The precise goal is to determine how Logstash reconciles a persistently mounted sincedb_path against file inode changes, rotations, or permission shifts during restart, and whether the saved byte offset is honored or reset to the file start. Key uncertainty arises from the default sincedb_write_interval of 15 seconds, which may create a temporal gap between actual pipeline progress and persisted offset, especially under high-write frequency. Additionally, if the sincedb file at the configured path is unavailable or altered between restarts, Logstash may default to beginning-of-file processing, potentially emitting duplicate events or losing records.
Does Logstash prioritize the configured sincedb_path over the default state directory when resuming from a checkpoint? If the externally mounted sincedb_path is replaced or cleared between restarts, does the file input reset to the beginning of associated files or retain the last saved offset? What impact does the sincedb_write_interval have on offset durability versus temporary staleness when the checkpoint resides on a persistent volume?
35275 reputation · 26 Dec 2021, 01:04 UTC
sincedb_path exclusively. It does not fall back to the default $HOME/.sincedb_* location when that path is set.start_position (default: beginning). The last saved offset is not retained.sincedb_write_interval: 15 creates a durability window of up to 15 seconds. On clean shutdown (SIGTERM) Logstash flushes immediately, eliminating the gap. On unclean termination (OOMKill, SIGKILL, power loss) up to one interval of processed bytes can be lost, causing duplicate events on restart.On startup the file input reads the sincedb file at the configured path. Each record stores the watched file's path, inode, major device number, minor device number, and the last known byte offset. Logstash scans the current filesystem for files matching the input's path patterns and matches them against the sincedb entries by inode + device (Unix) or file ID (Windows).
start_position.File rotation is handled naturally: the old file's final offset remains recorded; the new file (same path, new inode) starts from start_position.
sincedb_path must point to a persistent volume that survives pod/container restarts.sincedb_path set to /your/path and Reading sincedb from /your/path.cat /your/path/sincedb (plain text: path, inode, major, minor, offset). Compare before and after a restart.kill -9 <pid>, restart, and observe whether the last events before the kill are duplicated.mv watched.log watched.log.1 && touch watched.log, write to both, restart, and confirm the rotated file's offset is preserved while the new file starts from the beginning.Are you using a network filesystem (NFS, SMB, EFS, etc.) for the sincedb volume? Network filesystems may not preserve inode/device stability across server restarts, which breaks sincedb matching and forces re-reading from the beginning.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.