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

Lock sessions table when opening a new session #309

Open
sde1000 opened this issue Jan 9, 2025 · 2 comments
Open

Lock sessions table when opening a new session #309

sde1000 opened this issue Jan 9, 2025 · 2 comments

Comments

@sde1000
Copy link
Owner

sde1000 commented Jan 9, 2025

If two people try to start a session at exactly the same time, two open sessions can be created.

Take an exclusive lock on the sessions table during session creation to prevent this.

@sde1000 sde1000 added the bug label Jan 9, 2025
@sde1000
Copy link
Owner Author

sde1000 commented Jan 9, 2025

(Amazingly, this came up for the first time in 20 years, this week!)

@sde1000
Copy link
Owner Author

sde1000 commented Jan 13, 2025

The easiest way to do this Properly™ would be to add a unique constraint on endtime with the SQL NULLS NOT DISTINCT clause — that way, at most one row could have a null endtime.

Unfortunately, this was only implemented in Postgresql 15 — most current installations are using Postgresql 14 (or earlier).

Since this has only come up once in 20 years, we could wait a while before fixing it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant