-
Notifications
You must be signed in to change notification settings - Fork 103
[sql-14] sessions: atomic session creation #980
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
Conversation
72d32b0
to
5a28d56
Compare
session_rpcserver.go
Outdated
req.DevServer, uniquePermissions, caveats, nil, false, nil, | ||
session.PrivacyFlags{}, | ||
) | ||
if err != nil { | ||
return nil, fmt.Errorf("error creating new session: %v", err) | ||
} | ||
|
||
if err := s.cfg.db.CreateSession(sess); err != nil { | ||
sess, err = s.cfg.db.CreateSession(sess.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: in this follow up, we add a way to do this in one go for normal (non-autopilot) sessions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good 🚀! Leaving one comment regarding state enforcement during session revoking that I believe we should fix :)
5a28d56
to
374c93f
Compare
374c93f
to
3f94793
Compare
bc53495
to
3e58e19
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 🚀! Still need to clarify regarding the same comment I left above though, but other than that, this looks good to go from my end 🔥
3e58e19
to
c60dc68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Niiiiiiiiiiiiice! uTACK LGTM 🔥!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice clean-up ⚡
In this commit, we let StateReserved be the new initial state of a session for when NewSession is called. We then do predicate checks for linked sessions along with unique session alias (ID) and priv key derivations all under the same DB transaction in NewSession. ShiftState then moves a session to StateCreated. Only in StateCreated does a session become usable. With this change, we no longer need to ensure atomic session creation by acquiring the `sessRegMu` mutex in the session RPC server.
This was used to check that all linked sessions are no longer active before attempting to register an autopilot session. But this is no longer needed since this is done within NewSession.
c60dc68
to
32a34d1
Compare
See #979 for more context.
In this PR, we do the refactor to make session creation happen in 1 atomic DB transaction as described in the issue above.
Fixes #979