Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: raft log store read data race #168

Closed
MrCroxx opened this issue May 19, 2022 · 1 comment · Fixed by #167
Closed

bug: raft log store read data race #168

MrCroxx opened this issue May 19, 2022 · 1 comment · Fixed by #167
Assignees
Labels
bug Something isn't working

Comments

@MrCroxx
Copy link
Owner

MrCroxx commented May 19, 2022

Sometimes, fn read() call of Log leads to early EOF error. Maybe caused by data race when rotating active log file.

thread 'tokio-runtime-worker' panicked at 'unexpected error: Store(Other(StorageError(IoError(Custom { kind: UnexpectedEof, error: "early eof" })))), raft_id: 2, raft node: 2, group: 1, namespace: raft', /home/mrcroxx/.cargo/git/checkouts/raft-rs-097263935fea03be/710b3a9/src/raft_log.rs:624:26
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/panicking.rs:142:14
   2: raft::raft_log::RaftLog<T>::slice::{{closure}}
             at /home/mrcroxx/.cargo/git/checkouts/raft-rs-097263935fea03be/710b3a9/src/raft_log.rs:624:26
   3: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/mod.rs:91:19
   4: raft::raft_log::RaftLog<T>::next_entries_since::{{closure}}
             at /home/mrcroxx/.cargo/git/checkouts/raft-rs-097263935fea03be/710b3a9/src/raft_log.rs:445:18
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/mod.rs:91:19
   6: raft::raw_node::RawNode<T>::gen_light_ready::{{closure}}
             at /home/mrcroxx/.cargo/git/checkouts/raft-rs-097263935fea03be/710b3a9/src/raw_node.rs:458:67
   7: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/mod.rs:91:19
   8: raft::raw_node::RawNode<T>::ready::{{closure}}
             at /home/mrcroxx/.cargo/git/checkouts/raft-rs-097263935fea03be/710b3a9/src/raw_node.rs:553:42
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/mod.rs:91:19
  10: runkv_wheel::worker::raft::RaftWorker<RN,F>::handle_ready::{{closure}}::{{closure}}
             at ./wheel/src/worker/raft.rs:503:42
  11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/mod.rs:91:19
  12: runkv_wheel::worker::raft::RaftWorker<RN,F>::handle_ready::{{closure}}
             at ./wheel/src/worker/raft.rs:499:5
  13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/mod.rs:91:19
  14: runkv_wheel::worker::raft::RaftWorker<RN,F>::run_inner::{{closure}}
             at ./wheel/src/worker/raft.rs:421:36
  15: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/mod.rs:91:19
  16: <runkv_wheel::worker::raft::RaftWorker<RN,F> as runkv_common::Worker>::run::{{closure}}
             at ./wheel/src/worker/raft.rs:289:35
  17: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/mod.rs:91:19
  18: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/future.rs:124:9
  19: runkv_wheel::components::raft_manager::RaftManager::create_raft_node::{{closure}}::{{closure}}
             at ./wheel/src/components/raft_manager.rs:176:43
  20: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/future/mod.rs:91:19
  21: tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/core.rs:161:17
  22: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/loom/std/unsafe_cell.rs:14:9
  23: tokio::runtime::task::core::CoreStage<T>::poll
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/core.rs:151:13
  24: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:467:19
  25: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/panic/unwind_safe.rs:271:9
  26: std::panicking::try::do_call
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/std/src/panicking.rs:492:40
  27: __rust_try
  28: std::panicking::try
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/std/src/panicking.rs:456:19
  29: std::panic::catch_unwind
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/std/src/panic.rs:137:14
  30: tokio::runtime::task::harness::poll_future
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:455:18
  31: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:103:27
  32: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:57:15
  33: tokio::runtime::task::raw::poll
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/raw.rs:128:5
  34: tokio::runtime::task::raw::RawTask::poll
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/raw.rs:80:18
  35: tokio::runtime::task::LocalNotified<S>::run
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/mod.rs:347:9
  36: tokio::runtime::thread_pool::worker::Context::run_task::{{closure}}
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:425:13
  37: tokio::coop::with_budget::{{closure}}
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:102:9
  38: std::thread::local::LocalKey<T>::try_with
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/std/src/thread/local.rs:442:16
  39: std::thread::local::LocalKey<T>::with
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/std/src/thread/local.rs:418:9
  40: tokio::coop::with_budget
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:95:5
  41: tokio::coop::budget
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:72:5
  42: tokio::runtime::thread_pool::worker::Context::run_task
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:424:9
  43: tokio::runtime::thread_pool::worker::Context::run
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:391:24
  44: tokio::runtime::thread_pool::worker::run::{{closure}}
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:376:17
  45: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/macros/scoped_tls.rs:61:9
  46: tokio::runtime::thread_pool::worker::run
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:373:5
  47: tokio::runtime::thread_pool::worker::Launch::launch::{{closure}}
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:352:45
  48: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/blocking/task.rs:42:21
  49: tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/core.rs:161:17
  50: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/loom/std/unsafe_cell.rs:14:9
  51: tokio::runtime::task::core::CoreStage<T>::poll
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/core.rs:151:13
  52: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:467:19
  53: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/core/src/panic/unwind_safe.rs:271:9
  54: std::panicking::try::do_call
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/std/src/panicking.rs:492:40
  55: __rust_try
  56: std::panicking::try
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/std/src/panicking.rs:456:19
  57: std::panic::catch_unwind
             at /rustc/f4a7ce997a1d7546d2b737f8b87d36907bcea2ad/library/std/src/panic.rs:137:14
  58: tokio::runtime::task::harness::poll_future
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:455:18
  59: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:103:27
  60: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:57:15
  61: tokio::runtime::task::raw::poll
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/raw.rs:128:5
  62: tokio::runtime::task::raw::RawTask::poll
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/raw.rs:80:18
  63: tokio::runtime::task::UnownedTask<S>::run
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/mod.rs:384:9
  64: tokio::runtime::blocking::pool::Task::run
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/blocking/pool.rs:91:9
  65: tokio::runtime::blocking::pool::Inner::run
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/blocking/pool.rs:308:17
  66: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at /home/mrcroxx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/blocking/pool.rs:288:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@MrCroxx MrCroxx added the bug Something isn't working label May 19, 2022
@MrCroxx MrCroxx self-assigned this May 19, 2022
@MrCroxx
Copy link
Owner Author

MrCroxx commented May 19, 2022

After investigation, when rotating log and read log happens concurrently, Log::read() gets wrong active file (expected origin active one, get the new one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant