Lock the workspace row when accepting an invitation
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- authentication, backend, databases
Research direction
Start with server/orcaster_server/workspaces/service.py and trace the invitation refusal hook through server/orcaster_server/auth/config.py and the join and register/complete routes in server/orcaster_server/auth/router.py. Check how those routes manage transactions and how existing invitation tests set up database sessions. Done means both acceptance routes hold a shared row lock through commit or rollback, the read-only invitation paths remain unlocked, and the requested concurrency and 410 cases pass.
Written by the indexing model from the issue text.
Description
Problem
An invitation for a disabled workspace must never create a user, a session or a membership. The check and the commit are not atomic.
is_workspace_disabled runs a plain SELECT disabled_at with no row lock (server/orcaster_server/workspaces/service.py:147). It is reached through the is_invitation_refused hook (server/orcaster_server/auth/config.py:84) and _refused (server/orcaster_server/auth/router.py:114). The check runs at server/orcaster_server/auth/router.py:386 (register/complete) and server/orcaster_server/auth/router.py:284 (join), and the commit comes later (server/orcaster_server/auth/router.py:417 and :297). If the workspace is disabled after the check and before the commit, the acceptance still succeeds.
The window is small. It is wider if a slow step runs between check and commit.
Proposed change
Add a locking variant of the disabled check that uses SELECT disabled_at FROM workspaces WHERE id = ... FOR SHARE, and use it from the acceptance routes (register/complete and join). The lock is held until the route commits or rolls back. A concurrent update that sets disabled_at then waits for the acceptance to finish. Either the disable lands after the membership exists, or the acceptance sees disabled_at and answers 410. Both outcomes are consistent.
- Keep the read-only invitation page free of the lock.
- A workspace disabled after the acceptance keeps its new member. This is out of scope.
Acceptance criteria
-
register/completereads the workspace row withFOR SHAREand keeps the lock until commit or rollback. -
joindoes the same. - The read-only invitation page and
describe_invitationtake no row lock. - A test with two database sessions shows that setting
workspaces.disabled_atblocks while an acceptance is in progress and lands after its commit. Same test forjoin. - A test shows that a disable committed before the check gives 410 and creates no user, session or membership.
- Existing deployments keep working without configuration changes. The only visible effect is that an operator update of
workspacesmay wait for one acceptance transaction. - Existing invitation tests pass.
- CHANGELOG entry under Unreleased.
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AInvirion/orcaster
-
enhancement P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
enhancement good first issue P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug P2 server
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
bug P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
enhancement P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
All issues in AInvirion/orcaster
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day