Skip to content

Commit

Permalink
MB-51805: Pass persistedPrepareSeqno(maxPrepareSeqno) into Checkpoint
Browse files Browse the repository at this point in the history
We set the value of the first Checkpoint to this value to ensure
that the on disk HPS is correctly updated if we partially persist
a snapshot, restart, and find on streaming the rest of the snapshot
that it does not contain any prepares.

Change-Id: I216effaa2d0f12e0c7d4bb0d67d7e2510526e2fa
Reviewed-on: https://review.couchbase.org/c/kv_engine/+/173917
Well-Formed: Restriction Checker
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Paolo Cocchi <paolo.cocchi@couchbase.com>
  • Loading branch information
BenHuddleston committed May 13, 2022
1 parent ef87bb3 commit 027f65f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions engines/ep/src/checkpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Checkpoint::Checkpoint(CheckpointManager& manager,
uint64_t snapEnd,
uint64_t visibleSnapEnd,
std::optional<uint64_t> highCompletedSeqno,
uint64_t highPreparedSeqno,
Vbid vbid,
CheckpointType checkpointType)
: manager(&manager),
Expand All @@ -79,6 +80,7 @@ Checkpoint::Checkpoint(CheckpointManager& manager,
auto& core = stats.coreLocal.get();
core->memOverhead.fetch_add(sizeof(Checkpoint));
core->numCheckpoints++;
this->highPreparedSeqno.reset(highPreparedSeqno);

// the overheadChangedCallback uses the accurately tracked overhead
// from queueAllocator. The above memOverhead stat is "manually"
Expand Down
1 change: 1 addition & 0 deletions engines/ep/src/checkpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class Checkpoint {
uint64_t snapEnd,
uint64_t visibleSnapEnd,
std::optional<uint64_t> highCompletedSeqno,
uint64_t highPreparedSeqno,
Vbid vbid,
CheckpointType checkpointType);

Expand Down
8 changes: 7 additions & 1 deletion engines/ep/src/checkpoint_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ CheckpointManager::CheckpointManager(EPStats& st,
lastSnapEnd,
maxVisibleSeqno,
{},
maxPrepareSeqno,
CheckpointType::Memory);

if (checkpointConfig.isPersistenceEnabled()) {
Expand Down Expand Up @@ -160,6 +161,7 @@ void CheckpointManager::addNewCheckpoint(
snapEndSeqno,
visibleSnapEnd,
highCompletedSeqno,
0, // HPS - default to 0 for now
checkpointType);

// If cursors reached to the end of its current checkpoint, move it to the
Expand Down Expand Up @@ -205,6 +207,7 @@ void CheckpointManager::addOpenCheckpoint(
uint64_t snapEnd,
uint64_t visibleSnapEnd,
std::optional<uint64_t> highCompletedSeqno,
uint64_t highPreparedSeqno,
CheckpointType checkpointType) {
Expects(checkpointList.empty() ||
checkpointList.back()->getState() ==
Expand All @@ -216,13 +219,14 @@ void CheckpointManager::addOpenCheckpoint(
EP_LOG_DEBUG(
"CheckpointManager::addOpenCheckpoint: Create "
"a new open checkpoint: [{}, id:{}, snapStart:{}, snapEnd:{}, "
"visibleSnapEnd:{}, hcs:{}, type:{}]",
"visibleSnapEnd:{}, hcs:{}, hps:{} type:{}]",
vb.getId(),
id,
snapStart,
snapEnd,
visibleSnapEnd,
to_string_or_none(highCompletedSeqno),
highPreparedSeqno,
to_string(checkpointType));

auto ckpt = std::make_unique<Checkpoint>(*this,
Expand All @@ -232,6 +236,7 @@ void CheckpointManager::addOpenCheckpoint(
snapEnd,
visibleSnapEnd,
highCompletedSeqno,
highPreparedSeqno,
vb.getId(),
checkpointType);
// Add an empty-item into the new checkpoint.
Expand Down Expand Up @@ -1140,6 +1145,7 @@ void CheckpointManager::clear(const std::lock_guard<std::mutex>& lh,
lastBySeqno + 1,
maxVisibleSeqno,
{},
0, // HPS=0 because we have correct val on disk and in PDM
CheckpointType::Memory);
resetCursors();
}
Expand Down
1 change: 1 addition & 0 deletions engines/ep/src/checkpoint_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ class CheckpointManager {
uint64_t snapEnd,
uint64_t visibleSnapEnd,
std::optional<uint64_t> highCompletedSeqno,
uint64_t highPreparedSeqno,
CheckpointType checkpointType);

/**
Expand Down

0 comments on commit 027f65f

Please sign in to comment.