Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tx_service/include/cc/template_cc_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,7 @@ class TemplateCcMap : public CcMap
// backfill version.
cce->SetCkptTs(req.CommitTs());
OnFlushed(cce, was_dirty);
OnCommittedUpdate(cce, was_dirty);

// Refill mvcc archives.
if (shard_->EnableMvcc())
Expand Down Expand Up @@ -10042,8 +10043,6 @@ class TemplateCcMap : public CcMap
const uint64_t cce_version = cce->CommitTs();

bool was_dirty = cce->IsDirty();
cce->SetCkptTs(commit_ts);
OnFlushed(cce, was_dirty);

if (cce_version < commit_ts)
{
Expand All @@ -10062,6 +10061,11 @@ class TemplateCcMap : public CcMap
return false;
}
}
// Update the payload first, then mark as flushed via
// SetCkptTs. The previous order (SetCkptTs before
// SetCommitTsPayloadStatus) caused the flush bit to be
// set and then immediately cleared, leaving the entry
// dirty with no corresponding dirty-count increment.
cce->SetCommitTsPayloadStatus(commit_ts, status);

if (status == RecordStatus::Deleted)
Expand All @@ -10086,6 +10090,13 @@ class TemplateCcMap : public CcMap
payload->Deserialize(rec_str.c_str(), offset);
cce->AddArchiveRecord(payload, status, commit_ts);
}
// Mark the backfilled version as flushed and reconcile
// dirty-key stats. SetCkptTs must run after
// SetCommitTsPayloadStatus so that the flush bit it sets is
// not immediately cleared by the payload update.
cce->SetCkptTs(commit_ts);
OnFlushed(cce, was_dirty);
OnCommittedUpdate(cce, was_dirty);
if (RangePartitioned && cce->entry_info_.DataStoreSize() == INT32_MAX)
{
cce->entry_info_.SetDataStoreSize(
Expand Down
12 changes: 8 additions & 4 deletions tx_service/src/cc/cc_req_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ bool UpdateCceCkptTsCc::Execute(CcShard &ccs)
VersionedLruEntry<true, true> *v_entry =
static_cast<VersionedLruEntry<true, true> *>(ref.cce_);

assert(v_entry->CommitTs() > 1 && !v_entry->IsPersistent());
assert(v_entry->CommitTs() > 1);
bool was_dirty = v_entry->IsDirty();
v_entry->entry_info_.SetDataStoreSize(ref.post_flush_size_);

Expand All @@ -1176,7 +1176,7 @@ bool UpdateCceCkptTsCc::Execute(CcShard &ccs)
{
VersionedLruEntry<false, true> *v_entry =
static_cast<VersionedLruEntry<false, true> *>(ref.cce_);
assert(v_entry->CommitTs() > 1 && !v_entry->IsPersistent());
assert(v_entry->CommitTs() > 1);
bool was_dirty = v_entry->IsDirty();
v_entry->entry_info_.SetDataStoreSize(ref.post_flush_size_);

Expand All @@ -1192,7 +1192,7 @@ bool UpdateCceCkptTsCc::Execute(CcShard &ccs)
VersionedLruEntry<true, false> *v_entry =
static_cast<VersionedLruEntry<true, false> *>(ref.cce_);

assert(v_entry->CommitTs() > 1 && !v_entry->IsPersistent());
assert(v_entry->CommitTs() > 1);
bool was_dirty = v_entry->IsDirty();
v_entry->SetCkptTs(ref.commit_ts_);
v_entry->ClearBeingCkpt();
Expand All @@ -1203,7 +1203,11 @@ bool UpdateCceCkptTsCc::Execute(CcShard &ccs)
VersionedLruEntry<false, false> *v_entry =
static_cast<VersionedLruEntry<false, false> *>(ref.cce_);

assert(v_entry->CommitTs() > 1 && !v_entry->IsPersistent());
assert(v_entry->CommitTs() > 1);
// The entry may already be persistent if a concurrent
// BackFill marked it as flushed before this checkpoint
// callback ran. That is benign — proceed to reconcile
// the dirty-key stats.
bool was_dirty = v_entry->IsDirty();
v_entry->SetCkptTs(ref.commit_ts_);
v_entry->ClearBeingCkpt();
Expand Down
Loading