pub struct ClientSession {Show 14 fields
pub id: Uuid,
pub client_addr: SocketAddr,
pub current_node: RwLock<Option<String>>,
pub in_transaction: AtomicBool,
pub copy_in_progress: AtomicBool,
pub tx_state: RwLock<TransactionState>,
pub variables: RwLock<HashMap<String, String>>,
pub created_at: DateTime<Utc>,
pub tr_mode: TrMode,
pub last_write_at: RwLock<Option<Instant>>,
pub pool_client_id: ClientId,
pub plugin_identity: RwLock<Option<Identity>>,
pub edge_ineligible: AtomicBool,
pub pending_edge_copy_tables: Mutex<Option<Vec<String>>>,
}Expand description
Client session
Fields§
§id: UuidSession ID
client_addr: SocketAddrClient address
current_node: RwLock<Option<String>>Current backend node
in_transaction: AtomicBoolFast, lock-free “in a transaction” flag — the single per-query hot-path
read/write of transaction state. Written from the ReadyForQuery status
byte at each response boundary; read by pool-release, read-node
selection, and cache-eligibility checks. This is authoritative on the
data path; tx_state (below) retains the richer structure for TR/replay
consumers but is no longer touched per query, so the relay pays no
RwLock acquisition just to test in-transaction.
copy_in_progress: AtomicBoolSet while the session is mid-COPY (the backend sent CopyInResponse /
CopyBothResponse and is awaiting CopyData from the client). A COPY is
NOT a clean transaction boundary even though no ReadyForQuery has been
seen yet, so Transaction/Statement pool release must be suppressed while
it is set — otherwise the connection would be reset (DISCARD ALL) and
parked in the middle of a copy, aborting it and hanging the client.
Cleared once the COPY drains to ReadyForQuery.
tx_state: RwLock<TransactionState>Rich transaction state (tx id, statement log, savepoints) for
Transaction-Replay/library consumers. Not read or written on the
per-query forward path — see in_transaction above.
variables: RwLock<HashMap<String, String>>Session variables
created_at: DateTime<Utc>Created at
tr_mode: TrModeTR mode for this session
last_write_at: RwLock<Option<Instant>>Wall-clock instant of this session’s most recent write, for read-your-writes routing: reads within the configured window after a write are pinned to the primary so the client observes its own writes despite replica lag.
pool_client_id: ClientIdClient ID for pool-modes lease tracking
plugin_identity: RwLock<Option<Identity>>Identity returned by an Authenticate plugin, if any. Downstream
plugins (masking, residency routing, cost governor) read this to
gate per-user policy. None when no plugin ran or every plugin
deferred to the default auth flow.
edge_ineligible: AtomicBoolSticky edge-cache ineligibility: set once the session executes any statement that alters execution context (SET/SET ROLE/search_path, temp tables, …). The shared edge cache keys on (fingerprint, params, db/user, startup vars) — it cannot see session-local GUC state, so a session that mutates it must never read from or store into the shared cache again (cross-session wrong-rows otherwise).
pending_edge_copy_tables: Mutex<Option<Vec<String>>>Tables of an in-flight COPY ... FROM awaiting its CopyDone drain.
COPY rows become visible at drain time, so the edge invalidation is
deferred until then (never held across an await).
Auto Trait Implementations§
impl !Freeze for ClientSession
impl !RefUnwindSafe for ClientSession
impl !UnwindSafe for ClientSession
impl Send for ClientSession
impl Sync for ClientSession
impl Unpin for ClientSession
impl UnsafeUnpin for ClientSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more