]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Remove TaskLimiterToken::ReleaseOnce for fix (#8567)
authorPeter Dillinger <peterd@fb.com>
Thu, 22 Jul 2021 00:36:48 +0000 (17:36 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 22 Jul 2021 00:37:53 +0000 (17:37 -0700)
Summary:
Rare TSAN and valgrind failures are caused by unnecessary
reading of a field on the TaskLimiterToken::limiter_ for an assertion
after the token has been released and the limiter destroyed. To simplify
we can simply destroy the token before triggering DB shutdown
(potentially destroying the limiter). This makes the ReleaseOnce logic
unnecessary.

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

Test Plan: watch for more failures in CI

Reviewed By: ajkr

Differential Revision: D29811795

Pulled By: pdillinger

fbshipit-source-id: 135549ebb98fe4f176d1542ed85d5bd6350a40b3

db/db_impl/db_impl_compaction_flush.cc
util/concurrent_task_limiter_impl.cc
util/concurrent_task_limiter_impl.h

index 2b771e360731493886e8992335bfe0715579b657..515bd742215da4aa648df330f8dc1c540020a1d5 100644 (file)
@@ -2785,9 +2785,11 @@ void DBImpl::BackgroundCallCompaction(PrepickedCompaction* prepicked_compaction,
 
     if (prepicked_compaction != nullptr &&
         prepicked_compaction->task_token != nullptr) {
-      // Releasing task tokens affects the DB state, so must be done before we
-      // potentially signal the DB close process to proceed below.
-      prepicked_compaction->task_token->ReleaseOnce();
+      // Releasing task tokens affects (and asserts on) the DB state, so
+      // must be done before we potentially signal the DB close process to
+      // proceed below.
+      prepicked_compaction->task_token.reset();
+      ;
     }
 
     if (made_progress ||
index efa01a17f93ba75e78e2d840e3a74889580ea5a2..2342677d8953131491303cb79d0ef93d48ed1e16 100644 (file)
@@ -59,14 +59,9 @@ ConcurrentTaskLimiter* NewConcurrentTaskLimiter(
   return new ConcurrentTaskLimiterImpl(name, limit);
 }
 
-void TaskLimiterToken::ReleaseOnce() {
-  if (!released_) {
-    --limiter_->outstanding_tasks_;
-    released_ = true;
-  }
+TaskLimiterToken::~TaskLimiterToken() {
+  --limiter_->outstanding_tasks_;
   assert(limiter_->outstanding_tasks_ >= 0);
 }
 
-TaskLimiterToken::~TaskLimiterToken() { ReleaseOnce(); }
-
 }  // namespace ROCKSDB_NAMESPACE
index 0e6cf1466d6d56b075b645974856c349e14b9791..d8c1e03cb07697c41a1d478c7b0030ff211e98ee 100644 (file)
@@ -53,16 +53,11 @@ class ConcurrentTaskLimiterImpl : public ConcurrentTaskLimiter {
 class TaskLimiterToken {
  public:
   explicit TaskLimiterToken(ConcurrentTaskLimiterImpl* limiter)
-      : limiter_(limiter), released_(false) {}
+      : limiter_(limiter) {}
   ~TaskLimiterToken();
-  // Releases the token from the `ConcurrentTaskLimiterImpl` if not already
-  // released.
-  // Not thread-safe.
-  void ReleaseOnce();
 
  private:
   ConcurrentTaskLimiterImpl* limiter_;
-  bool released_;
 
   // no copying allowed
   TaskLimiterToken(const TaskLimiterToken&) = delete;