zboxfs / zbox

Zero-details, privacy-focused in-app file system.
https://zbox.io/fs/
Apache License 2.0
1.53k stars 74 forks source link

Panic when writing to `Mutex<zbox::File>` from multiple threads. #68

Open vi opened 4 years ago

vi commented 4 years ago
[2020-01-01T01:08:49Z DEBUG zbox::trans::txmgr] run tx failed: Io(Custom { kind: Other, error: "Not in transaction" })
[2020-01-01T01:08:49Z DEBUG zbox::trans::txmgr] abort tx#3
[2020-01-01T01:08:50Z DEBUG zbox::trans::txmgr] tx#3 aborted
[2020-01-01T01:08:50Z ERROR zboxmount::zboxfuse] IO error: Not in transaction
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1025
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:193
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:471
  11: rust_begin_unwind
             at src/libstd/panicking.rs:375
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:84
  13: core::panicking::panic
             at src/libcore/panicking.rs:51
  14: core::option::Option<T>::unwrap
             at /rustc/3eeb8d4f2fbae0bb1c587d00b5abeaf938da47f4/src/libcore/macros/mod.rs:15
  15: zbox::trans::txmgr::TxMgr::abort_trans
             at /home/vi/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.8/src/trans/txmgr.rs:157
  16: zbox::trans::txmgr::TxHandle::abort
             at /home/vi/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.8/src/trans/txmgr.rs:238
  17: zbox::trans::txmgr::TxHandle::run
             at /home/vi/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.8/src/trans/txmgr.rs:208
  18: <zbox::file::File as std::io::Write>::write
             at /home/vi/.cargo/registry/src/github.com-1ecc6299db9ec823/zbox-0.8.8/src/file.rs:586
burmecia commented 4 years ago

Can you post example code causing this issue? Theoretically it should be able to write the same file from multiple thread but not in same time, because transaction is exclusive and one file cannot be in multiple transaction at same time.