Skip to main content

ClientSession

Struct ClientSession 

Source
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: Uuid

Session ID

§client_addr: SocketAddr

Client address

§current_node: RwLock<Option<String>>

Current backend node

§in_transaction: AtomicBool

Fast, 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: AtomicBool

Set 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: TrMode

TR 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: ClientId

Client 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: AtomicBool

Sticky 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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more