Skip to content

Use monotonic clock so postgres timeouts are unaffected by system clock changes#141

Merged
seuros merged 1 commit intoClosureTree:masterfrom
eliotsykes:use-monotonic-time
Jan 15, 2026
Merged

Use monotonic clock so postgres timeouts are unaffected by system clock changes#141
seuros merged 1 commit intoClosureTree:masterfrom
eliotsykes:use-monotonic-time

Conversation

@eliotsykes
Copy link
Contributor

Time.now is not a reliable way to measure elapsed time. If a system clock adjustment coincides with a lock being held, then the timeout actually used may not be the same as timeout_seconds.

The monotonic clock measures elapsed time more accurately. The monotonic time is the time since the computer started up, and it is always moving forward.

This change should only affect postgres advisory locks as mysql does not use this method for its timeout behavior.

@seuros
Copy link
Member

seuros commented Jan 15, 2026

That awesome, thanks.

@seuros seuros merged commit 929e010 into ClosureTree:master Jan 15, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants