feat(consensus): add session registration protocol with combined login+register#3108
feat(consensus): add session registration protocol with combined login+register#3108krishvishal wants to merge 9 commits intoapache:masterfrom
Conversation
login+register command
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3108 +/- ##
============================================
+ Coverage 72.76% 73.16% +0.40%
Complexity 943 943
============================================
Files 1117 1122 +5
Lines 96368 97623 +1255
Branches 73544 74815 +1271
============================================
+ Hits 70119 71425 +1306
+ Misses 23702 23591 -111
- Partials 2547 2607 +60
🚀 New features to boost your workflow:
|
|
I've looked through this PR and I wonder how does it differ from the login and login with personal access token ? |
|
@numinnex I've only implemented login functionality with register but didn't implement login with personal access token. But its easily implementable because register doesn't care about how we logged in. |
| RequestStatus::AlreadyRegistered { session } => { | ||
| // Synthesize a register reply with the existing session. | ||
| // The caller can extract session from reply.header().commit. | ||
| tracing::debug!( | ||
| client_id, | ||
| session, | ||
| "register_preflight: client already registered, ignoring" | ||
| ); | ||
| None | ||
| } | ||
| RequestStatus::InProgress => None, |
There was a problem hiding this comment.
on AlreadyRegistered, the code returns None without sending the existing-session reply it says it will synthesize. This can black-hole duplicate Register retries (lost reply/timeout path), leaving clients stuck waiting instead of getting a deterministic session response.
There was a problem hiding this comment.
This is done on purpose since SDK is not wired up completely.
| let preflight_ok = if operation == Operation::Register { | ||
| register_preflight(consensus, client_id).await.is_some() | ||
| } else { | ||
| request_preflight(consensus, client_id, session, request) | ||
| .await | ||
| .is_some() | ||
| }; | ||
| if !preflight_ok { | ||
| return; |
There was a problem hiding this comment.
register_preflight(...).is_some() gates progress, and None returns early with no response to the client. Together with register_preflight behavior, duplicate register requests will be dropped silently
Summary
Operation::Registeras a VSR-level operation that goes through consensus to create durable client sessions, giving each client a deterministic session number (= commit op number) agreed upon by all replicas.sessionfield toRequestHeaderwith wire-layer validation: register requiressession=0, request=0; all other operations requiresession>0, request>0.ClientTableinto session-aware paths:check_register()/commit_register()for registration, andcheck_request()/commit_reply()with session + strict request monotonicity validation (NoSession,SessionMismatch, `RequestGap).ConsensusSession(SDK) for client-side session lifecycle andSessionManager(server-ng) for transport-to-consensus bridging.login_registerhandler: phase 1 verifies credentials locally, phase 2 submits register through consensus.RequestFrame2/ResponseFrame2withrequest_idfor request-response correlation and pipelining support.