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

fix(stats): time now_local not working on Linux #1477

Merged
merged 1 commit into from
Jan 1, 2024
Merged

Conversation

conradludgate
Copy link
Collaborator

@conradludgate conradludgate commented Jan 1, 2024

On many platforms, getting local timezone requires a call to get_env which is not thread safe. This means it conservatively doesn't work if a thread has been spawned (I believe sqlite is using a separate thread here).

Attempt to fix by acquiring the local tz as early as possible.

Copy link

vercel bot commented Jan 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
atuin-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 1, 2024 4:34pm

@ellie ellie changed the title fix time now_local fix(stats): time now_local not working on Linux Jan 1, 2024
@conradludgate conradludgate marked this pull request as draft January 1, 2024 16:36
Copy link
Member

@ellie ellie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@conradludgate
Copy link
Collaborator Author

Let me verify that it actually works

@ellie
Copy link
Member

ellie commented Jan 1, 2024

ah yes, draft 🤦‍♀️

@conradludgate
Copy link
Collaborator Author

conradludgate commented Jan 1, 2024

I believe sqlite is using a separate thread here

Confirmed. I pulled in the num_threads crate that time uses to verify, and before the sqlite dbs are opened it is single threaded, after they are opened it has 3 threads. This change should indeed work as settings are necessarily loaded before the database.

Further, if there is no local offset available, we fallback to UTC.

@conradludgate conradludgate marked this pull request as ready for review January 1, 2024 16:40
@ellie ellie merged commit e2a4e9c into main Jan 1, 2024
10 checks passed
@ellie ellie deleted the fix-local-time branch January 1, 2024 16:42
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