Skip to content

Commit f534348

Browse files
committed
MB-48467: Add config for magma MinCheckpointCreationInterval
Magma will create a checkpoint if the overhead of the checkpoint queue exceeds 10% of the data size including fragmentation. It is configured to 2% per checkpoint via magma_checkpoint_threshold in config.json which results in 10% since magma holds a max of five checkpoints. During data load or overwrite workloads where the data size is small, this can result in agressive checkpoint creation. This patch adds MinCheckpointCreationInterval config to rate limit checkpoint creation in such workloads. Also set the config to zero for tests which require creation of a checkpoint every batch. Change-Id: If09b7fd6d7615a583d8f99c050682c66b1842727 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/163750 Reviewed-by: Ben Huddleston <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 326f424 commit f534348

File tree

9 files changed

+42
-9
lines changed

9 files changed

+42
-9
lines changed

engines/ep/configuration.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,13 @@
12471247
"magma_checkpoint_interval": {
12481248
"default": "120",
12491249
"dynamic": false,
1250-
"descr": "Frequency of checkpoint interval; in seconds. A checkpoint interval provides a rollback point to which the data store can rollback to in the event of a failure.",
1250+
"descr": "Frequency of checkpoint interval; in seconds. A checkpoint provides a rollback point to which the data store can rollback to in the event of a failure.",
1251+
"type": "size_t"
1252+
},
1253+
"magma_min_checkpoint_interval": {
1254+
"default": "1",
1255+
"dynamic": false,
1256+
"descr": "Minimum interval between two checkpoints; in seconds. Prevents excessive creation of checkpoints.",
12511257
"type": "size_t"
12521258
},
12531259
"magma_checkpoint_threshold": {

engines/ep/src/kvstore/magma-kvstore/magma-kvstore.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,8 @@ MagmaKVStore::MagmaKVStore(MagmaKVStoreConfig& configuration)
494494
configuration.getMagmaCheckpointInterval();
495495
configuration.magmaCfg.CheckpointCreationThreshold =
496496
configuration.getMagmaCheckpointThreshold();
497+
configuration.magmaCfg.MinCheckpointCreationInterval =
498+
configuration.getMagmaMinCheckpointInterval();
497499
configuration.magmaCfg.HeartbeatInterval =
498500
configuration.getMagmaHeartbeatInterval();
499501
configuration.magmaCfg.MinValueSize =

engines/ep/src/kvstore/magma-kvstore/magma-kvstore_config.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ MagmaKVStoreConfig::MagmaKVStoreConfig(Configuration& config,
6767
magmaMaxCheckpoints = config.getMagmaMaxCheckpoints();
6868
magmaCheckpointInterval =
6969
std::chrono::milliseconds(1s * config.getMagmaCheckpointInterval());
70+
magmaMinCheckpointInterval = std::chrono::milliseconds(
71+
1s * config.getMagmaMinCheckpointInterval());
7072
magmaCheckpointThreshold = config.getMagmaCheckpointThreshold();
7173
magmaHeartbeatInterval =
7274
std::chrono::milliseconds(1s * config.getMagmaHeartbeatInterval());

engines/ep/src/kvstore/magma-kvstore/magma-kvstore_config.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ class MagmaKVStoreConfig : public KVStoreConfig {
5757
void setMagmaCheckpointInterval(std::chrono::milliseconds val) {
5858
magmaCheckpointInterval = val;
5959
}
60+
std::chrono::milliseconds getMagmaMinCheckpointInterval() const {
61+
return magmaMinCheckpointInterval;
62+
}
63+
void setMagmaMinCheckpointInterval(std::chrono::milliseconds val) {
64+
magmaMinCheckpointInterval = val;
65+
}
6066
float getMagmaCheckpointThreshold() const {
6167
return magmaCheckpointThreshold;
6268
}
@@ -230,6 +236,9 @@ class MagmaKVStoreConfig : public KVStoreConfig {
230236
// Time interval between checkpoints
231237
std::chrono::milliseconds magmaCheckpointInterval;
232238

239+
// Minimum time interval between two checkpoints
240+
std::chrono::milliseconds magmaMinCheckpointInterval;
241+
233242
// Fraction of total data before checkpoint is created
234243
float magmaCheckpointThreshold;
235244

engines/ep/src/kvstore/nexus-kvstore/nexus-kvstore-config.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ NexusKVStoreConfig::NexusKVStoreConfig(Configuration& config,
5050
magmaKVStoreConfig.setMagmaSyncEveryBatch(true);
5151
magmaKVStoreConfig.setMagmaCheckpointInterval(
5252
std::chrono::milliseconds(0));
53+
magmaKVStoreConfig.setMagmaMinCheckpointInterval(
54+
std::chrono::milliseconds(0));
5355
#endif
5456
} else if (primaryBackend == "couchdb") {
5557
// Couchstore has an optimization that forces rollback to zero should
@@ -66,6 +68,8 @@ NexusKVStoreConfig::NexusKVStoreConfig(Configuration& config,
6668
magmaKVStoreConfig.setMagmaSyncEveryBatch(true);
6769
magmaKVStoreConfig.setMagmaCheckpointInterval(
6870
std::chrono::milliseconds(0));
71+
magmaKVStoreConfig.setMagmaMinCheckpointInterval(
72+
std::chrono::milliseconds(0));
6973
#endif
7074
} else if (primaryBackend == "couchdb") {
7175
// Couchstore has an optimization that forces rollback to zero should

engines/ep/tests/ep_testsuite.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7011,6 +7011,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
70117011
"ep_item_num_based_new_chk",
70127012
"ep_magma_sync_every_batch",
70137013
"ep_magma_checkpoint_interval",
7014+
"ep_magma_min_checkpoint_interval",
70147015
"ep_magma_checkpoint_threshold",
70157016
"ep_magma_delete_frag_ratio",
70167017
"ep_magma_delete_memtable_writecache",
@@ -7321,6 +7322,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
73217322
"ep_num_writer_threads",
73227323
"ep_magma_sync_every_batch",
73237324
"ep_magma_checkpoint_interval",
7325+
"ep_magma_min_checkpoint_interval",
73247326
"ep_magma_checkpoint_threshold",
73257327
"ep_magma_delete_frag_ratio",
73267328
"ep_magma_delete_memtable_writecache",
@@ -8689,6 +8691,7 @@ BaseTestCase testsuite_testcases[] = {
86898691
test_setup,
86908692
teardown,
86918693
"magma_checkpoint_interval=0;"
8694+
"magma_min_checkpoint_interval=0;"
86928695
"magma_sync_every_batch=true",
86938696
/* TODO RDB: Needs stat:ep_db_data_size */
86948697
prepare_ep_bucket_skip_broken_under_rocks,
@@ -8698,6 +8701,7 @@ BaseTestCase testsuite_testcases[] = {
86988701
test_setup,
86998702
teardown,
87008703
"magma_checkpoint_interval=0;"
8704+
"magma_min_checkpoint_interval=0;"
87018705
"magma_sync_every_batch=true",
87028706
prepare,
87038707
cleanup),
@@ -8779,6 +8783,7 @@ BaseTestCase testsuite_testcases[] = {
87798783
test_setup,
87808784
teardown,
87818785
"magma_checkpoint_interval=0;"
8786+
"magma_min_checkpoint_interval=0;"
87828787
"magma_sync_every_batch=true",
87838788
/* TODO RDB: DB file size is not reported correctly */
87848789
prepare_ep_bucket_skip_broken_under_rocks,

engines/ep/tests/ep_testsuite_dcp.cc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8433,10 +8433,12 @@ BaseTestCase testsuite_testcases[] = {
84338433
test_chk_manager_rollback,
84348434
test_setup,
84358435
teardown,
8436-
// 'magma_checkpoint_interval=0' allows us to create more than
8437-
// one checkpoint in less than 2mins
8436+
// 'magma_checkpoint_interval=0' and
8437+
// 'magma_min_checkpoint_interval=0' allows us to create more
8438+
// than one checkpoint in less than 2mins
84388439
"dcp_flow_control_policy=none;dcp_enable_noop=false;"
8439-
"magma_checkpoint_interval=0;",
8440+
"magma_checkpoint_interval=0;"
8441+
"magma_min_checkpoint_interval=0;",
84408442
// TODO RDB: implement getItemCount.
84418443
// Needs the 'curr_items_tot' stat.
84428444
prepare_skip_broken_under_rocks,
@@ -8456,13 +8458,14 @@ BaseTestCase testsuite_testcases[] = {
84568458
test_partialrollback_for_consumer,
84578459
test_setup,
84588460
teardown,
8459-
// 'magma_checkpoint_interval=0' allows us to create more than
8460-
// one checkpoint in less than 2mins.
8461-
// 'magma_max_checkpoints=10' the max number of checkpoints that
8462-
// can be rolled back.
8461+
// 'magma_checkpoint_interval=0;magma_min_checkpoint_interval=0;'
8462+
// allows us to create more than one checkpoint in less than
8463+
// 2mins. 'magma_max_checkpoints=10' the max number of
8464+
// checkpoints that can be rolled back.
84638465
// 'magma_sync_every_batch=true' makes magma behaviour
84648466
// like couchstore, creating a checkpoint for every flush batch.
8465-
"dcp_enable_noop=false;magma_checkpoint_interval=0;"
8467+
"dcp_enable_noop=false;"
8468+
"magma_checkpoint_interval=0;magma_min_checkpoint_interval=0;"
84668469
"magma_max_checkpoints=10;magma_sync_every_batch=true",
84678470
// TODO RDB: implement getItemCount.
84688471
// Needs the 'vb_replica_curr_items' stat.

engines/ep/tests/module_tests/item_pager_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class STBucketQuotaTest : public STParameterizedBucketTest {
5959
config_string +=
6060
"ht_size=47;"
6161
"magma_checkpoint_interval=0;"
62+
"magma_min_checkpoint_interval=0;"
6263
"magma_sync_every_batch=true";
6364

6465
STParameterizedBucketTest::SetUp();

engines/ep/tests/module_tests/test_helpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static std::string magmaConfig =
3939
static std::string magmaRollbackConfig =
4040
"magma_max_checkpoints=10;"
4141
"magma_checkpoint_interval=0;"
42+
"magma_min_checkpoint_interval=0;"
4243
"magma_sync_every_batch=true";
4344

4445
class VBucket;

0 commit comments

Comments
 (0)