Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CLOCK_MONOTONIC instead of Time.new to determine idle_since in the Session class #109

Open
dazuma opened this issue Jun 20, 2024 · 0 comments
Assignees

Comments

@dazuma
Copy link
Member

dazuma commented Jun 20, 2024

Google::Cloud::Spanner::Session#idle_since? uses an internal variable @last_updated_at to track the last change timestamp. This object is currently a Time object retrieved via Time.now, but it is never accessed directly, only in comparison with other Time objects to determine durations. For this purpose, it is better practice to use Process::clock_gettime(Process::CLOCK_MONOTONIC) which isn't sensitive to changes in the clock (e.g. due to time server updates).

We should also audit the rest of the code base to ensure there aren't other cases of this.

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

No branches or pull requests

1 participant