@@ -699,20 +699,22 @@ func (cn *Conn) GetStateMachine() *ConnStateMachine {
699699// TryAcquire attempts to acquire the connection for use.
700700// This is an optimized inline method for the hot path (Get operation).
701701//
702- // It tries to transition from IDLE -> IN_USE or CREATED -> IN_USE .
702+ // It tries to transition from IDLE -> IN_USE or CREATED -> CREATED .
703703// Returns true if the connection was successfully acquired, false otherwise.
704+ // The CREATED->CREATED is done so we can keep the state correct for later
705+ // initialization of the connection in initConn.
704706//
705707// Performance: This is faster than calling GetStateMachine() + TryTransitionFast()
706708//
707709// NOTE: We directly access cn.stateMachine.state here instead of using the state machine's
708710// methods. This breaks encapsulation but is necessary for performance.
709- // The IDLE->IN_USE and CREATED->IN_USE transitions don't need
711+ // The IDLE->IN_USE and CREATED->CREATED transitions don't need
710712// waiter notification, and benchmarks show 1-3% improvement. If the state machine ever
711713// needs to notify waiters on these transitions, update this to use TryTransitionFast().
712714func (cn * Conn ) TryAcquire () bool {
713715 // The || operator short-circuits, so only 1 CAS in the common case
714716 return cn .stateMachine .state .CompareAndSwap (uint32 (StateIdle ), uint32 (StateInUse )) ||
715- cn .stateMachine .state .CompareAndSwap (uint32 (StateCreated ), uint32 (StateInUse ))
717+ cn .stateMachine .state .CompareAndSwap (uint32 (StateCreated ), uint32 (StateCreated ))
716718}
717719
718720// Release releases the connection back to the pool.
0 commit comments