From 9a803817bedb6b1077697bdb2869d4bf585cc15c Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Mon, 16 Aug 2021 17:23:31 -0700 Subject: [PATCH 1/4] fix(pool): reenable connection reaper --- sqlx-core/src/pool/inner.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sqlx-core/src/pool/inner.rs b/sqlx-core/src/pool/inner.rs index e297537e36..9572eb85c3 100644 --- a/sqlx-core/src/pool/inner.rs +++ b/sqlx-core/src/pool/inner.rs @@ -322,16 +322,16 @@ fn spawn_reaper(pool: &Arc>) { (None, None) => return, }; - // let pool = Arc::clone(&pool); - // - // sqlx_rt::spawn(async move { - // while !pool.is_closed() { - // if !pool.idle_conns.is_empty() { - // do_reap(&pool).await; - // } - // sqlx_rt::sleep(period).await; - // } - // }); + let pool = Arc::clone(&pool); + + sqlx_rt::spawn(async move { + while !pool.is_closed() { + if !pool.idle_conns.is_empty() { + do_reap(&pool).await; + } + sqlx_rt::sleep(period).await; + } + }); } async fn do_reap(pool: &SharedPool) { From 09ef6eeade927fb31e8b904de476c5a5c4eb116f Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Mon, 16 Aug 2021 17:29:55 -0700 Subject: [PATCH 2/4] fix warnings --- sqlx-core/src/pool/connection.rs | 7 ------- sqlx-core/src/pool/inner.rs | 12 ++++++------ sqlx-core/src/postgres/types/money.rs | 3 ++- sqlx-core/src/sqlite/statement/handle.rs | 7 +++---- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/sqlx-core/src/pool/connection.rs b/sqlx-core/src/pool/connection.rs index 415fd0c1ec..ea31990abc 100644 --- a/sqlx-core/src/pool/connection.rs +++ b/sqlx-core/src/pool/connection.rs @@ -132,13 +132,6 @@ impl DerefMut for Idle { } } -impl<'s, C> Floating<'s, C> { - pub fn into_leakable(self) -> C { - self.guard.cancel(); - self.inner - } -} - impl<'s, DB: Database> Floating<'s, Live> { pub fn new_live(conn: DB::Connection, guard: DecrementSizeGuard<'s>) -> Self { Self { diff --git a/sqlx-core/src/pool/inner.rs b/sqlx-core/src/pool/inner.rs index 9572eb85c3..d67cdfc0f1 100644 --- a/sqlx-core/src/pool/inner.rs +++ b/sqlx-core/src/pool/inner.rs @@ -4,16 +4,16 @@ use crate::connection::Connection; use crate::database::Database; use crate::error::Error; use crate::pool::{deadline_as_timeout, PoolOptions}; -use crossbeam_queue::{ArrayQueue, SegQueue}; -use futures_core::task::{Poll, Waker}; +use crossbeam_queue::ArrayQueue; + use futures_intrusive::sync::{Semaphore, SemaphoreReleaser}; -use futures_util::future; + use std::cmp; use std::mem; use std::ptr; use std::sync::atomic::{AtomicBool, AtomicU32, Ordering}; -use std::sync::{Arc, Weak}; -use std::task::Context; +use std::sync::Arc; + use std::time::{Duration, Instant}; /// Ihe number of permits to release to wake all waiters, such as on `SharedPool::close()`. @@ -90,7 +90,7 @@ impl SharedPool { .await; while let Some(idle) = self.idle_conns.pop() { - idle.live.float(self).close().await; + let _ = idle.live.float(self).close().await; } } diff --git a/sqlx-core/src/postgres/types/money.rs b/sqlx-core/src/postgres/types/money.rs index 9b9178bbe0..f327726710 100644 --- a/sqlx-core/src/postgres/types/money.rs +++ b/sqlx-core/src/postgres/types/money.rs @@ -6,7 +6,6 @@ use crate::{ types::Type, }; use byteorder::{BigEndian, ByteOrder}; -use std::convert::TryFrom; use std::{ io, ops::{Add, AddAssign, Sub, SubAssign}, @@ -97,6 +96,8 @@ impl PgMoney { /// [`Decimal`]: crate::types::Decimal #[cfg(feature = "decimal")] pub fn from_decimal(mut decimal: rust_decimal::Decimal, locale_frac_digits: u32) -> Self { + use std::convert::TryFrom; + // this is all we need to convert to our expected locale's `frac_digits` decimal.rescale(locale_frac_digits); diff --git a/sqlx-core/src/sqlite/statement/handle.rs b/sqlx-core/src/sqlite/statement/handle.rs index e796d48c5b..78f2ff2abc 100644 --- a/sqlx-core/src/sqlite/statement/handle.rs +++ b/sqlx-core/src/sqlite/statement/handle.rs @@ -14,10 +14,9 @@ use libsqlite3_sys::{ sqlite3_column_bytes, sqlite3_column_count, sqlite3_column_database_name, sqlite3_column_decltype, sqlite3_column_double, sqlite3_column_int, sqlite3_column_int64, sqlite3_column_name, sqlite3_column_origin_name, sqlite3_column_table_name, - sqlite3_column_type, sqlite3_column_value, sqlite3_db_handle, sqlite3_finalize, sqlite3_reset, - sqlite3_sql, sqlite3_step, sqlite3_stmt, sqlite3_stmt_readonly, sqlite3_table_column_metadata, - sqlite3_value, SQLITE_DONE, SQLITE_MISUSE, SQLITE_OK, SQLITE_ROW, SQLITE_TRANSIENT, - SQLITE_UTF8, + sqlite3_column_type, sqlite3_column_value, sqlite3_db_handle, sqlite3_finalize, sqlite3_sql, + sqlite3_stmt, sqlite3_stmt_readonly, sqlite3_table_column_metadata, sqlite3_value, + SQLITE_MISUSE, SQLITE_OK, SQLITE_TRANSIENT, SQLITE_UTF8, }; use crate::error::{BoxDynError, Error}; From e9faac24a6d9ab67bddf2f420a74ce9257252934 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Mon, 16 Aug 2021 17:55:17 -0700 Subject: [PATCH 3/4] chore: bump published crates to 0.5.6 --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- sqlx-cli/Cargo.toml | 2 +- sqlx-core/Cargo.toml | 2 +- sqlx-macros/Cargo.toml | 2 +- sqlx-rt/Cargo.toml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7426ac7f8..b97c1d28cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2290,7 +2290,7 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.5.5" +version = "0.5.6" dependencies = [ "anyhow", "async-std", @@ -2323,7 +2323,7 @@ dependencies = [ [[package]] name = "sqlx-cli" -version = "0.5.5" +version = "0.5.6" dependencies = [ "anyhow", "async-trait", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.5.5" +version = "0.5.6" dependencies = [ "ahash", "atoi", @@ -2482,7 +2482,7 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.5.5" +version = "0.5.6" dependencies = [ "dotenv", "either", @@ -2503,7 +2503,7 @@ dependencies = [ [[package]] name = "sqlx-rt" -version = "0.5.5" +version = "0.5.6" dependencies = [ "actix-rt", "async-native-tls", diff --git a/Cargo.toml b/Cargo.toml index f5928be8b4..b533434bdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ members = [ [package] name = "sqlx" -version = "0.5.5" +version = "0.5.6" license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/launchbadge/sqlx" diff --git a/sqlx-cli/Cargo.toml b/sqlx-cli/Cargo.toml index 82233be9e1..aef8dbf5d1 100644 --- a/sqlx-cli/Cargo.toml +++ b/sqlx-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqlx-cli" -version = "0.5.5" +version = "0.5.6" description = "Command-line utility for SQLx, the Rust SQL toolkit." edition = "2018" readme = "README.md" diff --git a/sqlx-core/Cargo.toml b/sqlx-core/Cargo.toml index e4942b2cf9..66d53e717b 100644 --- a/sqlx-core/Cargo.toml +++ b/sqlx-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqlx-core" -version = "0.5.5" +version = "0.5.6" repository = "https://github.com/launchbadge/sqlx" description = "Core of SQLx, the rust SQL toolkit. Not intended to be used directly." license = "MIT OR Apache-2.0" diff --git a/sqlx-macros/Cargo.toml b/sqlx-macros/Cargo.toml index 014f3a5611..0e55df3c95 100644 --- a/sqlx-macros/Cargo.toml +++ b/sqlx-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqlx-macros" -version = "0.5.5" +version = "0.5.6" repository = "https://github.com/launchbadge/sqlx" description = "Macros for SQLx, the rust SQL toolkit. Not intended to be used directly." license = "MIT OR Apache-2.0" diff --git a/sqlx-rt/Cargo.toml b/sqlx-rt/Cargo.toml index 942a54753f..9fbc159b24 100644 --- a/sqlx-rt/Cargo.toml +++ b/sqlx-rt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqlx-rt" -version = "0.5.5" +version = "0.5.6" repository = "https://github.com/launchbadge/sqlx" license = "MIT OR Apache-2.0" description = "Runtime abstraction used by SQLx, the Rust SQL toolkit. Not intended to be used directly." From cd23588710720056ef8fd04aac69f9c65fded363 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Mon, 16 Aug 2021 17:49:12 -0700 Subject: [PATCH 4/4] chore: update CHANGELOG.md for 0.5.6 --- CHANGELOG.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e3addaecd..5ab9352c5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.5.6 - 2021-08-16 + +A large bugfix release, including but not limited to: + +* [[#1329]] Implement `MACADDR` type for Postgres [[@nomick]] +* [[#1363]] Fix `PortalSuspended` for array of composite types in Postgres [[@AtkinsChang]] +* [[#1320]] Reimplement `sqlx::Pool` internals using `futures-intrusive` [[@abonander]] + * This addresses a number of deadlocks/stalls on acquiring connections from the pool. +* [[#1332]] Macros: tell the compiler about external files/env vars to watch [[@abonander]] + * Includes `sqlx build-script` to create a `build.rs` to watch `migrations/` for changes. + * Nightly users can try `RUSTFLAGS=--cfg sqlx_macros_unstable` to tell the compiler + to watch `migrations/` for changes instead of using a build script. + * See the new section in the docs for `sqlx::migrate!()` for details. +* [[#1351]] Fix a few sources of segfaults/errors in SQLite driver [[@abonander]] + * Includes contributions from [[@link2ext]] and [[@madadam]]. +* [[#1323]] Keep track of column typing in SQLite EXPLAIN parsing [[@marshoepial]] + * This fixes errors in the macros when using `INSERT/UPDATE/DELETE ... RETURNING ...` in SQLite. + +[A total of 25 pull requests][0.5.6-prs] were merged this release cycle! + +[#1329]: https://github.com/launchbadge/sqlx/pull/1329 +[#1363]: https://github.com/launchbadge/sqlx/pull/1363 +[#1320]: https://github.com/launchbadge/sqlx/pull/1320 +[#1332]: https://github.com/launchbadge/sqlx/pull/1332 +[#1351]: https://github.com/launchbadge/sqlx/pull/1351 +[#1323]: https://github.com/launchbadge/sqlx/pull/1323 +[0.5.6-prs]: https://github.com/launchbadge/sqlx/pulls?q=is%3Apr+is%3Amerged+merged%3A2021-05-24..2021-08-17 + ## 0.5.5 - 2021-05-24 - [[#1242]] Fix infinite loop at compile time when using query macros [[@toshokan]] @@ -925,3 +953,8 @@ Fix docs.rs build by enabling a runtime feature in the docs.rs metadata in `Carg [@feikesteenbergen]: https://github.com/feikesteenbergen [@etcaton]: https://github.com/ETCaton [@toshokan]: https://github.com/toshokan +[@nomick]: https://github.com/nomick +[@marshoepial]: https://github.com/marshoepial +[@link2ext]: https://github.com/link2ext +[@madadam]: https://github.com/madadam +[@AtkinsChang]: https://github.com/AtkinsChang \ No newline at end of file