awslabs / amazon-kinesis-agent

Continuously monitors a set of log files and sends new data to the Amazon Kinesis Stream and Amazon Kinesis Firehose in near-real-time.
Other
352 stars 218 forks source link

Assert crash when tailing double logrotated file #231

Open TheHinsh opened 2 years ago

TheHinsh commented 2 years ago

When a log file being monitored by the aws-kinesis-agent is (inadvertently) log rotated twice, the following code in TrackedFileRotationAnalyzer.java will assert, causing the agent to stop working (and likely not recover properly due to ungracefully closing down).

        Preconditions.checkState(incoming.size() > 1); // always true after rotation by Truncate
        Preconditions.checkState(hasCounterpart(incoming.get(0))); // always true for rotation by Truncate

Commenting (or just removing) these two lines will allow the code to properly close down the tailing of a file that has been double log rotated.

        // Preconditions.checkState(incoming.size() > 1); // always true after rotation by Truncate
        // Preconditions.checkState(hasCounterpart(incoming.get(0))); // always true for rotation by Truncate