Skip to content

Commit f0cda70

Browse files
authored
feat(bin): abort connections before dropping temp databases in parallel run (#247)
* feat(bin): abort connections before dropping temp databases in parallel run Signed-off-by: Bugen Zhao <i@bugenzhao.com> * fmt Signed-off-by: Bugen Zhao <i@bugenzhao.com> * refine comments Signed-off-by: Bugen Zhao <i@bugenzhao.com> * use one from `tokio-util` Signed-off-by: Bugen Zhao <i@bugenzhao.com> * bump version and add release notes Signed-off-by: Bugen Zhao <i@bugenzhao.com> --------- Signed-off-by: Bugen Zhao <i@bugenzhao.com>
1 parent 3c4ee72 commit f0cda70

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## [0.26.3] - 2025-01-14
11+
12+
* bin: when `--fail-fast` is enabled, abort all remaining connections before dropping temporary databases.
13+
1014
## [0.26.2] - 2025-01-08
1115

1216
* bin: support `--fail-fast`, and add env vars `SLT_FAIL_FAST` and `SLT_KEEP_DB_ON_FAILURE`

Cargo.lock

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "2"
33
members = ["sqllogictest", "sqllogictest-bin", "sqllogictest-engines", "tests"]
44

55
[workspace.package]
6-
version = "0.26.2"
6+
version = "0.26.3"
77
edition = "2021"
88
homepage = "https://github.com/risinglightdb/sqllogictest-rs"
99
keywords = ["sql", "database", "parser", "cli"]

sqllogictest-bin/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ tokio = { version = "1", features = [
3333
"fs",
3434
"process",
3535
] }
36+
tokio-util = { version = "0.7.12", features = ["rt"] }
3637
fs-err = "3.0.0"
3738
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
3839
tracing = "0.1"

sqllogictest-bin/src/main.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use sqllogictest::{
2020
default_column_validator, default_normalizer, default_validator, update_record_with_output,
2121
AsyncDB, Injected, MakeConnection, Record, Runner,
2222
};
23+
use tokio_util::task::AbortOnDropHandle;
2324

2425
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
2526
#[must_use]
@@ -314,21 +315,21 @@ async fn run_parallel(
314315
}
315316
}
316317

317-
let mut stream = futures::stream::iter(create_databases.into_iter())
318+
let mut stream = futures::stream::iter(create_databases)
318319
.map(|(db_name, filename)| {
319320
let mut config = config.clone();
320321
config.db.clone_from(&db_name);
321322
let file = filename.to_string_lossy().to_string();
322323
let engine = engine.clone();
323324
let labels = labels.to_vec();
324325
async move {
325-
let (buf, res) = tokio::spawn(async move {
326+
let (buf, res) = AbortOnDropHandle::new(tokio::spawn(async move {
326327
let mut buf = vec![];
327328
let res =
328329
connect_and_run_test_file(&mut buf, filename, &engine, config, &labels)
329330
.await;
330331
(buf, res)
331-
})
332+
}))
332333
.await
333334
.unwrap();
334335
(db_name, file, res, buf)
@@ -396,6 +397,10 @@ async fn run_parallel(
396397
start.elapsed().as_millis()
397398
);
398399

400+
// If `fail_fast`, there could be some ongoing cases (then active connections)
401+
// in the stream. Abort them before dropping temporary databases.
402+
drop(stream);
403+
399404
for db_name in db_names {
400405
if keep_db_on_failure && failed_db.contains(&db_name) {
401406
eprintln!(

0 commit comments

Comments
 (0)