Unverified Commit 72869ef8 authored by Li Zhang's avatar Li Zhang Committed by GitHub
Browse files

fix cache verification (#821)

parent cfa80974
...@@ -207,7 +207,7 @@ int BlockManager::Lock(const BlockIds& ids) ...@@ -207,7 +207,7 @@ int BlockManager::Lock(const BlockIds& ids)
for (const auto& i : ids) { for (const auto& i : ids) {
auto& b = blocks_[i]; auto& b = blocks_[i];
FT_CHECK(is_cached(b)); FT_CHECK_WITH_INFO(is_cached(b), to_string(b));
if (++b.use_count == 1) { if (++b.use_count == 1) {
lock.push_back(i); lock.push_back(i);
FT_CHECK(is_active(b)); FT_CHECK(is_active(b));
......
...@@ -93,17 +93,16 @@ void SequenceManager::VerifyAndLockCached(const Sequences& sequences) ...@@ -93,17 +93,16 @@ void SequenceManager::VerifyAndLockCached(const Sequences& sequences)
continue; continue;
} }
FT_CHECK(seq.blocks.size() == seq.block_unique_ids.size()); FT_CHECK(seq.blocks.size() == seq.block_unique_ids.size());
if (need_verify_) { // Verify cache blocks that may be invalidated
const int count = block_manager_->Verify(seq.blocks, seq.block_unique_ids); const int count = block_manager_->Verify(seq.blocks, seq.block_unique_ids);
seq.blocks.resize(count); seq.blocks.resize(count);
seq.block_unique_ids.resize(count); seq.block_unique_ids.resize(count);
}
blocks.insert(blocks.end(), seq.blocks.begin(), seq.blocks.end()); blocks.insert(blocks.end(), seq.blocks.begin(), seq.blocks.end());
seq.cache_len = std::min<int>(seq.cache_len, seq.blocks.size() * block_seq_len_); seq.cache_len = std::min<int>(seq.cache_len, seq.blocks.size() * block_seq_len_);
seq.status = Sequence::kLocked; seq.status = Sequence::kLocked;
} }
block_manager_->Lock(blocks); block_manager_->Lock(blocks);
need_verify_ = false;
} }
void SequenceManager::CommitUnlockAndFree() void SequenceManager::CommitUnlockAndFree()
...@@ -435,7 +434,6 @@ auto SequenceManager::Materialize(Sequences sequences, ...@@ -435,7 +434,6 @@ auto SequenceManager::Materialize(Sequences sequences,
// evict cached blocks -> free // evict cached blocks -> free
if (schedule.evict) { if (schedule.evict) {
block_manager_->Evict(schedule.evict); block_manager_->Evict(schedule.evict);
need_verify_ = true;
} }
// allocate & assign blocks // allocate & assign blocks
......
...@@ -127,8 +127,6 @@ private: ...@@ -127,8 +127,6 @@ private:
int rank_; int rank_;
size_t val_offset_{}; size_t val_offset_{};
bool need_verify_{};
// Use `std::map` to avoid reference invalidation // Use `std::map` to avoid reference invalidation
std::map<uint64_t, Sequence> sequences_; std::map<uint64_t, Sequence> sequences_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment