Skip to main content

AcquireError

Enum AcquireError 

Source
pub enum AcquireError {
    AtCapacity {
        capacity: usize,
    },
    OutOfReservation {
        requested: usize,
        reserved: usize,
        budget: usize,
    },
    SpawnFailed(Error),
    ShuttingDown,
}
Expand description

Why WorkerPool::acquire refused.

§The defect this closes

acquire refuses at two gates that mean opposite things to whoever has to act on the refusal:

  • AtCapacitythis process said no. Every set the pool may create is already leased. The remedy is to raise the bound (or to accept the bound as the connection limit it is); the target is fine.
  • OutOfReservationthis process said no on behalf of the target: admitting would reserve more thread memory than the process is allowed to hold. The remedy is RAM plus a raised POOL_RESERVATION_ENV, and the target is still healthy — which is the whole point of refusing here rather than one connection later.
  • SpawnFailedthe target said no. The OS refused to create the set’s threads. The remedy is memory, and the pool’s own bound is irrelevant because it was never reached.

Both used to be an io::Error, and both landed on io::ErrorKind::WouldBlock — the capacity arm by construction, the spawn arm because a failed Builder::spawn is EAGAIN and std decodes EAGAIN as WouldBlock. So the one discriminator a consumer had was the message prose, and every consumer that branched on kind() silently answered the wrong question. Both server drivers did: the CA server reported both as one status on the wire — measured on VxWorks 7, where both gates were reached on one image with available=48 on each (doc/vxworks-ca-refusal-fidelity.md §6) — and the PVA server’s kind() == WouldBlock arm reports an out-of-threads target as max_connections reached, naming a bound that never fired. That second one is by construction, not measured: the blocking PVA server has not been driven to its wall on this target.

Naming the gate in the type is what makes that class of mistake unwritable: a consumer that wants “is this the connection limit” must now say so, and gets an answer that cannot be an EAGAIN in disguise.

The From conversion to io::Error keeps each variant’s historical ErrorKind for callers that only propagate, and carries self as the error’s payload so the gate survives the conversion and stays recoverable with downcast_ref.

Variants§

§

AtCapacity

Every set the pool may ever create is leased out. capacity is the bound that was reached — the number to report and the number to raise.

Fields

§capacity: usize

The pool’s declared capacity, in sets.

§

OutOfReservation

Admitting would take the process past its thread-memory budget. Nothing was reserved and no thread was created.

Fields

§requested: usize

What this set would have reserved, in bytes.

§reserved: usize

Already reserved by every pool in the process, in bytes.

§budget: usize

The process budget, in bytes — the number POOL_RESERVATION_ENV raises.

§

SpawnFailed(Error)

The OS refused to create the set’s threads. The pool was below its capacity and created is left exactly as it was found.

§

ShuttingDown

The pool is shutting down and will not lease again.

Trait Implementations§

Source§

impl Debug for AcquireError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for AcquireError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for AcquireError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<AcquireError> for Error

Source§

fn from(cause: AcquireError) -> Error

Converts to this type from the input type.

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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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<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