Debian Codegraph @

src/pool/inner.rs

raw symbols SCIP
1 use superrust-analyzer cargo sqlx-core 0.8.3 pool/::connectionrust-analyzer cargo sqlx-core 0.8.3 pool/connection/::{Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#, Idlerust-analyzer cargo sqlx-core 0.8.3 pool/connection/Idle#, Liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/Live#};
2 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::connectionrust-analyzer cargo sqlx-core 0.8.3 connection/::ConnectOptionsrust-analyzer cargo sqlx-core 0.8.3 connection/ConnectOptions#;
3 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::connectionrust-analyzer cargo sqlx-core 0.8.3 connection/::Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#;
4 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::databaserust-analyzer cargo sqlx-core 0.8.3 database/::Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#;
5 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
6 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::poolrust-analyzer cargo sqlx-core 0.8.3 pool/::{deadline_as_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/deadline_as_timeout()., CloseEventrust-analyzer cargo sqlx-core 0.8.3 pool/CloseEvent#, Poolrust-analyzer cargo sqlx-core 0.8.3 pool/Pool#, PoolOptionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#};
7 use crossbeam_queuerust-analyzer cargo crossbeam-queue 0.3.13 crate/::ArrayQueuerust-analyzer cargo crossbeam-queue 0.3.13 array_queue/ArrayQueue#;
8
9 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::syncrust-analyzer cargo sqlx-core 0.8.3 sync/::{AsyncSemaphorerust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphore#, AsyncSemaphoreReleaserrust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphoreReleaser#};
10
11 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/;
12 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/::Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#;
13 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::atomicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/::{AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#, AtomicU32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU32#, AtomicUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicUsize#, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#};
14 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::{Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#, RwLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/rwlock/RwLock#};
15 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::taskrust-analyzer cargo std https://github.com/rust-lang/rust/library/std task/::Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#;
16
17 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::loggerrust-analyzer cargo sqlx-core 0.8.3 logger/::private_level_filter_to_trace_levelrust-analyzer cargo sqlx-core 0.8.3 logger/private_level_filter_to_trace_level().;
18 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::poolrust-analyzer cargo sqlx-core 0.8.3 pool/::optionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/::PoolConnectionMetadatarust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolConnectionMetadata#;
19 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::private_tracing_dynamic_eventrust-analyzer cargo sqlx-core 0.8.3 logger/private_tracing_dynamic_event!;
20 use futures_utilrust-analyzer cargo futures-util 0.3.34 crate/::futurerust-analyzer cargo futures-util 0.3.34 future/::{selfrust-analyzer cargo futures-util 0.3.34 future/};
21 use futures_utilrust-analyzer cargo futures-util 0.3.34 crate/::FutureExtrust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#;
22 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::{Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#};
23 use tracingrust-analyzer cargo tracing 0.1.44 crate/::Levelrust-analyzer cargo tracing-core 0.1.36 metadata/Level#;
24
25 pub(craterust-analyzer cargo sqlx-core 0.8.3 crate/) struct PoolInnerrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#> {
26 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) connect_optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#connect_options.: RwLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/rwlock/RwLock#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<<DB::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection# as Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#>::Optionsrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#Options#>>,
27 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) idle_connsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#idle_conns.: ArrayQueuerust-analyzer cargo crossbeam-queue 0.3.13 array_queue/ArrayQueue#<Idlerust-analyzer cargo sqlx-core 0.8.3 pool/connection/Idle#<DB>>,
28 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore.: AsyncSemaphorerust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphore#,
29 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#size.: AtomicU32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU32#,
30 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) num_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#num_idle.: AtomicUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicUsize#,
31 is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#is_closed.: AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#,
32 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) on_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#on_closed.: event_listenerrust-analyzer cargo event-listener 5.4.2 crate/::Eventrust-analyzer cargo event-listener 5.4.2 Event#,
33 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options.: PoolOptionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#<DB>,
34 pub(craterust-analyzer cargo sqlx-core 0.8.3 crate/) acquire_time_levelrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#acquire_time_level.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Levelrust-analyzer cargo tracing-core 0.1.36 metadata/Level#>,
35 pub(craterust-analyzer cargo sqlx-core 0.8.3 crate/) acquire_slow_levelrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#acquire_slow_level.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Levelrust-analyzer cargo tracing-core 0.1.36 metadata/Level#>,
36 }
37
38 impl<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#> PoolInnerrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#<DB> {
39 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) fn new_arcrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]new_arc().(
40 options: PoolOptionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#<DB>,
41 connect_options: <DB::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection# as Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#>::Optionsrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#Options#,
42 ) -> Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]> {
43 let capacity = options.max_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#max_connections. as usize;
44
45 let semaphore_capacity = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent) = &options.parent_poolrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#parent_pool. {
46 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(options.max_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#max_connections. <= parent.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/impl#[`Pool<DB>`]options().().max_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#max_connections.);
47 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(options.fairrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#fair., parent.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/impl#[`Pool<DB>`]options().().fairrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#fair.);
48 // The child pool must steal permits from the parent
49 0
50 } else {
51 capacity
52 };
53
54 let pool = Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`] {
55 connect_optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#connect_options.: RwLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/rwlock/RwLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/rwlock/impl#[`RwLock<T>`]new().(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(connect_options)),
56 idle_connsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#idle_conns.: ArrayQueuerust-analyzer cargo crossbeam-queue 0.3.13 array_queue/ArrayQueue#::newrust-analyzer cargo crossbeam-queue 0.3.13 array_queue/impl#[`ArrayQueue<T>`]new().(capacity),
57 semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore.: AsyncSemaphorerust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphore#::newrust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]new().(options.fairrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#fair., semaphore_capacity),
58 sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#size.: AtomicU32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU32#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU32]new().(0),
59 num_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#num_idle.: AtomicUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicUsize#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicUsize]new().(0),
60 is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#is_closed.: AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicBool]new().(false),
61 on_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#on_closed.: event_listenerrust-analyzer cargo event-listener 5.4.2 crate/::Eventrust-analyzer cargo event-listener 5.4.2 Event#::newrust-analyzer cargo event-listener 5.4.2 impl#[Event]new().(),
62 acquire_time_levelrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#acquire_time_level.: private_level_filter_to_trace_levelrust-analyzer cargo sqlx-core 0.8.3 logger/private_level_filter_to_trace_level().(options.acquire_time_levelrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#acquire_time_level.),
63 acquire_slow_levelrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#acquire_slow_level.: private_level_filter_to_trace_levelrust-analyzer cargo sqlx-core 0.8.3 logger/private_level_filter_to_trace_level().(options.acquire_slow_levelrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#acquire_slow_level.),
64 optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options.,
65 };
66
67 let pool = Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(pool);
68
69 spawn_maintenance_tasksrust-analyzer cargo sqlx-core 0.8.3 pool/inner/spawn_maintenance_tasks().(&pool);
70
71 pool
72 }
73
74 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) fn sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]size().(&self) -> u32 {
75 self.sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#size..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU32]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Acquirerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Acquire#)
76 }
77
78 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) fn num_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]num_idle().(&self) -> usize {
79 // We don't use `self.idle_conns.len()` as it waits for the internal
80 // head and tail pointers to stop changing for a moment before calculating the length,
81 // which may take a long time at high levels of churn.
82 //
83 // By maintaining our own atomic count, we avoid that issue entirely.
84 self.num_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#num_idle..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicUsize]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Acquirerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Acquire#)
85 }
86
87 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) fn is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]is_closed().(&self) -> bool {
88 self.is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#is_closed..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicBool]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Acquirerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Acquire#)
89 }
90
91 fn mark_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]mark_closed().(&self) {
92 self.is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#is_closed..storerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicBool]store().(true, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Releaserust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Release#);
93 self.on_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#on_closed..notifyrust-analyzer cargo event-listener 5.4.2 impl#[`Event<T>`]notify().(usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX.);
94 }
95
96 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) fn closerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]close().<'a>(self: &'a Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]>) -> impl Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#Output# = ()> + 'a {
97 self.mark_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]mark_closed().();
98
99 async move {
100 for permits in 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..max_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#max_connections. {
101 // Close any currently idle connections in the pool.
102 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(idle) = self.idle_connsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#idle_conns..poprust-analyzer cargo crossbeam-queue 0.3.13 array_queue/impl#[`ArrayQueue<T>`]pop().() {
103 let _ = idle.liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/Idle#live..floatrust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Live<DB>`]float().((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().()).closerust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Live<DB>>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
104 }
105
106 if self.sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]size().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().0 {
107 break;
108 }
109
110 // Wait for all permits to be released.
111 let _permits = self.semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore..acquirerust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]acquire().(permits).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
112 }
113 }
114 }
115
116 pub(craterust-analyzer cargo sqlx-core 0.8.3 crate/) fn close_eventrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]close_event().(&self) -> CloseEventrust-analyzer cargo sqlx-core 0.8.3 pool/CloseEvent# {
117 CloseEventrust-analyzer cargo sqlx-core 0.8.3 pool/CloseEvent# {
118 listenerrust-analyzer cargo sqlx-core 0.8.3 pool/CloseEvent#listener.: (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]is_closed().()).thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| self.on_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#on_closed..listenrust-analyzer cargo event-listener 5.4.2 impl#[`Event<T>`]listen().()),
119 }
120 }
121
122 /// Attempt to pull a permit from `self.semaphore` or steal one from the parent.
123 ///
124 /// If we steal a permit from the parent but *don't* open a connection,
125 /// it should be returned to the parent.
126 async fn acquire_permitrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]acquire_permit().<'a>(self: &'a Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<AsyncSemaphoreReleaserrust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphoreReleaser#<'a>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
127 let parent = self
128 .parentrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]parent().()
129 // If we're already at the max size, we shouldn't try to steal from the parent.
130 // This is just going to cause unnecessary churn in `acquire()`.
131 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|_| self.sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]size().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]lt().self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..max_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#max_connections.);
132
133 let acquire_self = self.semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore..acquirerust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]acquire().(1).fuserust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#fuse().();
134 let mut close_event = self.close_eventrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]close_event().();
135
136 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent) = parent {
137 let acquire_parent = parent.0rust-analyzer cargo sqlx-core 0.8.3 pool/Pool#0..semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore..acquirerust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]acquire().(1);
138 let parent_close_event = parent.0rust-analyzer cargo sqlx-core 0.8.3 pool/Pool#0..close_eventrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]close_event().();
139
140 futures_utilrust-analyzer cargo futures-util 0.3.34 crate/::pin_mutrust-analyzer cargo futures-util 0.3.34 macros/pin_mut!!(
141 acquire_parent,
142 acquire_self,
143 close_event,
144 parent_close_event
145 );
146
147 let mut poll_parent = false;
148
149 futurerust-analyzer cargo futures-util 0.3.34 future/::poll_fnrust-analyzer cargo futures-util 0.3.34 future/poll_fn/poll_fn().(|cx| {
150 if close_event.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().().pollrust-analyzer cargo sqlx-core 0.8.3 pool/impl#[CloseEvent][Future]poll().(cx).is_readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/impl#[`Poll<T>`]is_ready().() {
151 return Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::PoolClosedrust-analyzer cargo sqlx-core 0.8.3 error/Error#PoolClosed#));
152 }
153
154 if parent_close_event.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().().pollrust-analyzer cargo sqlx-core 0.8.3 pool/impl#[CloseEvent][Future]poll().(cx).is_readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/impl#[`Poll<T>`]is_ready().() {
155 // Propagate the parent's close event to the child.
156 self.mark_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]mark_closed().();
157 return Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::PoolClosedrust-analyzer cargo sqlx-core 0.8.3 error/Error#PoolClosed#));
158 }
159
160 if let Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(permit) = acquire_self.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().().pollrust-analyzer cargo futures-util 0.3.34 future/future/fuse/impl#[`Fuse<Fut>`][Future]poll().(cx) {
161 return Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(permit));
162 }
163
164 // Don't try the parent right away.
165 if poll_parent {
166 acquire_parent.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().().pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().(cx).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/impl#[`Poll<T>`]map().(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#)
167 } else {
168 poll_parent = true;
169 cx.wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[`Context<'a>`]waker().().wake_by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[Waker]wake_by_ref().();
170 Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending#
171 }
172 })
173 .rust-analyzer cargo futures-util 0.3.34 future/poll_fn/impl#[`PollFn<F>`][Future]poll().awaitrust-analyzer cargo futures-util 0.3.34 future/poll_fn/impl#[`PollFn<F>`][Future]poll().
174 } else {
175 close_event.do_untilrust-analyzer cargo sqlx-core 0.8.3 pool/impl#[CloseEvent]do_until().(acquire_self).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
176 }
177 }
178
179 fn parentrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]parent().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Poolrust-analyzer cargo sqlx-core 0.8.3 pool/Pool#<DB>> {
180 self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..parent_poolrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#parent_pool..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
181 }
182
183 #[inline]
184 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) fn try_acquirerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]try_acquire().(self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#<DB, Idlerust-analyzer cargo sqlx-core 0.8.3 pool/connection/Idle#<DB>>> {
185 if self.is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]is_closed().() {
186 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
187 }
188
189 let permit = self.semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore..try_acquirerust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]try_acquire().(1)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
190
191 self.pop_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]pop_idle().(permit).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
192 }
193
194 fn pop_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]pop_idle().<'a>(
195 self: &'a Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]>,
196 permit: AsyncSemaphoreReleaserrust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphoreReleaser#<'a>,
197 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#<DB, Idlerust-analyzer cargo sqlx-core 0.8.3 pool/connection/Idle#<DB>>, AsyncSemaphoreReleaserrust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphoreReleaser#<'a>> {
198 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(idle) = self.idle_connsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#idle_conns..poprust-analyzer cargo crossbeam-queue 0.3.13 array_queue/impl#[`ArrayQueue<T>`]pop().() {
199 self.num_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#num_idle..fetch_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicUsize]fetch_sub().(1, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::AcqRelrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#AcqRel#);
200 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#::from_idlerust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Idle<DB>>`]from_idle().(idle, (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(), permit))
201 } else {
202 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(permit)
203 }
204 }
205
206 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) fn releaserust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]release().(&self, floating: Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#<DB, Liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/Live#<DB>>) {
207 // `options.after_release` and other checks are in `PoolConnection::return_to_pool()`.
208
209 let Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating# { innerrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#inner.: idle, guardrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#guard. } = floating.into_idlerust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Live<DB>>`]into_idle().();
210
211 if self.idle_connsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#idle_conns..pushrust-analyzer cargo crossbeam-queue 0.3.13 array_queue/impl#[`ArrayQueue<T>`]push().(idle).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() {
212 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("BUG: connection queue overflow in release()");
213 }
214
215 // NOTE: we need to make sure we drop the permit *after* we push to the idle queue
216 // don't decrease the size
217 guard.release_permitrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`]release_permit().();
218
219 self.num_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#num_idle..fetch_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicUsize]fetch_add().(1, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::AcqRelrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#AcqRel#);
220 }
221
222 /// Try to atomically increment the pool size for a new connection.
223 ///
224 /// Returns `Err` if the pool is at max capacity already or is closed.
225 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) fn try_increment_sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]try_increment_size().<'a>(
226 self: &'a Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]>,
227 permit: AsyncSemaphoreReleaserrust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphoreReleaser#<'a>,
228 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<DecrementSizeGuardrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#<DB>, AsyncSemaphoreReleaserrust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphoreReleaser#<'a>> {
229 let result = self
230 .sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#size.
231 .fetch_updaterust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU32]fetch_update().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::AcqRelrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#AcqRel#, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Acquirerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Acquire#, |size| {
232 if self.is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]is_closed().() {
233 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
234 }
235
236 size.checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]checked_add().(1)
237 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|size| size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]le().&self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..max_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#max_connections.)
238 });
239
240 match result {
241 // we successfully incremented the size
242 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(_) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(DecrementSizeGuardrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#::from_permitrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`]from_permit().((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(), permit)),
243 // the pool is at max capacity or is closed
244 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(permit),
245 }
246 }
247
248 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) async fn acquirerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]acquire().(self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#<DB, Liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/Live#<DB>>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
249 if self.is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]is_closed().() {
250 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::PoolClosedrust-analyzer cargo sqlx-core 0.8.3 error/Error#PoolClosed#);
251 }
252
253 let acquire_started_at = Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().();
254 let deadline = acquire_started_at rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant][`Add<Duration>`]add().+rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant][`Add<Duration>`]add(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant][`Add<Duration>`]add().self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..acquire_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#acquire_timeout.;
255
256 let acquired = craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::timeoutrust-analyzer cargo sqlx-core 0.8.3 rt/timeout().(
257 self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..acquire_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#acquire_timeout.,
258 async {
259 loop {
260 // Handles the close-event internally
261 let permit = self.acquire_permitrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]acquire_permit().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
262
263
264 // First attempt to pop a connection from the idle queue.
265 let guard = match self.pop_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]pop_idle().(permit) {
266
267 // Then, check that we can use it...
268 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(conn) => match check_idle_connrust-analyzer cargo sqlx-core 0.8.3 pool/inner/check_idle_conn().(conn, &self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). {
269
270 // All good!
271 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(live) => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(live),
272
273 // if the connection isn't usable for one reason or another,
274 // we get the `DecrementSizeGuard` back to open a new one
275 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(guard) => guard,
276 },
277 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(permit) => if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(guard) = self.try_increment_sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]try_increment_size().(permit) {
278 // we can open a new connection
279 guard
280 } else {
281 // This can happen for a child pool that's at its connection limit,
282 // or if the pool was closed between `acquire_permit()` and
283 // `try_increment_size()`.
284 tracingrust-analyzer cargo tracing 0.1.44 crate/::debugrust-analyzer cargo tracing 0.1.44 macros/debug!!("woke but was unable to acquire idle connection or open new one; retrying");
285 // If so, we're likely in the current-thread runtime if it's Tokio,
286 // and so we should yield to let any spawned return_to_pool() tasks
287 // execute.
288 craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::yield_nowrust-analyzer cargo sqlx-core 0.8.3 rt/yield_now().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
289 continue;
290 }
291 };
292
293 // Attempt to connect...
294 return self.connectrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]connect().(deadline, guard).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
295 }
296 }
297 )
298 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
299 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::PoolTimedOutrust-analyzer cargo sqlx-core 0.8.3 error/Error#PoolTimedOut#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
300
301 let acquired_after = acquire_started_at.elapsedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]elapsed().();
302
303 let acquire_slow_level = self
304 .acquire_slow_levelrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#acquire_slow_level.
305 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|_| acquired_after rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..acquire_slow_thresholdrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#acquire_slow_threshold.);
306
307 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(level) = acquire_slow_level {
308 private_tracing_dynamic_eventrust-analyzer cargo sqlx-core 0.8.3 logger/private_tracing_dynamic_event!!(
309 target: "sqlx::pool::acquire",
310 level,
311 aquired_after_secs = acquired_after.as_secs_f64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs_f64().(),
312 slow_acquire_threshold_secs = self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..acquire_slow_thresholdrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#acquire_slow_threshold..as_secs_f64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs_f64().(),
313 "acquired connection, but time to acquire exceeded slow threshold"
314 );
315 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(level) = self.acquire_time_levelrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#acquire_time_level. {
316 private_tracing_dynamic_eventrust-analyzer cargo sqlx-core 0.8.3 logger/private_tracing_dynamic_event!!(
317 target: "sqlx::pool::acquire",
318 level,
319 aquired_after_secs = acquired_after.as_secs_f64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs_f64().(),
320 "acquired connection"
321 );
322 }
323
324 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(acquired)
325 }
326
327 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) async fn connectrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]connect().(
328 self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]>,
329 deadline: Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#,
330 guard: DecrementSizeGuardrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#<DB>,
331 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#<DB, Liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/Live#<DB>>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
332 if self.is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]is_closed().() {
333 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::PoolClosedrust-analyzer cargo sqlx-core 0.8.3 error/Error#PoolClosed#);
334 }
335
336 let mut backoff = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(10);
337 let max_backoff = deadline_as_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/deadline_as_timeout().(deadline)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`Div<u32>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`Div<u32>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`Div<u32>`]div().5;
338
339 loop {
340 let timeout = deadline_as_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/deadline_as_timeout().(deadline)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
341
342 // clone the connect options arc so it can be used without holding the RwLockReadGuard
343 // across an async await point
344 let connect_options = self
345 .connect_optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#connect_options.
346 .readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/rwlock/impl#[`RwLock<T>`]read().()
347 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("write-lock holder panicked")
348 .clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().();
349
350 // result here is `Result<Result<C, Error>, TimeoutError>`
351 // if this block does not return, sleep for the backoff timeout and try again
352 match craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::timeoutrust-analyzer cargo sqlx-core 0.8.3 rt/timeout().(timeout, connect_options.connectrust-analyzer cargo sqlx-core 0.8.3 connection/ConnectOptions#connect().()).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). {
353 // successfully established connection
354 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(mut raw)) => {
355 // See comment on `PoolOptions::after_connect`
356 let meta = PoolConnectionMetadatarust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolConnectionMetadata# {
357 agerust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolConnectionMetadata#age.: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::ZEROrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]ZERO.,
358 idle_forrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolConnectionMetadata#idle_for.: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::ZEROrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]ZERO.,
359 };
360
361 let res = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(callback) = &self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..after_connectrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#after_connect. {
362 callback(&mut raw, meta).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().
363 } else {
364 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
365 };
366
367 match res {
368 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#::new_liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Live<DB>>`]new_live().(raw, guard)),
369 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => {
370 tracingrust-analyzer cargo tracing 0.1.44 crate/::errorrust-analyzer cargo tracing 0.1.44 macros/error!!(%error, "error returned from after_connect");
371 // The connection is broken, don't try to close nicely.
372 let _ = raw.close_hardrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#close_hard().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().;
373
374 // Fall through to the backoff.
375 }
376 }
377 }
378
379 // an IO error while connecting is assumed to be the system starting up
380 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Iorust-analyzer cargo sqlx-core 0.8.3 error/Error#Io#(e))) if e.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::ConnectionRefusedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#ConnectionRefused# => (),
381
382 // We got a transient database error, retry.
383 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Databaserust-analyzer cargo sqlx-core 0.8.3 error/Error#Database#(error))) if error.is_transient_in_connect_phaserust-analyzer cargo sqlx-core 0.8.3 error/DatabaseError#is_transient_in_connect_phase().() => (),
384
385 // Any other error while connection should immediately
386 // terminate and bubble the error up
387 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e)) => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e),
388
389 // timed out
390 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::PoolTimedOutrust-analyzer cargo sqlx-core 0.8.3 error/Error#PoolTimedOut#),
391 }
392
393 // If the connection is refused, wait in exponentially
394 // increasing steps for the server to come up,
395 // capped by a factor of the remaining time until the deadline
396 craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::sleeprust-analyzer cargo sqlx-core 0.8.3 rt/sleep().(backoff).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
397 backoff = cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(backoff rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`Mul<u32>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`Mul<u32>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`Mul<u32>`]mul().2, max_backoff);
398 }
399 }
400
401 /// Try to maintain `min_connections`, returning any errors (including `PoolTimedOut`).
402 pub async fn try_min_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]try_min_connections().(self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]>, deadline: Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
403 while self.sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]size().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]lt().self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..min_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#min_connections. {
404 // Don't wait for a semaphore permit.
405 //
406 // If no extra permits are available then we shouldn't be trying to spin up
407 // connections anyway.
408 let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(permit) = self.semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore..try_acquirerust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]try_acquire().(1) else {
409 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
410 };
411
412 // We must always obey `max_connections`.
413 let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(guard) = self.try_increment_sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]try_increment_size().(permit).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().() else {
414 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
415 };
416
417 // We skip `after_release` since the connection was never provided to user code
418 // besides `after_connect`, if they set it.
419 self.releaserust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]release().(self.connectrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]connect().(deadline, guard).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
420 }
421
422 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
423 }
424
425 /// Attempt to maintain `min_connections`, logging if unable.
426 pub async fn min_connections_maintenancerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]min_connections_maintenance().(self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]>, deadline: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#>) {
427 let deadline = deadline.unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| {
428 // Arbitrary default deadline if the caller doesn't care.
429 Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant][`Add<Duration>`]add().+rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant][`Add<Duration>`]add(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant][`Add<Duration>`]add().Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(300)
430 });
431
432 match self.try_min_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]try_min_connections().(deadline).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). {
433 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) => (),
434 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::PoolClosedrust-analyzer cargo sqlx-core 0.8.3 error/Error#PoolClosed#) => (),
435 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::PoolTimedOutrust-analyzer cargo sqlx-core 0.8.3 error/Error#PoolTimedOut#) => {
436 tracingrust-analyzer cargo tracing 0.1.44 crate/::debugrust-analyzer cargo tracing 0.1.44 macros/debug!!("unable to complete `min_connections` maintenance before deadline")
437 }
438 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => tracingrust-analyzer cargo tracing 0.1.44 crate/::debugrust-analyzer cargo tracing 0.1.44 macros/debug!!(%error, "error while maintaining min_connections"),
439 }
440 }
441 }
442
443 impl<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#> Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for PoolInnerrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#<DB> {
444 fn droprust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`][Drop]drop().(&mut self) {
445 self.mark_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]mark_closed().();
446
447 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent) = &self.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..parent_poolrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#parent_pool. {
448 // Release the stolen permits.
449 parent.0rust-analyzer cargo sqlx-core 0.8.3 pool/Pool#0..semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore..releaserust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]release().(self.semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore..permitsrust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]permits().());
450 }
451 }
452 }
453
454 /// Returns `true` if the connection has exceeded `options.max_lifetime` if set, `false` otherwise.
455 pub(superrust-analyzer cargo sqlx-core 0.8.3 pool/) fn is_beyond_max_lifetimerust-analyzer cargo sqlx-core 0.8.3 pool/inner/is_beyond_max_lifetime().<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>(
456 live: &Liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/Live#<DB>,
457 options: &PoolOptionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#<DB>,
458 ) -> bool {
459 options
460 .max_lifetimerust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#max_lifetime.
461 .map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(false, |max| live.created_atrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Live#created_at..elapsedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]elapsed().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().max)
462 }
463
464 /// Returns `true` if the connection has exceeded `options.idle_timeout` if set, `false` otherwise.
465 fn is_beyond_idle_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/inner/is_beyond_idle_timeout().<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>(idle: &Idlerust-analyzer cargo sqlx-core 0.8.3 pool/connection/Idle#<DB>, options: &PoolOptionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#<DB>) -> bool {
466 options
467 .idle_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#idle_timeout.
468 .map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(false, |timeout| idle.idle_sincerust-analyzer cargo sqlx-core 0.8.3 pool/connection/Idle#idle_since..elapsedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]elapsed().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().timeout)
469 }
470
471 async fn check_idle_connrust-analyzer cargo sqlx-core 0.8.3 pool/inner/check_idle_conn().<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>(
472 mut conn: Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#<DB, Idlerust-analyzer cargo sqlx-core 0.8.3 pool/connection/Idle#<DB>>,
473 options: &PoolOptionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#<DB>,
474 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Floatingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Floating#<DB, Liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/Live#<DB>>, DecrementSizeGuardrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#<DB>> {
475 if options.test_before_acquirerust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#test_before_acquire. {
476 // Check that the connection is still live
477 if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) = conn.pingrust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Idle<DB>>`]ping().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). {
478 // an error here means the other end has hung up or we lost connectivity
479 // either way we're fine to just discard the connection
480 // the error itself here isn't necessarily unexpected so WARN is too strong
481 tracingrust-analyzer cargo tracing 0.1.44 crate/::inforust-analyzer cargo tracing 0.1.44 macros/info!!(%error, "ping on idle connection returned error");
482 // connection is broken so don't try to close nicely
483 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(conn.close_hardrust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Idle<DB>>`]close_hard().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().);
484 }
485 }
486
487 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(test) = &options.before_acquirerust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#before_acquire. {
488 let meta = conn.metadatarust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Idle<DB>>`]metadata().();
489 match test(&mut conn.liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/Idle#live..rawrust-analyzer cargo sqlx-core 0.8.3 pool/connection/Live#raw., meta).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll(). {
490 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false) => {
491 // connection was rejected by user-defined hook, close nicely
492 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(conn.closerust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Idle<DB>>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().);
493 }
494
495 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => {
496 tracingrust-analyzer cargo tracing 0.1.44 crate/::warnrust-analyzer cargo tracing 0.1.44 macros/warn!!(%error, "error from `before_acquire`");
497 // connection is broken so don't try to close nicely
498 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(conn.close_hardrust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Idle<DB>>`]close_hard().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().);
499 }
500
501 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true) => {}
502 }
503 }
504
505 // No need to re-connect; connection is alive or we don't care
506 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(conn.into_liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Idle<DB>>`]into_live().())
507 }
508
509 fn spawn_maintenance_tasksrust-analyzer cargo sqlx-core 0.8.3 pool/inner/spawn_maintenance_tasks().<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>(pool: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<PoolInnerrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#<DB>>) {
510 // NOTE: use `pool_weak` for the maintenance tasks
511 // so they don't keep `PoolInner` from being dropped.
512 let pool_weak = Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::downgraderust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]downgrade().(pool);
513
514 let period = match (pool.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..max_lifetimerust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#max_lifetime., pool.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..idle_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#idle_timeout.) {
515 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(it), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(it)) => it,
516
517 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(a), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b)) => cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(a, b),
518
519 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => {
520 if pool.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options..min_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#min_connections. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().0 {
521 craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::spawnrust-analyzer cargo sqlx-core 0.8.3 rt/spawn().(async move {
522 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pool) = pool_weak.upgraderust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Weak<T, A>`]upgrade().() {
523 pool.min_connections_maintenancerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]min_connections_maintenance().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
524 }
525 });
526 }
527
528 return;
529 }
530 };
531
532 // Immediately cancel this task if the pool is closed.
533 let mut close_event = pool.close_eventrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]close_event().();
534
535 craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::spawnrust-analyzer cargo sqlx-core 0.8.3 rt/spawn().(async move {
536 let _ = close_event
537 .do_untilrust-analyzer cargo sqlx-core 0.8.3 pool/impl#[CloseEvent]do_until().(async {
538 // If the last handle to the pool was dropped while we were sleeping
539 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pool) = pool_weak.upgraderust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Weak<T, A>`]upgrade().() {
540 if pool.is_closedrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]is_closed().() {
541 return;
542 }
543
544 let next_run = Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant][`Add<Duration>`]add().+rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant][`Add<Duration>`]add(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant][`Add<Duration>`]add().period;
545
546 // Go over all idle connections, check for idleness and lifetime,
547 // and if we have fewer than min_connections after reaping a connection,
548 // open a new one immediately. Note that other connections may be popped from
549 // the queue in the meantime - that's fine, there is no harm in checking more
550 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#pool.num_idlerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]num_idle().() {
551 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(conn) = pool.try_acquirerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]try_acquire().() {
552 if is_beyond_idle_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/inner/is_beyond_idle_timeout().(&conn, &pool.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options.)
553 || is_beyond_max_lifetimerust-analyzer cargo sqlx-core 0.8.3 pool/inner/is_beyond_max_lifetime().(&conn, &pool.optionsrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#options.)
554 {
555 let _ = conn.closerust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Idle<DB>>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
556 pool.min_connections_maintenancerust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]min_connections_maintenance().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(next_run)).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
557 } else {
558 pool.releaserust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`PoolInner<DB>`]release().(conn.into_liverust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`Floating<DB, Idle<DB>>`]into_live().());
559 }
560 }
561 }
562
563 // Don't hold a reference to the pool while sleeping.
564 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(pool);
565
566 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(duration) = next_run.checked_duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]checked_duration_since().(Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().()) {
567 // `async-std` doesn't have a `sleep_until()`
568 craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::sleeprust-analyzer cargo sqlx-core 0.8.3 rt/sleep().(duration).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
569 } else {
570 // `next_run` is in the past, just yield.
571 craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::yield_nowrust-analyzer cargo sqlx-core 0.8.3 rt/yield_now().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
572 }
573 }
574 })
575 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
576 });
577 }
578
579 /// RAII guard returned by `Pool::try_increment_size()` and others.
580 ///
581 /// Will decrement the pool size if dropped, to avoid semantically "leaking" connections
582 /// (where the pool thinks it has more connections than it does).
583 pub(in craterust-analyzer cargo sqlx-core 0.8.3 crate/::poolrust-analyzer cargo sqlx-core 0.8.3 pool/) struct DecrementSizeGuardrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#> {
584 pub(craterust-analyzer cargo sqlx-core 0.8.3 crate/) poolrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#pool.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<PoolInnerrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#<DB>>,
585 cancelledrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#cancelled.: bool,
586 }
587
588 impl<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#> DecrementSizeGuardrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#<DB> {
589 /// Create a new guard that will release a semaphore permit on-drop.
590 pub fn new_permitrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`]new_permit().(pool: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<PoolInnerrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#<DB>>) -> Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`] {
591 Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`] {
592 poolrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#pool.,
593 cancelledrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#cancelled.: false,
594 }
595 }
596
597 pub fn from_permitrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`]from_permit().(pool: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<PoolInnerrust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#<DB>>, permit: AsyncSemaphoreReleaserrust-analyzer cargo sqlx-core 0.8.3 sync/AsyncSemaphoreReleaser#<'_>) -> Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`] {
598 // here we effectively take ownership of the permit
599 permit.disarmrust-analyzer cargo sqlx-core 0.8.3 sync/impl#[`AsyncSemaphoreReleaser<'_>`]disarm().();
600 Selfrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`]::new_permitrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`]new_permit().(pool)
601 }
602
603 /// Release the semaphore permit without decreasing the pool size.
604 ///
605 /// If the permit was stolen from the pool's parent, it will be returned to the child's semaphore.
606 fn release_permitrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`]release_permit().(self) {
607 self.poolrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#pool..semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore..releaserust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]release().(1);
608 self.cancelrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`]cancel().();
609 }
610
611 pub fn cancelrust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`]cancel().(mut self) {
612 self.cancelledrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#cancelled. = true;
613 }
614 }
615
616 impl<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#> Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for DecrementSizeGuardrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#<DB> {
617 fn droprust-analyzer cargo sqlx-core 0.8.3 pool/inner/impl#[`DecrementSizeGuard<DB>`][Drop]drop().(&mut self) {
618 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.cancelledrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#cancelled. {
619 self.poolrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#pool..sizerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#size..fetch_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU32]fetch_sub().(1, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::AcqRelrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#AcqRel#);
620
621 // and here we release the permit we got on construction
622 self.poolrust-analyzer cargo sqlx-core 0.8.3 pool/inner/DecrementSizeGuard#pool..semaphorerust-analyzer cargo sqlx-core 0.8.3 pool/inner/PoolInner#semaphore..releaserust-analyzer cargo sqlx-core 0.8.3 sync/impl#[AsyncSemaphore]release().(1);
623 }
624 }
625 }