[MDEV-3994] Use CLOCK_MONOTONIC for all pthread_cond_timedwait() Created: 2013-01-01  Updated: 2015-11-17

Status: Stalled
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Sergei Golubchik Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File clock_monotonic.diff    

 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.



 Comments   
Comment by Sergei Golubchik [ 2014-06-15 ]

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.

Comment by Sergei Golubchik [ 2014-06-16 ]

incomplete WIP patch is attached

Generated at Thu Feb 08 06:52:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.