fix(tx): guard parallel writes to local result (#2417)

This commit is contained in:
Vladislav 2024-01-15 13:51:30 +03:00 committed by GitHub
parent 39e7e5ad87
commit 078db5caae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -484,14 +484,16 @@ bool Transaction::RunInShard(EngineShard* shard, bool txq_ooo) {
local_result_ = status;
} else {
if (status == OpStatus::OUT_OF_MEMORY) {
absl::base_internal::SpinLockHolder lk{&local_result_mu_};
CHECK(local_result_ == OpStatus::OK || local_result_ == OpStatus::OUT_OF_MEMORY);
local_result_ = status;
} else {
CHECK_EQ(OpStatus::OK, status);
}
}
} catch (std::bad_alloc&) {
// TODO: to log at most once per sec.
LOG_FIRST_N(ERROR, 16) << " out of memory";
LOG_FIRST_N(ERROR, 16) << " out of memory"; // TODO: to log at most once per sec.
absl::base_internal::SpinLockHolder lk{&local_result_mu_};
local_result_ = OpStatus::OUT_OF_MEMORY;
} catch (std::exception& e) {
LOG(FATAL) << "Unexpected exception " << e.what();