SQLite error on making repeated requests
Summary
In certain situations (unclear as to why this happens), an application using arti_client or arti_hyper will panic with an SQLite error complaining about "attempt to write a readonly database".
I myself only found this issue because I wanted to build small projects using these crates to uncover bugs in them.
Steps to reproduce:
- I was experimenting here, so getting that code would be good.
- Run the code 2-3 times (it first makes request via arti_client then arti_hyper, forgive the messiness and all, I merely copied and pasted starter docs to learn about each struct and the method of using the APIs)
- If you are lucky, you will see what I am talking about (no idea what triggers this, I am afraid)
What is the current bug behavior?
It panics with a long backtrace
What is the expected behavior?
Repeated calls to a resource should just be fulfilled (or rejected, depending on the situation) but definitely not a panic.
Environment
- Version: both arti-client and arti-hyper at 0.8.1
- Operating system: Fedora 37 amd64
- Install method: cargo (from crates.io)
Relevant logs and/or screenshots:
One errant output:
Hello, world!
HTTP/1.1 200 OK
Date: Mon, 27 Feb 2023 14:31:12 GMT
Content-Type: text/plain
Content-Length: 14
Connection: close
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Set-Cookie: __cf_bm=cseyp1gRP0X6TzXaa8pOxIHITZQi2cDv6TtaGIGmzxc-1677508272-0-AS9zqtkA2ihZe4vFxvMEyjMy3hn9I26h+ReVbXJ22deuo0nES91g0vrurvW9AYBNIWS3T3QNBZI8P44NbHF4XL0=; path=/; expires=Mon, 27-Feb-23 15:01:12 GMT; domain=.icanhazip.com; HttpOnly
Server: cloudflare
CF-RAY: 7a019f6ceef095fa-ARN
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
37.228.129.24
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { detail: DirMgrBootstrap(Bug(Bug(BugRepr { message: "sqlite detected bug", location: Location { file: "/home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-dirmgr-0.9.1/src/err.rs", line: 317, col: 17 }, backtrace: Captured( 0: tor_error::internal::ie_backtrace::capture
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-error-0.4.1/src/internal.rs:21:18
1: tor_error::internal::Bug::new_inner
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-error-0.4.1/src/internal.rs:105:24
2: tor_error::internal::Bug::from_error
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-error-0.4.1/src/internal.rs:121:9
3: <tor_dirmgr::err::Error as core::convert::From<rusqlite::error::Error>>::from
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-dirmgr-0.9.1/src/err.rs:317:17
4: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:2108:27
5: <tor_dirmgr::storage::sqlite::SqliteStore as tor_dirmgr::storage::Store>::mark_consensus_usable
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-dirmgr-0.9.1/src/storage/sqlite.rs:464:17
6: tor_dirmgr::DirMgr<R>::apply_netdir_changes
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-dirmgr-0.9.1/src/lib.rs:1051:21
7: tor_dirmgr::bootstrap::load::{{closure}}
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-dirmgr-0.9.1/src/bootstrap.rs:388:13
8: tor_dirmgr::DirMgr<R>::load_directory::{{closure}}
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-dirmgr-0.9.1/src/lib.rs:914:79
9: tor_dirmgr::DirMgr<R>::bootstrap::{{closure}}
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-dirmgr-0.9.1/src/lib.rs:465:61
10: <alloc::sync::Arc<tor_dirmgr::DirMgr<R>> as tor_dirmgr::DirProvider>::bootstrap::{{closure}}
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tor-dirmgr-0.9.1/src/lib.rs:231:32
11: <core::pin::Pin<P> as core::future::future::Future>::poll
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/future/future.rs:124:9
12: arti_client::client::TorClient<R>::bootstrap_inner::{{closure}}
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/arti-client-0.8.1/src/client.rs:640:13
13: arti_client::client::TorClient<R>::bootstrap::{{closure}}
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/arti-client-0.8.1/src/client.rs:585:31
14: arti_client::builder::TorClientBuilder<R>::create_bootstrapped::{{closure}}
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/arti-client-0.8.1/src/builder.rs:161:22
15: arti_client::client::TorClient<tor_rtcompat::PreferredRuntime>::create_bootstrapped::{{closure}}
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/arti-client-0.8.1/src/client.rs:382:13
16: arti_sample_project::get_ip_hyper::{{closure}}
at src/main.rs:49:60
17: arti_sample_project::main::{{closure}}
at src/main.rs:68:19
18: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/park.rs:283:63
19: tokio::runtime::coop::with_budget
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/coop.rs:102:5
tokio::runtime::coop::budget
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/coop.rs:68:5
tokio::runtime::park::CachedParkThread::block_on
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/park.rs:283:31
20: tokio::runtime::context::BlockingRegionGuard::block_on
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/context.rs:315:13
21: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/scheduler/multi_thread/mod.rs:66:9
22: tokio::runtime::runtime::Runtime::block_on
at /home/gotlou/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/runtime.rs:284:45
23: arti_sample_project::main
at src/main.rs:68:5
24: core::ops::function::FnOnce::call_once
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:507:5
25: std::sys_common::backtrace::__rust_begin_short_backtrace
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:121:18
26: std::rt::lang_start::{{closure}}
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:166:18
27: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:606:13
std::panicking::try::do_call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
std::panicking::try
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
std::panic::catch_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
std::rt::lang_start_internal::{{closure}}
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:148:48
std::panicking::try::do_call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
std::panicking::try
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
std::panic::catch_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
std::rt::lang_start_internal
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:148:20
28: std::rt::lang_start
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:165:17
29: main
30: __libc_start_call_main
31: __libc_start_main@GLIBC_2.2.5
32: _start
), source: Some(SqliteFailure(Error { code: ReadOnly, extended_code: 8 }, Some("attempt to write a readonly database"))), kind: Internal }))) }', src/main.rs:49:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Edited by Saksham Mittal