Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4739

Race condition in log rotation (was: SIGUSR1 should set a flag rather than doing rotation)

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.5, 2.4.4, 2.5.0
    • Affects Version/s: 2.2.0, 2.2.2
    • Component/s: Logging, Stability
    • None

      The locking within logRotate only covers the swap of file handles, but renaming an open log file while it is being written to by another thread is not safe. The locking needs to be modified so that no race conditions exist.

      In addition, doing log rotation from a signal handler may be unsafe. It would be better to set a flag in the signal handler, and respond to it from a normal (non-signal) code path. For example, we could rotate the log next time something is logged.

      Currently there is a deadlock if the current thread is in the middle of logging.

            Votes:
            24 Vote for this issue
            Watchers:
            29 Start watching this issue

              Created:
              Updated:
              Resolved: