fix(server): Reorder ExecuteAsync callback seqlock check (#873)

fix(server): Reoder cb check

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2023-02-24 22:55:56 +03:00 committed by GitHub
parent e54f44a0f5
commit be4ef01975
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -791,12 +791,8 @@ void Transaction::ExecuteAsync() {
auto cb = [seq, this] { auto cb = [seq, this] {
EngineShard* shard = EngineShard::tlocal(); EngineShard* shard = EngineShard::tlocal();
uint16_t local_mask = GetLocalMask(shard->shard_id()); uint32_t seq_after = seqlock_.load(memory_order_acquire);
bool should_poll = (seq_after == seq) && (GetLocalMask(shard->shard_id()) & ARMED);
// we use fetch_add with release trick to make sure that local_mask is loaded before
// we load seq_after. We could gain similar result with "atomic_thread_fence(acquire)"
uint32_t seq_after = seqlock_.fetch_add(0, memory_order_release);
bool should_poll = (seq_after == seq) && (local_mask & ARMED);
DVLOG(2) << "PollExecCb " << DebugId() << " sid(" << shard->shard_id() << ") " DVLOG(2) << "PollExecCb " << DebugId() << " sid(" << shard->shard_id() << ") "
<< run_count_.load(memory_order_relaxed) << ", should_poll: " << should_poll; << run_count_.load(memory_order_relaxed) << ", should_poll: " << should_poll;