refactor: Staff permissions in codebase - #836
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4618e32ecf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await Promise.all( | ||
| affectedUserIds.map( | ||
| async userId => await invalidateSessionCacheForUser(c, userId), | ||
| ), |
There was a problem hiding this comment.
Batch session-cache invalidation when deleting roles
When a role has many primary or secondary holders, this launches one invalidateSessionCacheForUser call per user without a concurrency limit; each call performs two database queries before deleting cache keys. Deleting a widely assigned role can therefore enqueue thousands of concurrent queries, exhaust the database pool, and return a 500 after the role transaction has already committed. Load the affected sessions in batched queries and delete their cache keys in bulk, or at least process users with bounded concurrency.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de1787fe16
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -112,32 +112,34 @@ export const signUp = async ( | |||
| }); | |||
There was a problem hiding this comment.
Avoid serializing every post-bootstrap signup
Every registration acquires the same transaction-scoped advisory lock before counting users, including after bootstrap when the first-user race no longer exists. Concurrent signups across all application instances are therefore forced through one database transaction at a time, unnecessarily capping registration throughput and increasing latency. Perform an unlocked existence check first, and only acquire this lock and recheck when the database may still be empty.
Useful? React with 👍 / 👎.
Improving Documentation
pnpm lint:fixto fix formatting issues before opening the PR.Description
What?
Why?