Roundcube logs are rotated recursively, generating ever-longer filenames and infinite duplication

Issue #818 resolved
pje created an issue

The /etc/logrotate.d/roundcube config file rotates * instead of *.log… which means that it also rotates its rotations, generating filenames like sendmail.log.1.1.1.1.1.1.1.1.1.1.1.1.1.1… continuing indefinitely.

I discovered this problem when my server backups began taking ridiculous amounts of time, due to the >750k log files thus generated. There were enough files that multiple logrotate operations were running in parallel, rotating, compressing and deleting each other’s rotations and compressions, to the point that I’m getting SSD drive errors that are likely the result of this constant, frenetic rewriting of the files.

The error exists in 2.2.26, as well as prior versions back to at least 2.2.19.

Comments (5)

  1. Robert Obermeier

    ^- for this some kind of notification would be nice or is there a mailing list for any other way to be notified about updates?
    I just had to do some disaster recovery after my server refused to do anything after hitting the directory limits of the filesystem (~5 mio. files)

  2. yannikh

    To make this better searchable and solvable for others, here my experience:

    Yesterday poste.io shut down. I think that was most likely my fault, stopping the server accidentally, but maybe it was also related to this issue, not quite sure. When I restarted the server it got “stuck” at [cont-init.d] 24-roundcube.sh: executing... . Looking around i found out that it was busy with chown of the roundcube logs directory. dmesg showed loads of messages like this:

    [16718682.749947] EXT4-fs warning (device dm-5): ext4_dx_add_entry:2209: Directory (ino: 4194315) index full, reach max htree level :2
    [16718682.750028] EXT4-fs warning (device dm-5): ext4_dx_add_entry:2213: Large directory feature is not enabled on this filesystem
    

    The script eventually completed (after… maybe 30 minuted) and roundcube started, acting normally. However I searched for the root of the problem and found that there were a total of 5,387,172 files in the roundcube log dir, making up 8 GB.

    I used the following command from roundcube/logs to remove the files:

    ls | grep -vP '\.log(\.\d+(\.gz)?)?$' | xargs -d '\n' rm
    

    I ran into some problems with that directory, so eventually I ended up deleting the directory and moving the remaining files:

    mv logs logs-old; mv logs-old/* logs; rm -r logs-old
    

  3. Denis Bukashk0zzz

    @yannikh Thank you so much. This post saves me a lot of time. Have exactly the same issue.

  4. Log in to comment