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

Deadlock? #2

Closed
jswrenn opened this issue Jan 23, 2022 · 2 comments
Closed

Deadlock? #2

jswrenn opened this issue Jan 23, 2022 · 2 comments

Comments

@jswrenn
Copy link

jswrenn commented Jan 23, 2022

To play around with this crate, I tried my hand at using it in mini-redis: jswrenn/mini-redis@a2ae42c. I launched my patched mini-redis with:

RUST_BACKTRACE=1 RUSTFLAGS="--cfg tokio_unstable" RUST_LOG=trace cargo run --bin mini-redis-server

...and, in another terminal, ran:

$ redis-benchmark -t set -n 1

Unfortunately, mini-redis then seems to deadlock before the benchmark can complete:

$ RUST_BACKTRACE=1 RUSTFLAGS="--cfg tokio_unstable" RUST_LOG=trace cargo run --bin mini-redis-server
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/mini-redis-server`
mini-redis-server::Handler::run                                                                                            18ms ├────────────────────────────┤
  run                                                                                                                      14ms ├──────────────────────┤
    read_frame                                                                                                            172μs ┆
    from_frame{frame: Array([Bulk(b"CONFIG"), Bulk(b"GET"), Bulk(b"save")])}                                               66μs  ┆
    apply{self: Unknown(Unknown { command_name: "config" }), db: Db { shared: Shared { state: Mutex { data: State { entr  432μs  │
      apply                                                                                                               254μs   ┆
    read_frame                                                                                                             95μs   ┆
    from_frame{frame: Array([Bulk(b"CONFIG"), Bulk(b"GET"), Bulk(b"appendonly")])}                                         55μs    ┆
    apply{self: Unknown(Unknown { command_name: "config" }), db: Db { shared: Shared { state: Mutex { data: State { entr 1015μs    ├┤
      apply                                                                                                               640μs    │
    read_frame                                                                                                            232μs               ┆

(At this point, I have to kill the mini-redis-server process in another terminal.)

Any thoughts about what might be going on here?

@rcoh
Copy link
Owner

rcoh commented Jan 23, 2022

I found two separate deadlock causes 😅 will get a new release out soon. Thanks for catching this!

@rcoh
Copy link
Owner

rcoh commented Jan 24, 2022

0.1.2 has been pushed. Also, thanks for that Redis example! It's the perfect test bed to quickly iterate on performance :-)

mini-redis-server::Handler::run                                                                                           143μs ├──────────────────────────────────────────────────────────────────────────────────────────────────────┤
  run                                                                                                                     138μs    ├──────────────────────────────────────────────────────────────────────────────────────────────────┤
    read_frame                                                                                                              7μs       ├───┤
    from_frame{frame: Array([Bulk(b"SET"), Bulk(b"key:__rand_int__"), Bulk(b"xxx")])}                                       2μs                      ├┤
    apply{self: Set(Set { key: "key:__rand_int__", value: b"xxx", expire: None }), db: Db { shared: Shared { state: Mute   40μs                                     ├───────────────────────────┤
      apply                                                                                                                35μs                                       ├────────────────────────┤
    read_frame                                                                                                             31μs                                                                       ├─────────────────────┤

@rcoh rcoh closed this as completed Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants