diff options
author | Levi Tamasi <ltamasi@meta.com> | 2024-08-02 14:11:08 -0700 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2024-08-02 14:11:08 -0700 |
commit | 2e8a1a14eff1ef1532be92face831e76d4d1fcf0 (patch) | |
tree | 630dc462d60dc95a4463b8aeddeff038e61721d0 /db/db_impl/db_impl_write.cc | |
parent | 9245550e8bc7fdb71f2ce191c73b40e6affec64e (diff) |
Fix a data race affecting the background error status (#12910)
Summary:
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12910
There is currently a call to `GetBGError()` in `DBImpl::WriteImplWALOnly()` where the DB mutex is (incorrectly) not held, leading to a data race. Technically, we could acquire the mutex here but instead, the patch removes the affected check altogether, since the same check is already performed (in a thread-safe manner) in the subsequent call to `PreprocessWrite()`.
Reviewed By: cbi42
Differential Revision: D60682008
fbshipit-source-id: 54b67975dcf57d67c068cac71e8ada09a1793ec5
Diffstat (limited to 'db/db_impl/db_impl_write.cc')
-rw-r--r-- | db/db_impl/db_impl_write.cc | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/db/db_impl/db_impl_write.cc b/db/db_impl/db_impl_write.cc index ec5283ad9..d6899502a 100644 --- a/db/db_impl/db_impl_write.cc +++ b/db/db_impl/db_impl_write.cc @@ -969,21 +969,17 @@ Status DBImpl::WriteImplWALOnly( assert(w.state == WriteThread::STATE_GROUP_LEADER); if (publish_last_seq == kDoPublishLastSeq) { - Status status; - // Currently we only use kDoPublishLastSeq in unordered_write assert(immutable_db_options_.unordered_write); - WriteContext write_context; - if (error_handler_.IsDBStopped()) { - status = error_handler_.GetBGError(); - } + // TODO(myabandeh): Make preliminary checks thread-safe so we could do them // without paying the cost of obtaining the mutex. - if (status.ok()) { - LogContext log_context; - status = PreprocessWrite(write_options, &log_context, &write_context); - WriteStatusCheckOnLocked(status); - } + LogContext log_context; + WriteContext write_context; + Status status = + PreprocessWrite(write_options, &log_context, &write_context); + WriteStatusCheckOnLocked(status); + if (!status.ok()) { WriteThread::WriteGroup write_group; write_thread->EnterAsBatchGroupLeader(&w, &write_group); |