daily_file_sink deletes the active log file when a message timestamp jumps past more than one rotation day (max_files=1)
With max_files=1, log two messages timestamped 48h ahead via logger.log(time_point, ...). After the first, the file exists. After the second, it's deleted. Each message triggers a rotation to the same filename, and delete_old_ pops the queue front, which is the file being written.
Real triggers: backfilled logs, out-of-order ingestion, or a forward clock jump (NTP, VM resume). Different from #2553, where old files aren't deleted. #3598 rewrites the cleanup and would probably cover this. If you'd like a small fix on the current logic (never unlink the active file), I can send a PR.
AI disclosure: I used AI tools to find and reproduce this; I reviewed it myself.
That is correct, but since time-based rotation is performed based on the timestamp in the log message, this is expected behavior. Besides, there's a problem with specifying a time 48 hours in the future (a fake time).
Agreed that rotation uses the message timestamp. I tested the triggers separately: past backfill, past out-of-order messages, and a sustained forward clock jump did not delete the active file. A simulated clock rollback did reproduce it when two messages timestamped before the rollback were delivered afterward. With max_files=1, next_rotation_tp_() resets from the current wall clock, both messages reopen the same filename, and the second delete_old_() unlinks it. So my original trigger list was too broad. Would protecting the active filename during cleanup make sense for that narrower case?
If the current log file is accidentally deleted when a 48-hour interval elapses in real time, it should be protected. However, if the problem only occurs when a timestamp 48 hours from the current time is passed, I don't think protection is necessary.