Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-3994

Use CLOCK_MONOTONIC for all pthread_cond_timedwait()

    Details

    • Type: Task
    • Status: Stalled
    • Priority: Minor
    • Resolution: Unresolved
    • Fix Version/s: 10.2
    • Component/s: None
    • Labels:
      None

      Description

      Now all pthread conditions in MariaDB are created with the default attributes. It means that pthread_cond_timedwait() uses "realtime" clock, and changes in the system time (e.g., if the system administrator manually changes the clock) might interrupt timed condition waits. In almost all cases this is not desirable. To fix it, we should use

        pthread_condattr_setclock(attr, CLOCK_MONOTONIC)
      

      create all conditions with this attribute, and use

      clock_gettime(CLOCK_MONOTONIC, ...)
      

      when calculating wakeup time.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            Somehow this didn't work. I'm getting lots of timeouts, but in the debugger I see that the current time (yes, CLOCK_MONOTONIC) is clearly less than the wakeup time.

            Show
            serg Sergei Golubchik added a comment - Somehow this didn't work. I'm getting lots of timeouts, but in the debugger I see that the current time (yes, CLOCK_MONOTONIC) is clearly less than the wakeup time.
            Hide
            serg Sergei Golubchik added a comment -

            incomplete WIP patch is attached

            Show
            serg Sergei Golubchik added a comment - incomplete WIP patch is attached

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                serg Sergei Golubchik
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - 2 hours
                  2h
                  Remaining:
                  Time Spent - 1 hour Remaining Estimate - 1 hour
                  1h
                  Logged:
                  Time Spent - 1 hour Remaining Estimate - 1 hour
                  1h