]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commit
Prevent deadlock in db_stress with DbStressCompactionFilter (#8956) wip-quincy-lock-ebusy
authorAndrew Kryczka <andrewkr@fb.com>
Fri, 24 Sep 2021 23:52:30 +0000 (16:52 -0700)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 31 May 2024 15:24:19 +0000 (15:24 +0000)
commit1418e868bbf6dae700904c2e5a85fb57907e026e
tree554a1bc832330d52a3a324da0d518d6274d0d5f8
parentc540de6f709b66efd41436694f72d6f7986a325b
Prevent deadlock in db_stress with DbStressCompactionFilter (#8956)

Summary:
The cyclic dependency was:

- `StressTest::OperateDb()` locks the mutex for key 'k'
- `StressTest::OperateDb()` calls a function like `PauseBackgroundWork()`, which waits for pending compaction to complete.
- The pending compaction reaches key `k` and `DbStressCompactionFilter::FilterV2()` calls `Lock()` on that key's mutex, which hangs forever.

The cycle can be broken by using a new function, `port::Mutex::TryLock()`, which returns immediately upon failure to acquire a lock. In that case `DbStressCompactionFilter::FilterV2()` can just decide to keep the key.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8956

Reviewed By: riversand963

Differential Revision: D31183718

Pulled By: ajkr

fbshipit-source-id: 329e4a31ce43085af174cf367ef560b5a04399c5
(cherry picked from commit 791bff5b4e1f0f35448eb2cffa2683e01952038b)

Conflicts:
port/port_posix.cc -- `errnoStr` is not used in the version
      we're cherry-picking on. Let's stay
      with `strerror`.
db_stress_tool/db_stress_compaction_filter.h
port/port_posix.cc
port/port_posix.h
port/win/port_win.h