Repository navigation
Closed
Labels
Test FlakeTests that work. Wait, no. Actually yes. Hang on. Something is broken.
Description
This test failed on a CI run on pull request 6475:
Log showing the specific test failure:
Excerpt from the log showing the failure:
FAIL [ 25.576s] omicron-omdb::test_all_output test_omdb_success_cases
--- STDOUT: omicron-omdb::test_all_output test_omdb_success_cases ---
running 1 test
running commands with args: ["db", "disks", "list"]
running commands with args: ["db", "dns", "show"]
running commands with args: ["db", "dns", "diff", "external", "2"]
running commands with args: ["db", "dns", "names", "external", "2"]
running commands with args: ["db", "instances"]
running commands with args: ["db", "reconfigurator-save", "/var/tmp/omicron_tmp/.tmpVjFflB/reconfigurator-save.out"]
running commands with args: ["db", "sleds"]
running commands with args: ["db", "sleds", "-F", "discretionary"]
running commands with args: ["mgs", "inventory"]
running commands with args: ["nexus", "background-tasks", "doc"]
running commands with args: ["nexus", "background-tasks", "show"]
running commands with args: ["nexus", "background-tasks", "show", "saga_recovery"]
running commands with args: ["nexus", "background-tasks", "show", "blueprint_loader", "blueprint_executor"]
running commands with args: ["nexus", "background-tasks", "show", "dns_internal"]
running commands with args: ["nexus", "background-tasks", "show", "dns_external"]
running commands with args: ["nexus", "background-tasks", "show", "all"]
running commands with args: ["nexus", "sagas", "list"]
running commands with args: ["--destructive", "nexus", "sagas", "demo-create"]
running commands with args: ["nexus", "sagas", "list"]
running commands with args: ["--destructive", "nexus", "background-tasks", "activate", "inventory_collection"]
running commands with args: ["nexus", "blueprints", "list"]
running commands with args: ["nexus", "blueprints", "show", "5103da0a-8625-4be7-b03e-16ff5fde04a9"]
running commands with args: ["nexus", "blueprints", "show", "current-target"]
running commands with args: ["nexus", "blueprints", "diff", "5103da0a-8625-4be7-b03e-16ff5fde04a9", "current-target"]
@@ -55,10 +55,13 @@
ID NAME STATE PROPOLIS_ID SLED_ID HOST_SERIAL
---------------------------------------------
stderr:
note: using database URL postgresql://root@[::1]:REDACTED_PORT/omicron?sslmode=disable
note: database schema version matches expected (<redacted database version>)
+thread 'tokio-runtime-worker' panicked at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-bb8-diesel-0.2.1/src/async_traits.rs:97:14:
+called `Result::unwrap()` on an `Err` value: JoinError::Cancelled(Id(36))
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
=============================================
EXECUTING COMMAND: omdb ["db", "reconfigurator-save", "<TMP_PATH_REDACTED>"]
termination: Exited(0)
---------------------------------------------
stdout:
test test_omdb_success_cases ... FAILED
failures:
failures:
test_omdb_success_cases
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2 filtered out; finished in 25.36s
--- STDERR: omicron-omdb::test_all_output test_omdb_success_cases ---
log file: /var/tmp/omicron_tmp/test_all_output-ce8c2ad688e5b1af-test_omdb_success_cases.19791.0.log
note: configured to log to "/var/tmp/omicron_tmp/test_all_output-ce8c2ad688e5b1af-test_omdb_success_cases.19791.0.log"
DB URL: postgresql://root@[::1]:43788/omicron?sslmode=disable
DB address: [::1]:43788
log file: /var/tmp/omicron_tmp/test_all_output-ce8c2ad688e5b1af-test_omdb_success_cases.19791.2.log
note: configured to log to "/var/tmp/omicron_tmp/test_all_output-ce8c2ad688e5b1af-test_omdb_success_cases.19791.2.log"
log file: /var/tmp/omicron_tmp/test_all_output-ce8c2ad688e5b1af-test_omdb_success_cases.19791.3.log
note: configured to log to "/var/tmp/omicron_tmp/test_all_output-ce8c2ad688e5b1af-test_omdb_success_cases.19791.3.log"
log file: /var/tmp/omicron_tmp/test_all_output-ce8c2ad688e5b1af-test_omdb_success_case.19791.4.log
note: configured to log to "/var/tmp/omicron_tmp/test_all_output-ce8c2ad688e5b1af-test_omdb_success_case.19791.4.log"
thread 'test_omdb_success_cases' panicked at dev-tools/omdb/tests/test_all_output.rs:242:5:
assertion failed: string doesn't match the contents of file: "tests/successes.out" see diffset above
set EXPECTORATE=overwrite if these changes are intentional
stack backtrace:
0: rust_begin_unwind
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:652:5
1: core::panicking::panic_fmt
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:72:14
2: assert_contents<&str>
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/expectorate-1.1.0/src/lib.rs:64:9
3: {async_fn#0}
at ./tests/test_all_output.rs:242:5
4: {async_block#0}
at ./tests/test_all_output.rs:116:1
5: poll<&mut dyn core::future::future::Future<Output=()>>
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/future/future.rs:123:9
6: poll<&mut core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/future/future.rs:123:9
7: {closure#0}<core::pin::Pin<&mut core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>>
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/scheduler/current_thread/mod.rs:673:57
8: with_budget<core::task::poll::Poll<()>, tokio::runtime::scheduler::current_thread::{impl#8}::block_on::{closure#0}::{closure#0}::{closure_env#0}<core::pin::Pin<&mut core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>>>
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/coop.rs:107:5
9: budget<core::task::poll::Poll<()>, tokio::runtime::scheduler::current_thread::{impl#8}::block_on::{closure#0}::{closure#0}::{closure_env#0}<core::pin::Pin<&mut core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>>>
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/coop.rs:73:5
10: {closure#0}<core::pin::Pin<&mut core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>>
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/scheduler/current_thread/mod.rs:673:25
11: tokio::runtime::scheduler::current_thread::Context::enter
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/scheduler/current_thread/mod.rs:412:19
12: {closure#0}<core::pin::Pin<&mut core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>>
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/scheduler/current_thread/mod.rs:672:36
13: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/scheduler/current_thread/mod.rs:751:68
14: tokio::runtime::context::scoped::Scoped<T>::set
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/context/scoped.rs:40:9
15: tokio::runtime::context::set_scheduler::{{closure}}
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/context.rs:180:26
16: try_with<tokio::runtime::context::Context, tokio::runtime::context::set_scheduler::{closure_env#0}<(alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core, alloc::alloc::Global>, core::option::Option<()>), tokio::runtime::scheduler::current_thread::{impl#8}::enter::{closure_env#0}<tokio::runtime::scheduler::current_thread::{impl#8}::block_on::{closure_env#0}<core::pin::Pin<&mut core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>>, core::option::Option<()>>>, (alloc::boxed::Box<tokio::runtime::scheduler::current_thread::Core, alloc::alloc::Global>, core::option::Option<()>)>
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/thread/local.rs:283:12
17: std::thread::local::LocalKey<T>::with
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/thread/local.rs:260:9
18: tokio::runtime::context::set_scheduler
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/context.rs:180:9
19: tokio::runtime::scheduler::current_thread::CoreGuard::enter
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/scheduler/current_thread/mod.rs:751:27
20: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/scheduler/current_thread/mod.rs:660:19
21: {closure#0}<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/scheduler/current_thread/mod.rs:180:28
22: tokio::runtime::context::runtime::enter_runtime
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/context/runtime.rs:65:16
23: block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/scheduler/current_thread/mod.rs:168:9
24: tokio::runtime::runtime::Runtime::block_on_inner
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/runtime.rs:361:47
25: block_on<core::pin::Pin<&mut dyn core::future::future::Future<Output=()>>>
at /home/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.3/src/runtime/runtime.rs:335:13
26: test_omdb_success_cases
at ./tests/test_all_output.rs:116:1
27: test_all_output::test_omdb_success_cases::{{closure}}
at ./tests/test_all_output.rs:117:70
28: core::ops::function::FnOnce::call_once
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/ops/function.rs:250:5
29: core::ops::function::FnOnce::call_once
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
WARN: dropped CockroachInstance without cleaning it up first (there may still be a child process running and a temporary directory leaked)
WARN: temporary directory leaked: "/var/tmp/omicron_tmp/.tmpDdfI0d"
If you would like to access the database for debugging, run the following:
# Run the database
cargo xtask db-dev run --no-populate --store-dir "/var/tmp/omicron_tmp/.tmpDdfI0d/data"
# Access the database. Note the port may change if you run multiple databases.
cockroach sql --host=localhost:32221 --insecure
WARN: dropped ClickHouseInstance without cleaning it up first (there may still be a child process running and a temporary directory leaked)
failed to clean up ClickHouse data dir:
- /var/tmp/omicron_tmp/test_all_output-ce8c2ad688e5b1af-test_omdb_success_cases.19791.1-clickhouse-Tjceqh: File exists (os error 17)
WARN: dropped DendriteInstance without cleaning it up first (there may still be a child process running and a temporary directory leaked)
WARN: dendrite temporary directory leaked: /var/tmp/omicron_tmp/.tmpgUhVaY
WARN: dropped DendriteInstance without cleaning it up first (there may still be a child process running and a temporary directory leaked)
WARN: dendrite temporary directory leaked: /var/tmp/omicron_tmp/.tmpU3R6qP
WARN: dropped MgdInstance without cleaning it up first (there may still be a child process running and a temporary directory leaked)
WARN: mgd temporary directory leaked: /var/tmp/omicron_tmp/.tmpoJXOMm
WARN: dropped MgdInstance without cleaning it up first (there may still be a child process running and a temporary directory leaked)
WARN: mgd temporary directory leaked: /var/tmp/omicron_tmp/.tmpoo1igu
Metadata
Metadata
Assignees
Labels
Test FlakeTests that work. Wait, no. Actually yes. Hang on. Something is broken.
Activity
davepacheco commentedon Sep 4, 2024
Bummer -- and thanks for filing this.
From the output, it looks to me like the test ran the command
omdb db instancesand that panicked with:That's not very much to go on. We don't have more because this was a subprocess -- the test ultimately failed only because the output didn't match what it expected. I haven't totally given up yet but I've put up #6516 so that if we hit this again we'll get more information about a panic from the subprocess.
davepacheco commentedon Sep 4, 2024
The panic message is coming from here:
https://github.com/oxidecomputer/async-bb8-diesel/blob/1850c9d9a9311ff6a60cadee9023e7693eda3304/src/async_traits.rs#L97
But I think that's just propagating a panic that happened in the middle of just about anything that async-bb8-diesel was doing. There are a few unwraps in in the
omdb db instancescommand itself:omicron/dev-tools/omdb/src/bin/omdb/db.rs
Lines 2837 to 2920 in a77c31b
But if we panicked in those, I don't think it would show up in async-bb8-diesel. I'm trying to figure out what would show up there. We're not using
transaction_asyncin this code so I don't see how we could have entered async-bb8-diesel and then called back out to this code. An example might be if the synchronousloadpanicked, but that's not our code so that would be surprising.I'm also going to file an async-bb8-diesel bug because it seems like it could propagate more about the panic error in this situation.
davepacheco commentedon Sep 4, 2024
Actually, I'm not sure this is an async-bb8-diesel bug. Looking more closely at the
JoinError, it's saying that the underlying task was cancelled, not that it panicked. How did that happen? Looking at the docs:One way I could imagine this happening is if the program started an async database operation (like
load_async) but then panicked before the corresponding tokio task was started. That might trigger teardown of the executor and we might see this second panic. But then shouldn't we see some information about that other panic?hawkw commentedon Sep 24, 2024
I hit this one today on PR #6652: https://buildomat.eng.oxide.computer/wg/0/details/01J8JH1GHTE595MAF5YBTA8BS6/3ybl2B1ZPCoj5D0UfV5BgvmfQpYqlpYGkOVlmy3dpaUvVN5L/01J8JH2AVHD7EAR6AT7ZG8WS72#S5595. Wanted to comment here because it looks like this particular flake may result in very different panic messages depending on which OMDB command actually hit the issue, so folks hitting this flake might report new issues for it that are actually duplicates of this.
gjcolombo commentedon Sep 27, 2024
Appears to have bitten #6698, also in an omdb test: https://buildomat.eng.oxide.computer/wg/0/details/01J8RD8168F85NSREWHQ1SDSRG/CYHvVeadfxQl3Yi4jpbKPAmUTiZePQCq9PVtL9VzofHG4CL6/01J8RD8TN8DS3QGWAZHEPVJYEW5
sunshowers commentedon Oct 12, 2024
Another example: https://buildomat.eng.oxide.computer/wg/0/details/01J9YQVN7X5EQNXFSEY6XJBH8B/zfviqPz9RoJp3bY4TafbyqXTwbhqdr7w4oupqBtVARR00CXF/01J9YQWAXY36WM0R2VG27QMFRK#S6015
sunshowers commentedon Oct 12, 2024
Could this be a shutdown task ordering issue? At https://docs.rs/crate/async-bb8-diesel/0.2.1/source/src/async_traits.rs#95, if the spawned task is cancelled due to the runtime shutting down, then there's going to be a panic here.
sunshowers commentedon Oct 12, 2024
Yeah, looking at it I'm pretty sure that it is a shutdown ordering issue. The API is generic over arbitrary E so there's sadly no good place to put in "child task got cancelled, runtime shutting down" at the moment. So we'll probably have to make a breaking change to async-bb8-diesel.
sunshowers commentedon Oct 12, 2024
Hmm, but as Dave pointed out this should only happen if the underlying task was cancelled. And the
spawn_blockingdocumentation promises that the task will never be cancelled. Wonder if there's a deeper tokio bug here.sunshowers commentedon Oct 12, 2024
Ah, according to tokio-rs/tokio#3805 (comment) what's happening is that the runtime is shutting down before
spawn_blockingis called. In that case, a handle is returned but it immediately fails with a cancelled error.sunshowers commentedon Oct 12, 2024
I've put up a tentative PR at oxidecomputer/async-bb8-diesel#77. I don't feel great about it, but I also don't see another way sadly.
This is going to end up infecting Omicron as well -- we'll no longer be dealing with Diesel errors, but instead with this new wrapper error type. (And here again we'd need to be careful to not panic on all errors -- instead, if the error is a shutdown error, silently ignoring it somehow.)
Ugh.
smklein commentedon Oct 14, 2024
I understand why we think async-bb8-diesel is causing this particular backtrace - the diagnosis of "We are trying to spawn new work while the tokio runtime is shutting down" seems accurate - but this seems like it might be a secondary failure, rather than the primary reason for the test failing.
Framed another way: why are we trying to spawn new work amid a runtime shutdown?
I think that propagating better error information from async-bb8-diesel would be worthwhile, just want to confirm my understanding here that "it's weird
omdb db instancesis sending new requests to the DB while also shutting down, right?"hawkw commentedon Oct 14, 2024
I'm guessing the reason we are wondering about async-bb8-diesel is that, as I understand it, nothing else in the
omdb db instancescommand has spawned any tasks in the background, so when the runtime shuts down because the#[tokio::main]function has exited, there isn't anything else left that might be trying to spawn new tasks?sunshowers commentedon Oct 14, 2024
Is there some kind of background task that might be hitting the DB periodically?
edit: it's a bit hard to be completely sure, but the stack trace does seem to suggest this is happening within a task.
sunshowers commentedon Oct 15, 2024
The error is coming from here:
omicron/nexus/db-queries/src/db/pool_connection.rs
Line 133 in cf4b8df
smklein commentedon Oct 15, 2024
Yeah, this tracks with the timing when qorb was integrated into Omicron (in dd85331, which landed right before this bug was first reported). On the bright side, this doesn't seem like a bug that would impact prod, but a test shutdown ordering.
I'll look at how we're terminating the pool. If we can cleanly terminate the qorb pool when the test exits, that should also help resolve this issue.
davepacheco commentedon Oct 15, 2024
Sorry I'm a little confused about our hypothesized sequence of events leading to this. Is it something like: in the child process:
ping_async, which entersasync-bb8-diesel, which doesspawn_blocking, which returns a handle that's already cancelled, and async-bb8-diesel panics?(I feel like that's not exactly right but I'm just trying to put together the pieces above)
smklein commentedon Oct 15, 2024
Yeah, it's worthwhile clarifying, there's a lot of moving pieces. This is my hypothesis:
nexus_test, so it spawns aqorbpool within Nexus. This spawns background tasks in the test process.nexus_test.qorbpool, along with Nexus and the entire tokio runtime.qorbtasks is still running while the tokio runtime is getting dropped. It callsping_async, which makes anasync_bb8_dieselcall, and panics. But really, it could be doing any background work, like trying to make a new connection to the DB.The qorb "termination" code is pretty half-baked right now -- it just calls
aborton background tasks indrop, but this signals them to start cancellation, and doesn't necessarily guarantee they get cancelled.My plan is the following:
drop. This should give us a way to ensure we've stopped all background tasks.nexus_test. This should stop all background tasks while we're exiting the test, but before the tokio runtime actually starts shutting down.smklein commentedon Oct 16, 2024
#6881 is my proposed fix, with an attempt to summarize "what I believe is going wrong" in the PR message.
[nexus] Explicitly terminate pools for qorb (#6881)