[SERVER-83933] Move AsioSession ingress initialization steps before startSession Created: 06/Dec/23  Updated: 07/Dec/23

Status: Open
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: James Bronsted Assignee: Backlog - Service Architecture
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Initiative
Related
is related to SERVER-72605 Ensure and document thread-safety sem... Closed
Assigned Teams:
Service Arch
Participants:

 Description   

Currently, `CommonAsioSession` performs a few initialization steps in ingress mode, some of which occur before the `startSession` is invoked on the session and some of which occur after. For example, parsing the proxy protocol header occurs before `startSession`, while the SSL handshake occurs during the first read, which occurs after `startSession`.

This inconsistency means that ingress sessions that have "started," and therefore are accessible by multiple threads, aren't fully initialized, which makes it potentially difficult to reason about what state a session may be in. The thread-safety issue documented in SERVER-72605 occurs because the SSL handshake can occur concurrently to the session being terminated; if the SSL handshake occurs before the session becomes available to threads other than its owner, there is no such concurrent behavior to consider.

Move all of ingress initialization steps to occur before `startSession`. An example of how this might be implemented can be found among these code snippets:

Additionally, when the SSL handshake is moved to occur before session start, also remove the synchronization logic added in SERVER-72605.


Generated at Thu Feb 08 06:53:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.