Closed dialogflowchatbot closed 2 months ago
Hey, I apologize for the issue and thank you for continuing to use OasysDB even after the overhaul.
I push a hotfix release of 0.7.2 where the temporary directory will now be created inside of the database directory you open. Unfortunately, I don't have a Windows machine and won't be able to test it directly. But based on the description you provided, this should fix it.
Thanks for the quick fix.
I upgraded Oasysdb
to 0.7.2
and encountered a new error
thread 'dialogflowchatbot' panicked at E:\dev-program-data\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\tokio-1.39.2\src\runtime\scheduler\multi_thread\mod.rs:86:9:
Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
I'm using tokio runtime
as well.
Not sure if it's the problem
Stacktrace:
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library\std\src\panicking.rs:652
1: core::panicking::panic_fmt
at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library\core\src\panicking.rs:72
2: tokio::runtime::context::runtime::enter_runtime<tokio::runtime::scheduler::multi_thread::impl$0::block_on::closure_env$0<enum2$<oasysdb::db::database::impl$2::async_connect::async_fn_env$0> >,enum2$<core::result::Result<sqlx_core::any::connection::AnyConne
at E:\dev-program-data\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\tokio-1.39.2\src\runtime\context\runtime.rs:68
3: tokio::runtime::scheduler::multi_thread::MultiThread::block_on<enum2$<oasysdb::db::database::impl$2::async_connect::async_fn_env$0> >
at E:\dev-program-data\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\tokio-1.39.2\src\runtime\scheduler\multi_thread\mod.rs:86
4: tokio::runtime::runtime::Runtime::block_on_inner<enum2$<oasysdb::db::database::impl$2::async_connect::async_fn_env$0> >
at E:\dev-program-data\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\tokio-1.39.2\src\runtime\runtime.rs:363
5: tokio::runtime::runtime::Runtime::block_on<enum2$<oasysdb::db::database::impl$2::async_connect::async_fn_env$0> >
at E:\dev-program-data\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\tokio-1.39.2\src\runtime\runtime.rs:335
6: oasysdb::db::database::DatabaseState::connect
at E:\dev-program-data\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\oasysdb-0.7.2\src\db\database.rs:501
7: oasysdb::db::database::DatabaseState::validate_connection
at E:\dev-program-data\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\oasysdb-0.7.2\src\db\database.rs:523
8: oasysdb::db::database::Database::open<std::path::PathBuf,alloc::string::String>
at E:\dev-program-data\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\oasysdb-0.7.2\src\db\database.rs:89
BTW, will you upgrade sqlx
to 0.8.0
?
Hey, I will update SQLx to 0.8.0 ASAP.
By the way, for the error trace your provided, do you mind sharing the code you use?
The reason of the error seems to come from running OasysDB inside of an async function with Tokio runtime like:
#[tokio::main]
async fn main() {
...
let db = Database::open(...)
}
Sure, let me sync code to github right away.
I pushed code to Github.
The error came from this line: https://github.com/dialogflowchatbot/dialogflow-backend/blob/main/src/intent/detector.rs#L13
I created a Tokio Runtime
in main
function:
https://github.com/dialogflowchatbot/dialogflow-backend/blob/main/src/main.rs#L24
It seems to be a problem with nested Tokio runtime since OasysDB blocking API will create a new Tokio runtime to execute the async code.
I am coming up with a quick fix to remove Tokio runtime requirement when opening the database.
I have published the hotfix for this issue on the version 0.7.3. I hope everything works this time 😂
Thanks a lot, let me try it
Database::open
worked. Thanks
Happy that it solved the problem 😁
Hi, as a reminder, these functions: create_index
and refresh_index
of Datebase
are still using tokio block_on
underneath which may cause the same error.
Hey, the Database offers async_create_index
and async_refresh_index
which you can use easily if you already use Tokio in your app.
Short Description
Ran
Database::open
failedSteps to Reproduce
Version of
Oasysdb
: 0.7.1open
function throwsI suspected that this error was thrown by
utils/file.rs
at this line:fs::rename(&tmp_file, &path)?;
I printed temporary directory on Windows was:
C:\Users\dialogf\AppData\Local\Temp\
and
Datebase
path I specified was:D:\work\dialogflow-backend\data\intentev\
Expected Behavior
Database open successfully.
Additional Context
Add any other context about the problem here like screenshots or logs.