Skip to content

Commit d0c66e6

Browse files
author
Gerrit Code Review
committed
Merge "Merge branch 'neo' into 'master'"
2 parents 6e11dc8 + d5971bc commit d0c66e6

35 files changed

+1081
-264
lines changed

daemon/mc_time.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,12 @@ void mc_time_clock_tick() {
236236
if (cb::logger::get() != nullptr) {
237237
/* log all variables used in time calculations */
238238
LOG_WARNING(
239-
"system clock changed? difference = {}, "
239+
"system clock changed? Expected delta of {}s ±1 since "
240+
"last check, actual difference = {}s, "
240241
"memcached_epoch = {}, "
241242
"memcached_uptime = {}, new memcached_epoch = {}, "
242243
"next check {}",
244+
memcached_check_system_time,
243245
difference,
244246
memcached_epoch.load(),
245247
memcached_uptime.load(),

engines/ep/configuration.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@
766766
},
767767
"max_checkpoints": {
768768
"default": "10",
769-
"descr": "Desired/expected max number of checkpoints in each VBucket for balanced systems where the load is approximately evenly spread across vbuckets. That is NOT a hard limit (see also max_checkpoints_hard_limit_multiplier). Directly used in the auto-computation for the actual checkpoint_max_size.",
769+
"descr": "Max number of checkpoints in each VBucket.",
770770
"dynamic": true,
771771
"type": "size_t",
772772
"validator": {
@@ -775,17 +775,6 @@
775775
}
776776
}
777777
},
778-
"max_checkpoints_hard_limit_multiplier" : {
779-
"default": "100",
780-
"descr": "Defines the actual max checkpoints (per vbucket) hard limit as (max_checkpoints * multiplier). The multiplier doesn't affect the auto checkpoint_max_size computation.",
781-
"dynamic": true,
782-
"type": "size_t",
783-
"validator": {
784-
"range": {
785-
"min": 1
786-
}
787-
}
788-
},
789778
"max_failover_entries": {
790779
"default": "25",
791780
"descr": "maximum number of failover log entries",

engines/ep/management/cbepctl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ Available params for "set":
198198
item_num_based_new_chk - true if a new checkpoint can be created based
199199
on.
200200
the number of items in the open checkpoint.
201-
max_checkpoints - Desired/expected max number of checkpoints in each VBucket for balanced systems where the load is approximately evenly spread across vbuckets. That is NOT a hard limit (see also max_checkpoints_hard_limit_multiplier). Directly used in the auto-computation for the actual checkpoint_max_size.
202-
max_checkpoints_hard_limit_multiplier - Defines the actual max checkpoints (per vbucket) hard limit as (max_checkpoints * multiplier). The multiplier doesn't affect the auto checkpoint_max_size computation.
201+
max_checkpoints - Max number of checkpoints allowed per vbucket.
203202
checkpoint_memory_ratio - Max ratio of the bucket quota that can be allocated in checkpoints.
204203
checkpoint_memory_recovery_upper_mark - Fraction of the checkpoint quota (as computed by checkpoint_memory_ratio) that triggers attempt of memory releasing from checkpoint.
205204
checkpoint_memory_recovery_lower_mark - Fraction of the checkpoint quota (as computed by checkpoint_memory_ratio) that represents the target of checkpoint memory recovery. Memory recovery yields when reached.

engines/ep/src/checkpoint_config.cc

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,33 @@ std::ostream& operator<<(std::ostream& os, const CheckpointRemoval& mode) {
4444
*/
4545
class CheckpointConfig::ChangeListener : public ValueChangedListener {
4646
public:
47-
explicit ChangeListener(const Configuration& config,
48-
CheckpointConfig& ckptConfig)
49-
: config(config), checkpointConfig(ckptConfig) {
47+
explicit ChangeListener(CheckpointConfig& c) : config(c) {
5048
}
5149

5250
void sizeValueChanged(const std::string& key, size_t value) override {
53-
if (key == "chk_period") {
54-
checkpointConfig.setCheckpointPeriod(value);
55-
} else if (key == "chk_max_items") {
56-
checkpointConfig.setCheckpointMaxItems(value);
57-
} else if (key == "max_checkpoints") {
58-
const auto newMaxCheckpoints =
59-
value * config.getMaxCheckpointsHardLimitMultiplier();
60-
checkpointConfig.setMaxCheckpoints(newMaxCheckpoints);
61-
} else if (key == "max_checkpoints_hard_limit_multiplier") {
62-
const auto newMaxCheckpoints = config.getMaxCheckpoints() * value;
63-
checkpointConfig.setMaxCheckpoints(newMaxCheckpoints);
51+
if (key.compare("chk_period") == 0) {
52+
config.setCheckpointPeriod(value);
53+
} else if (key.compare("chk_max_items") == 0) {
54+
config.setCheckpointMaxItems(value);
55+
} else if (key.compare("max_checkpoints") == 0) {
56+
config.setMaxCheckpoints(value);
6457
}
6558
}
6659

6760
void booleanValueChanged(const std::string& key, bool value) override {
6861
if (key.compare("item_num_based_new_chk") == 0) {
69-
checkpointConfig.allowItemNumBasedNewCheckpoint(value);
62+
config.allowItemNumBasedNewCheckpoint(value);
7063
}
7164
}
7265

7366
private:
74-
const Configuration& config;
75-
CheckpointConfig& checkpointConfig;
67+
CheckpointConfig& config;
7668
};
7769

7870
CheckpointConfig::CheckpointConfig(Configuration& config)
7971
: checkpointPeriod(config.getChkPeriod()),
8072
checkpointMaxItems(config.getChkMaxItems()),
81-
maxCheckpoints(config.getMaxCheckpoints() *
82-
config.getMaxCheckpointsHardLimitMultiplier()),
73+
maxCheckpoints(config.getMaxCheckpoints()),
8374
itemNumBasedNewCheckpoint(config.isItemNumBasedNewChk()),
8475
persistenceEnabled(config.getBucketType() == "persistent"),
8576
checkpointRemovalMode(
@@ -88,22 +79,19 @@ CheckpointConfig::CheckpointConfig(Configuration& config)
8879

8980
void CheckpointConfig::addConfigChangeListener(
9081
EventuallyPersistentEngine& engine) {
91-
auto& config = engine.getConfiguration();
92-
auto& ckptConfig = engine.getCheckpointConfig();
93-
config.addValueChangedListener(
94-
"chk_period", std::make_unique<ChangeListener>(config, ckptConfig));
95-
config.addValueChangedListener(
82+
Configuration& configuration = engine.getConfiguration();
83+
configuration.addValueChangedListener(
84+
"chk_period",
85+
std::make_unique<ChangeListener>(engine.getCheckpointConfig()));
86+
configuration.addValueChangedListener(
9687
"chk_max_items",
97-
std::make_unique<ChangeListener>(config, ckptConfig));
98-
config.addValueChangedListener(
88+
std::make_unique<ChangeListener>(engine.getCheckpointConfig()));
89+
configuration.addValueChangedListener(
9990
"max_checkpoints",
100-
std::make_unique<ChangeListener>(config, ckptConfig));
101-
config.addValueChangedListener(
102-
"max_checkpoints_hard_limit_multiplier",
103-
std::make_unique<ChangeListener>(config, ckptConfig));
104-
config.addValueChangedListener(
91+
std::make_unique<ChangeListener>(engine.getCheckpointConfig()));
92+
configuration.addValueChangedListener(
10593
"item_num_based_new_chk",
106-
std::make_unique<ChangeListener>(config, ckptConfig));
94+
std::make_unique<ChangeListener>(engine.getCheckpointConfig()));
10795
}
10896

10997
void CheckpointConfig::setCheckpointPeriod(size_t value) {

engines/ep/src/checkpoint_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ class CheckpointConfig {
5555
return checkpointRemovalMode;
5656
}
5757

58+
// @todo: Test only. Remove as soon as param made dynamic in EPConfig.
59+
void setCheckpointRemovalMode(CheckpointRemoval mode) {
60+
checkpointRemovalMode = mode;
61+
}
62+
5863
protected:
5964
friend class EventuallyPersistentEngine;
6065
friend class SynchronousEPEngine;

engines/ep/src/checkpoint_manager.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,13 @@ CheckpointManager::ItemsForCursor CheckpointManager::getItemsForCursor(
971971
if (enteredNewCp) {
972972
const auto& checkpoint = **cursor.getCheckpoint();
973973
result.checkpointType = checkpoint.getCheckpointType();
974-
result.ranges.push_back({{checkpoint.getSnapshotStartSeqno(),
975-
checkpoint.getSnapshotEndSeqno()},
976-
checkpoint.getHighCompletedSeqno(),
977-
checkpoint.getHighPreparedSeqno()});
974+
result.ranges.push_back(
975+
{{checkpoint.getSnapshotStartSeqno(),
976+
checkpoint.getSnapshotEndSeqno()},
977+
checkpoint.getHighCompletedSeqno(),
978+
checkpoint.getHighPreparedSeqno(),
979+
checkpoint.getState() ==
980+
checkpoint_state::CHECKPOINT_CLOSED});
978981
enteredNewCp = false;
979982

980983
// As we cross into new checkpoints, update the maxDeletedRevSeqno

engines/ep/src/checkpoint_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ struct CheckpointSnapshotRange {
6060
// HPS that should be flushed when the entire range has been persisted.
6161
// This is the seqno of the latest prepare in this checkpoint.
6262
std::optional<uint64_t> highPreparedSeqno = {};
63+
// Is the checkpoint closed
64+
bool isClosed = false;
6365
};
6466

6567
/**

engines/ep/src/checkpoint_remover.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ CheckpointMemRecoveryTask::attemptCursorDropping() {
183183
case CheckpointRemoval::Eager: {
184184
#if CB_DEVELOPMENT_ASSERTS
185185
Expects(manager.removeClosedUnrefCheckpoints().count == 0);
186+
#else
187+
// MB-51408: We need to make the call for keeping executing the
188+
// inner checkpoint creation logic - minimal fix for Neo.
189+
manager.removeClosedUnrefCheckpoints();
186190
#endif
187191
break;
188192
}
@@ -244,6 +248,10 @@ bool CheckpointMemRecoveryTask::runInner() {
244248
// This is not cheap to verify, as it requires scanning every
245249
// vbucket, so is only checked if dev asserts are on.
246250
Expects(attemptCheckpointRemoval().second == 0);
251+
#else
252+
// MB-51408: We need to make the call for keeping executing the inner
253+
// checkpoint creation logic - minimal fix for Neo.
254+
attemptCheckpointRemoval();
247255
#endif
248256
break;
249257
}

engines/ep/src/dcp/active_stream.cc

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,32 @@ void ActiveStream::processItems(
11771177
*/
11781178
std::optional<uint64_t> highNonVisibleSeqno;
11791179
for (auto& qi : outstandingItemsResult.items) {
1180+
if (qi->getOperation() == queue_op::checkpoint_end) {
1181+
// At the end of each checkpoint remove its snapshot range, so
1182+
// we don't use it to set nextSnapStart for the next checkpoint.
1183+
// If statement ensures that we have indeed completed the
1184+
// snapshot range by checking that checkpoint_end seqno is
1185+
// greater than the end of the range. Also account for an edge
1186+
// case where we have closed checkpoint who's checkpoint_end is
1187+
// equal to snapshot end seqno. This can happen when snapshots
1188+
// partially received by a replica which is then promoted to
1189+
// active
1190+
auto rangeItr = outstandingItemsResult.ranges.begin();
1191+
auto snapEnd = static_cast<int64_t>(rangeItr->getEnd());
1192+
if (snapEnd < qi->getBySeqno() ||
1193+
(rangeItr->isClosed && snapEnd == qi->getBySeqno())) {
1194+
outstandingItemsResult.ranges.erase(rangeItr);
1195+
} else {
1196+
log(spdlog::level::level_enum::err,
1197+
"ActiveStream::processItems checkpoint_end:{} "
1198+
"should not be in the current snapshot range "
1199+
"s:{}->e:{}",
1200+
qi->getBySeqno(),
1201+
rangeItr->getStart(),
1202+
rangeItr->getEnd());
1203+
}
1204+
}
1205+
11801206
if (qi->getOperation() == queue_op::checkpoint_start) {
11811207
/* if there are already other mutations, then they belong to the
11821208
previous checkpoint and hence we must create a snapshot and
@@ -1205,8 +1231,6 @@ void ActiveStream::processItems(
12051231

12061232
nextSnapStart =
12071233
outstandingItemsResult.ranges.begin()->getStart();
1208-
outstandingItemsResult.ranges.erase(
1209-
outstandingItemsResult.ranges.begin());
12101234

12111235
continue;
12121236
}

0 commit comments

Comments
 (0)