diff --git a/Cargo.lock b/Cargo.lock index 67511fa5..3ce66f8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ dependencies = [ "futures-channel", "futures-util", "smallvec", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -48,12 +48,13 @@ checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" [[package]] name = "ahash" -version = "0.5.10" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19fac972e53443ba111b1ff866e9d3b6484df5c05030e13bc7c6a1ebc802e983" +checksum = "a75b7e6a93ecd6dbd2c225154d0fa7f86205574ecaa6c87429fb5f66ee677c44" dependencies = [ "getrandom 0.2.0", "lazy_static", + "version_check", ] [[package]] @@ -193,9 +194,9 @@ dependencies = [ [[package]] name = "async-rustls" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f38092e8f467f47aadaff680903c7cbfeee7926b058d7f40af2dd4c878fbdee" +checksum = "9c86f33abd5a4f3e2d6d9251a9e0c6a7e52eb1113caf893dae8429bf4a53f378" dependencies = [ "futures-lite", "rustls", @@ -215,7 +216,7 @@ dependencies = [ "async-mutex", "async-process", "blocking", - "crossbeam-utils 0.8.1", + "crossbeam-utils", "futures-channel", "futures-core", "futures-io", @@ -251,9 +252,9 @@ dependencies = [ [[package]] name = "atoi" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c897df197d57c25b37df9d8fa2f93ddbfeee9ebd2264350ac79c8ec4b795885" +checksum = "616896e05fc0e2649463a93a15183c6a16bf03413a7af88ef1285ddedfa9cda5" dependencies = [ "num-traits", ] @@ -293,12 +294,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - [[package]] name = "base64" version = "0.13.0" @@ -426,6 +421,12 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +[[package]] +name = "bytes" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0dcbc35f504eb6fc275a6d20e4ebcda18cf50d40ba6fabff8c711fa16cb3b16" + [[package]] name = "cache-padded" version = "1.1.1" @@ -667,16 +668,6 @@ dependencies = [ "itertools", ] -[[package]] -name = "crossbeam-channel" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" -dependencies = [ - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - [[package]] name = "crossbeam-channel" version = "0.5.0" @@ -684,7 +675,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.1", + "crossbeam-utils", ] [[package]] @@ -695,7 +686,7 @@ checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", - "crossbeam-utils 0.8.1", + "crossbeam-utils", ] [[package]] @@ -706,7 +697,7 @@ checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", - "crossbeam-utils 0.8.1", + "crossbeam-utils", "lazy_static", "memoffset", "scopeguard", @@ -714,24 +705,12 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.2.3" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +checksum = "0f6cb3c7f5b8e51bc3ebb73a2327ad4abdbd119dc13223f14f961d2f38486756" dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg 1.0.1", - "cfg-if 0.1.10", - "lazy_static", + "cfg-if 1.0.0", + "crossbeam-utils", ] [[package]] @@ -747,9 +726,9 @@ dependencies = [ [[package]] name = "crypto-mac" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bcd97a54c7ca5ce2f6eb16f6bede5b0ab5f0055fedc17d2f0b4466e21671ca" +checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" dependencies = [ "generic-array 0.14.4", "subtle", @@ -1201,9 +1180,9 @@ checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" [[package]] name = "hmac" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deae6d9dbb35ec2c502d62b8f7b1c000a0822c3b0794ba36b3149c0a1c840dff" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest 0.9.0", @@ -1429,12 +1408,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "md-5" version = "0.9.1" @@ -1833,7 +1806,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c220d01f863d13d96ca82359d1e81e64a7c6bf0637bcde7b2349630addf0c6" dependencies = [ - "base64 0.13.0", + "base64", "once_cell", "regex", ] @@ -2116,9 +2089,9 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ - "crossbeam-channel 0.5.0", + "crossbeam-channel", "crossbeam-deque", - "crossbeam-utils 0.8.1", + "crossbeam-utils", "lazy_static", "num_cpus", ] @@ -2235,11 +2208,11 @@ dependencies = [ [[package]] name = "rustls" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" +checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b" dependencies = [ - "base64 0.12.3", + "base64", "log", "ring", "sct", @@ -2521,7 +2494,7 @@ dependencies = [ "sqlx-rt", "sqlx-test", "time 0.2.23", - "tokio", + "tokio 0.2.24", "trybuild", "url", ] @@ -2556,7 +2529,7 @@ dependencies = [ "serde", "serde_json", "sqlx", - "tokio", + "tokio 0.2.24", "url", ] @@ -2564,20 +2537,20 @@ dependencies = [ name = "sqlx-core" version = "0.4.0" dependencies = [ - "ahash 0.5.10", + "ahash 0.6.2", "atoi", - "base64 0.13.0", + "base64", "bigdecimal", "bit-vec", "bitflags", "bstr", "byteorder", - "bytes", + "bytes 0.6.0", "chrono", "crc", - "crossbeam-channel 0.4.4", + "crossbeam-channel", "crossbeam-queue", - "crossbeam-utils 0.7.2", + "crossbeam-utils", "digest 0.9.0", "either", "encoding_rs", @@ -2716,7 +2689,7 @@ dependencies = [ "async-std", "native-tls", "once_cell", - "tokio", + "tokio 0.2.24", "tokio-native-tls", "tokio-rustls", ] @@ -2730,7 +2703,7 @@ dependencies = [ "dotenv", "env_logger", "sqlx", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -3057,7 +3030,7 @@ version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "futures-core", "iovec", @@ -3075,6 +3048,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "tokio" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "720ba21c25078711bf456d607987d95bce90f7c3bea5abe1db587862e7a1e87c" +dependencies = [ + "autocfg 1.0.1", + "pin-project-lite 0.2.0", +] + [[package]] name = "tokio-macros" version = "0.2.6" @@ -3088,23 +3071,22 @@ dependencies = [ [[package]] name = "tokio-native-tls" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd608593a919a8e05a7d1fc6df885e40f6a88d3a70a3a7eff23ff27964eda069" +checksum = "501c8252b73bd01379aaae1521523c2629ff1bc6ea46c29e0baff515cee60f1b" dependencies = [ "native-tls", - "tokio", + "tokio 0.3.6", ] [[package]] name = "tokio-rustls" -version = "0.14.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" +checksum = "609ada6f5bf21315925c6e43d78dc51fba5c5968a995f95345b4781cc06f37eb" dependencies = [ - "futures-core", "rustls", - "tokio", + "tokio 0.3.6", "webpki", ] @@ -3356,9 +3338,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f20dea7535251981a9670857150d571846545088359b28e4951d350bdaf179f" +checksum = "82015b7e0b8bad8185994674a13a93306bea76cf5a16c5a181382fd3a5ec2376" dependencies = [ "webpki", ] diff --git a/sqlx-core/Cargo.toml b/sqlx-core/Cargo.toml index c65c2f6d..37072adf 100644 --- a/sqlx-core/Cargo.toml +++ b/sqlx-core/Cargo.toml @@ -53,30 +53,30 @@ _tls-rustls = [ "rustls", "webpki", "webpki-roots" ] offline = [ "serde", "either/serde" ] [dependencies] -ahash = "0.5" -atoi = "0.3.2" +ahash = "0.6.2" +atoi = "0.4.0" sqlx-rt = { path = "../sqlx-rt", version = "0.2.0" } base64 = { version = "0.13.0", default-features = false, optional = true, features = [ "std" ] } bigdecimal_ = { version = "0.2.0", optional = true, package = "bigdecimal" } -rust_decimal = { version = "1.7.0", optional = true } +rust_decimal = { version = "1.8.1", optional = true } bit-vec = { version = "0.6.2", optional = true } bitflags = { version = "1.2.1", default-features = false } -bytes = "0.5.4" +bytes = "0.6.0" byteorder = { version = "1.3.4", default-features = false, features = [ "std" ] } chrono = { version = "0.4.11", default-features = false, features = [ "clock" ], optional = true } crc = { version = "1.8.1", optional = true } -crossbeam-queue = "0.2.1" -crossbeam-channel = "0.4.2" -crossbeam-utils = { version = "0.7.2", default-features = false } +crossbeam-queue = "0.3.1" +crossbeam-channel = "0.5.0" +crossbeam-utils = { version = "0.8.1", default-features = false } digest = { version = "0.9.0", default-features = false, optional = true, features = [ "std" ] } encoding_rs = { version = "0.8.23", optional = true } either = "1.5.3" futures-channel = { version = "0.3.5", default-features = false, features = [ "sink", "alloc", "std" ] } futures-core = { version = "0.3.5", default-features = false } futures-util = { version = "0.3.5", features = [ "sink" ] } -generic-array = { version = "0.14.2", default-features = false, optional = true } +generic-array = { version = "0.14.4", default-features = false, optional = true } hex = "0.4.2" -hmac = { version = "0.9.0", default-features = false, optional = true } +hmac = { version = "0.10.1", default-features = false, optional = true } itoa = "0.4.5" ipnetwork = { version = "0.17.0", default-features = false, optional = true } libc = "0.2.71" @@ -84,14 +84,14 @@ libsqlite3-sys = { version = "0.20.1", optional = true, default-features = false log = { version = "0.4.8", default-features = false } md-5 = { version = "0.9.0", default-features = false, optional = true } memchr = { version = "2.3.3", default-features = false } -num-bigint = { version = "0.3.0", default-features = false, optional = true, features = [ "std" ] } -once_cell = "1.4.0" +num-bigint = { version = "0.3.1", default-features = false, optional = true, features = [ "std" ] } +once_cell = "1.5.2" percent-encoding = "2.1.0" parking_lot = "0.11.0" rand = { version = "0.7.3", default-features = false, optional = true, features = [ "std" ] } regex = { version = "1.3.9", optional = true } rsa = { version = "0.3.0", optional = true } -rustls = { version = "0.18.1", features = [ "dangerous_configuration" ], optional = true } +rustls = { version = "0.19.0", features = [ "dangerous_configuration" ], optional = true } serde = { version = "1.0.106", features = [ "derive", "rc" ], optional = true } serde_json = { version = "1.0.51", features = [ "raw_value" ], optional = true } sha-1 = { version = "0.9.0", default-features = false, optional = true } @@ -103,7 +103,7 @@ smallvec = "1.4.0" url = { version = "2.1.1", default-features = false } uuid = { version = "0.8.1", default-features = false, optional = true, features = [ "std" ] } webpki = { version = "0.21.3", optional = true } -webpki-roots = { version = "0.20.0", optional = true } +webpki-roots = { version = "0.21.0", optional = true } whoami = "1.0.1" stringprep = "0.1.2" bstr = { version = "0.2.14", default-features = false, features = [ "std" ], optional = true } diff --git a/sqlx-core/src/connection.rs b/sqlx-core/src/connection.rs index 28d8f188..a7d1438d 100644 --- a/sqlx-core/src/connection.rs +++ b/sqlx-core/src/connection.rs @@ -2,7 +2,6 @@ use crate::database::{Database, HasStatementCache}; use crate::error::Error; use crate::transaction::Transaction; use futures_core::future::BoxFuture; -use futures_core::Future; use log::LevelFilter; use std::fmt::Debug; use std::str::FromStr; @@ -51,9 +50,9 @@ pub trait Connection: Send { /// })).await /// # } /// ``` - fn transaction(&mut self, callback: F) -> BoxFuture> + fn transaction(&mut self, callback: F) -> BoxFuture<'_, Result> where - for<'c> F: FnOnce(&'c mut Transaction) -> BoxFuture<'c, Result> + for<'c> F: FnOnce(&'c mut Transaction<'_, Self::Database>) -> BoxFuture<'c, Result> + 'static + Send + Sync, diff --git a/sqlx-core/src/mysql/connection/auth.rs b/sqlx-core/src/mysql/connection/auth.rs index 1de59d51..3e625c1c 100644 --- a/sqlx-core/src/mysql/connection/auth.rs +++ b/sqlx-core/src/mysql/connection/auth.rs @@ -1,4 +1,4 @@ -use bytes::buf::ext::Chain; +use bytes::buf::Chain; use bytes::Bytes; use digest::{Digest, FixedOutput}; use generic_array::GenericArray; diff --git a/sqlx-core/src/mysql/connection/establish.rs b/sqlx-core/src/mysql/connection/establish.rs index f5549b60..0018227a 100644 --- a/sqlx-core/src/mysql/connection/establish.rs +++ b/sqlx-core/src/mysql/connection/establish.rs @@ -8,7 +8,7 @@ use crate::mysql::protocol::connect::{ }; use crate::mysql::protocol::Capabilities; use crate::mysql::{MySqlConnectOptions, MySqlConnection, MySqlSslMode}; -use bytes::buf::BufExt; +use bytes::buf::Buf as _; impl MySqlConnection { pub(crate) async fn establish(options: &MySqlConnectOptions) -> Result { diff --git a/sqlx-core/src/mysql/protocol/connect/handshake.rs b/sqlx-core/src/mysql/protocol/connect/handshake.rs index d4f6f48c..4a247033 100644 --- a/sqlx-core/src/mysql/protocol/connect/handshake.rs +++ b/sqlx-core/src/mysql/protocol/connect/handshake.rs @@ -1,5 +1,4 @@ -use bytes::buf::ext::Chain; -use bytes::buf::BufExt as _; +use bytes::buf::Chain; use bytes::{Buf, Bytes}; use crate::error::Error; diff --git a/sqlx-core/src/pool/inner.rs b/sqlx-core/src/pool/inner.rs index 8e128659..11f765f6 100644 --- a/sqlx-core/src/pool/inner.rs +++ b/sqlx-core/src/pool/inner.rs @@ -41,13 +41,13 @@ impl SharedPool { pub(super) async fn close(&self) { self.is_closed.store(true, Ordering::Release); - while let Ok(waker) = self.waiters.pop() { + while let Some(waker) = self.waiters.pop() { waker.wake(); } // ensure we wait until the pool is actually closed while self.size() > 0 { - if let Ok(idle) = self.idle_conns.pop() { + if let Some(idle) = self.idle_conns.pop() { if let Err(e) = Floating::from_idle(idle, self).close().await { log::warn!("error occurred while closing the pool connection: {}", e); } @@ -72,7 +72,7 @@ impl SharedPool { return None; } - Some(Floating::from_idle(self.idle_conns.pop().ok()?, self)) + Some(Floating::from_idle(self.idle_conns.pop()?, self)) } pub(super) fn release(&self, mut floating: Floating<'_, Live>) { @@ -83,11 +83,16 @@ impl SharedPool { } } - self.idle_conns + let is_ok = self + .idle_conns .push(floating.into_idle().into_leakable()) - .expect("BUG: connection queue overflow in release()"); + .is_ok(); - if let Ok(waker) = self.waiters.pop() { + if !is_ok { + panic!("BUG: connection queue overflow in release()"); + } + + if let Some(waker) = self.waiters.pop() { waker.wake(); } } @@ -331,9 +336,11 @@ fn spawn_reaper(pool: &Arc>) { for conn in keep { // return these connections to the pool first - pool.idle_conns - .push(conn.into_leakable()) - .expect("BUG: connection queue overflow in spawn_reaper"); + let is_ok = pool.idle_conns.push(conn.into_leakable()).is_ok(); + + if !is_ok { + panic!("BUG: connection queue overflow in spawn_reaper"); + } } for conn in reap { @@ -379,7 +386,7 @@ impl Drop for DecrementSizeGuard<'_> { assert!(!self.dropped, "double-dropped!"); self.dropped = true; self.size.fetch_sub(1, Ordering::SeqCst); - if let Ok(waker) = self.waiters.pop() { + if let Some(waker) = self.waiters.pop() { waker.wake(); } } diff --git a/sqlx-core/src/pool/options.rs b/sqlx-core/src/pool/options.rs index ff12968d..fb89d99b 100644 --- a/sqlx-core/src/pool/options.rs +++ b/sqlx-core/src/pool/options.rs @@ -238,9 +238,14 @@ async fn init_min_connections(pool: &SharedPool) -> Result<(), // [connect] will raise an error when past deadline // [connect] returns None if its okay to retry if let Some(conn) = pool.connection(deadline, guard).await? { - pool.idle_conns + let is_ok = pool + .idle_conns .push(conn.into_idle().into_leakable()) - .expect("BUG: connection queue overflow in init_min_connections"); + .is_ok(); + + if !is_ok { + panic!("BUG: connection queue overflow in init_min_connections"); + } } } } diff --git a/sqlx-rt/Cargo.toml b/sqlx-rt/Cargo.toml index 9754ef95..447a5fcb 100644 --- a/sqlx-rt/Cargo.toml +++ b/sqlx-rt/Cargo.toml @@ -28,12 +28,12 @@ _tls-rustls = [ ] [dependencies] async-native-tls = { version = "0.3.3", optional = true } -async-rustls = { version = "0.1.1", optional = true } +async-rustls = { version = "0.2.0", optional = true } actix-rt = { version = "1.1.1", optional = true } actix-threadpool = { version = "0.3.2", optional = true } async-std = { version = "1.6.5", features = [ "unstable" ], optional = true } tokio = { version = "0.2.21", optional = true, features = [ "blocking", "stream", "fs", "tcp", "uds", "macros", "rt-core", "rt-threaded", "time", "dns", "io-util" ] } -tokio-native-tls = { version = "0.1.0", optional = true } -tokio-rustls = { version = "0.14.0", optional = true } +tokio-native-tls = { version = "0.2.0", optional = true } +tokio-rustls = { version = "0.21.1", optional = true } native-tls = { version = "0.2.4", optional = true } once_cell = { version = "1.4", features = ["std"], optional = true }