Skip to content

Commit

Permalink
Fix data race in infinity::FlushInfo@flush_info::SetIsValidPostingBuf…
Browse files Browse the repository at this point in the history
…fer(bool)
  • Loading branch information
yangzq50 committed Jan 8, 2025
1 parent ce1bd1a commit 17d4833
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/storage/invertedindex/format/flush_info.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ private:
public:
FlushInfo() { Reset(); }

FlushInfo(const FlushInfo &other) { flush_info_ = other.flush_info_; }
FlushInfo(const FlushInfo &other) { flush_info_ = other.flush_info_.load(); }

~FlushInfo() = default;

FlushInfo &operator=(const FlushInfo &other) {
if (this != &other) {
flush_info_ = other.flush_info_.load();
}
return *this;
}

bool IsValidPostingBuffer() const { return GET_BIT_VALUE(MASK_IS_VALID, OFFSET_IS_VALID); }
void SetIsValidPostingBuffer(bool is_valid) {
u64 is_valid_posting_buffer = is_valid ? 1 : 0;
Expand All @@ -38,7 +45,7 @@ public:
static const u64 MASK_FLUSH_LENGTH = 0xFFFFFFFE;
static const u64 MASK_FLUSH_COUNT = 0xFFFFFFFF00000000;

u64 volatile flush_info_;
Atomic<u64> flush_info_{};
};

} // namespace infinity

0 comments on commit 17d4833

Please sign in to comment.