Fix for fail to remove state where file was deleted and clean_removed was set. #2061
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.
We ran filbeat on tens of files which are rotated every hour and get archived (gzipped) after a certain amount of hours.
We saw that some logfiles were not harvested after an hour and few hours later basically none of the logfile was harvested. Based on the debug logs it was due to inode reuse which happened quite frequently in our system (ubuntu linux/ext4) So basically when a file get archived then the next file get the it's inode and it confused filebeat.
To solve this we set the clean_removed property which should solve our issue but it did not.
See the debug log output:
2016-07-17T19:59:01+02:00 DBG New state added for /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:02+02:00 DBG Cleanup state for file as file removed: /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:03+02:00 DBG Cleanup state for file as file removed: /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:03+02:00 DBG Cleanup state for file as file removed: /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:04+02:00 DBG Cleanup state for file as file removed: /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:05+02:00 DBG Cleanup state for file as file removed: /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:05+02:00 DBG Cleanup state for file as file removed: /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:06+02:00 DBG Cleanup state for file as file removed: /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:07+02:00 DBG Cleanup state for file as file removed: /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:07+02:00 DBG Cleanup state for file as file removed: /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
2016-07-17T19:59:08+02:00 DBG New state added for /mnt/scribe/jseditor_structured/jseditor_structured-2016-07-17_00000
As you can see based on the logs the jseditor_structured logcategory should get removed earlier but it updated the state later.
Based on the code if a file gets deleted it set the ttl to zero and it sends an event and later it should be deleted. In reality it did not happen if clean_inactive was not set:
https://github.com/elastic/beats/blob/master/filebeat/prospector/prospector_log.go#L55
Now added an extra check to clean states if clean_removed set as well.
With this in our usecase it does not stop harvesting files after hours.