Skip to content

Commit 9a8cf8b

Browse files
Sean04MongoDB Bot
authored andcommitted
SERVER-99077 Add background read size and thread count configuration to live restore API (#31351)
GitOrigin-RevId: df37eb9
1 parent 8f6fe34 commit 9a8cf8b

File tree

8 files changed

+60
-2
lines changed

8 files changed

+60
-2
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,9 @@ WORKSPACE.bazel @10gen/devprod-build @svc-auto-approve-bot
15731573
# The following patterns are parsed from ./src/mongo/db/modules/enterprise/jstests/live_import/OWNERS.yml
15741574
/src/mongo/db/modules/enterprise/jstests/live_import/**/* @10gen/server-backup-restore @svc-auto-approve-bot
15751575

1576+
# The following patterns are parsed from ./src/mongo/db/modules/enterprise/jstests/live_restore/OWNERS.yml
1577+
/src/mongo/db/modules/enterprise/jstests/live_restore/**/* @10gen/server-backup-restore @svc-auto-approve-bot
1578+
15761579
# The following patterns are parsed from ./src/mongo/db/modules/enterprise/jstests/no_passthrough/OWNERS.yml
15771580
/src/mongo/db/modules/enterprise/jstests/no_passthrough/**/* @10gen/query-integration-fle @10gen/server-security @svc-auto-approve-bot
15781581

buildscripts/resmokeconfig/suites/no_passthrough.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ selector:
1111
- jstests/noPassthrough/**/*.js
1212
- src/mongo/db/modules/*/jstests/hot_backups/**/*.js
1313
- src/mongo/db/modules/*/jstests/live_import/*.js
14+
- src/mongo/db/modules/*/jstests/live_restore/*.js
1415
- src/mongo/db/modules/*/jstests/no_passthrough/*.js
1516

1617
# Self-tests for the Concurrency testing framework are run as part of this test suite.
@@ -26,6 +27,7 @@ executor:
2627
- jstests/noPassthrough/backup*.js
2728
- jstests/noPassthrough/oplog_writes_only_permitted_on_standalone.js
2829
- jstests/noPassthrough/wt_unclean_shutdown.js
30+
- src/mongo/db/modules/*/jstests/live_restore/*.js
2931
- src/mongo/db/modules/enterprise/jstests/hot_backups/**/*.js
3032
config:
3133
shell_options:

src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,21 @@ Status WiredTigerGlobalOptions::validateWiredTigerCompressor(const std::string&
7575
return Status::OK();
7676
}
7777

78+
Status WiredTigerGlobalOptions::validateWiredTigerLiveRestoreReadSizeMB(const int value) {
79+
if (value < 1) {
80+
return {ErrorCodes::BadValue,
81+
"Live restore read size must be greater than or equal to 1MB."};
82+
}
83+
84+
if (value > 16) {
85+
return {ErrorCodes::BadValue, "Live restore read size must be less than or equal to 16MB."};
86+
}
87+
88+
if ((value & (value - 1)) != 0) {
89+
return {ErrorCodes::BadValue, "Live restore read size must be a power of two."};
90+
}
91+
92+
return Status::OK();
93+
}
94+
7895
} // namespace mongo

src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class WiredTigerGlobalOptions {
4848
zstdCompressorLevel(0),
4949
directoryForIndexes(false),
5050
maxCacheOverflowFileSizeGBDeprecated(0),
51+
liveRestoreThreads(0),
52+
liveRestoreReadSizeMB(0),
5153
useCollectionPrefixCompression(false),
5254
useIndexPrefixCompression(false){};
5355

@@ -61,6 +63,8 @@ class WiredTigerGlobalOptions {
6163
double maxCacheOverflowFileSizeGBDeprecated;
6264
std::string engineConfig;
6365
std::string liveRestoreSource;
66+
int liveRestoreThreads;
67+
double liveRestoreReadSizeMB;
6468

6569
std::string collectionBlockCompressor;
6670
bool useCollectionPrefixCompression;
@@ -69,6 +73,8 @@ class WiredTigerGlobalOptions {
6973
std::string indexConfig;
7074

7175
static Status validateWiredTigerCompressor(const std::string&);
76+
static Status validateWiredTigerLiveRestoreReadSizeMB(int);
77+
7278

7379
/**
7480
* Returns current history file size limit in MB.

src/mongo/db/storage/wiredtiger/wiredtiger_global_options.idl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,25 @@ configs:
102102
arg_vartype: String
103103
cpp_varname: 'wiredTigerGlobalOptions.liveRestoreSource'
104104
short_name: wiredTigerLiveRestoreSource
105+
"storage.wiredTiger.engineConfig.wiredTigerLiveRestoreThreads":
106+
description: 'Number of live restore background threads.'
107+
arg_vartype: Int
108+
cpp_varname: 'wiredTigerGlobalOptions.liveRestoreThreads'
109+
short_name: wiredTigerLiveRestoreThreads
110+
validator:
111+
gte: 0
112+
lte: 12
113+
default: 8
114+
"storage.wiredTiger.engineConfig.wiredTigerLiveRestoreReadSizeMB":
115+
description: >-
116+
'The read size for data migration, in MB, must be a power of two.
117+
This setting is a best effort. It does not force every read to be this size.'
118+
arg_vartype: Int
119+
cpp_varname: 'wiredTigerGlobalOptions.liveRestoreReadSizeMB'
120+
short_name: wiredTigerLiveRestoreReadSizeMB
121+
validator:
122+
callback: WiredTigerGlobalOptions::validateWiredTigerLiveRestoreReadSizeMB
123+
default: 1
105124

106125
# WiredTiger collection options
107126
"storage.wiredTiger.collectionConfig.blockCompressor":

src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,9 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName,
483483

484484
if (!wiredTigerGlobalOptions.liveRestoreSource.empty() && !_ephemeral) {
485485
ss << "live_restore=(enabled=true,path=\"" << wiredTigerGlobalOptions.liveRestoreSource
486-
<< "\"),";
486+
<< "\",threads_max=" << wiredTigerGlobalOptions.liveRestoreThreads
487+
<< ",read_size=" << wiredTigerGlobalOptions.liveRestoreReadSizeMB << "MB"
488+
<< "),";
487489
}
488490

489491
ss << WiredTigerCustomizationHooks::get(getGlobalServiceContext())

src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,14 @@ logv2::LogComponent getWTLogComponent(const BSONObj& obj) {
530530
return logv2::LogComponent::kWiredTigerCompact;
531531
case WT_VERB_EVICTION:
532532
return logv2::LogComponent::kWiredTigerEviction;
533+
case WT_VERB_FILEOPS:
534+
return logv2::LogComponent::kWiredTigerFileOps;
533535
case WT_VERB_HS:
534536
case WT_VERB_HS_ACTIVITY:
535537
return logv2::LogComponent::kWiredTigerHS;
538+
case WT_VERB_LIVE_RESTORE:
539+
case WT_VERB_LIVE_RESTORE_PROGRESS:
540+
return logv2::LogComponent::kWiredTigerLiveRestore;
536541
case WT_VERB_RECOVERY:
537542
case WT_VERB_RECOVERY_PROGRESS:
538543
return logv2::LogComponent::kWiredTigerRecovery;
@@ -1165,7 +1170,9 @@ std::string WiredTigerUtil::generateWTVerboseConfiguration() {
11651170
{logv2::LogComponent::kWiredTigerCheckpoint, "checkpoint"},
11661171
{logv2::LogComponent::kWiredTigerCompact, "compact"},
11671172
{logv2::LogComponent::kWiredTigerEviction, "eviction"},
1173+
{logv2::LogComponent::kWiredTigerFileOps, "fileops"},
11681174
{logv2::LogComponent::kWiredTigerHS, "history_store"},
1175+
{logv2::LogComponent::kWiredTigerLiveRestore, "live_restore"},
11691176
{logv2::LogComponent::kWiredTigerRecovery, "recovery"},
11701177
{logv2::LogComponent::kWiredTigerRTS, "rts"},
11711178
{logv2::LogComponent::kWiredTigerSalvage, "salvage"},
@@ -1182,7 +1189,7 @@ std::string WiredTigerUtil::generateWTVerboseConfiguration() {
11821189
cfg << "verbose=[";
11831190

11841191
// Enable WiredTiger progress messages.
1185-
cfg << "recovery_progress:1,checkpoint_progress:1,compact_progress:1";
1192+
cfg << "recovery_progress:1,checkpoint_progress:1,compact_progress:1,live_restore_progress:1";
11861193

11871194
// Process each LOGV2 WiredTiger component and set the desired verbosity level.
11881195
for (const auto& [component, componentStr] : *wtVerboseComponents) {

src/mongo/logv2/log_component.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ namespace mongo::logv2 {
8585
X(kWiredTigerCheckpoint, , "wtCheckpoint" , "WTCHKPT" , kWiredTiger) \
8686
X(kWiredTigerCompact, , "wtCompact" , "WTCMPCT" , kWiredTiger) \
8787
X(kWiredTigerEviction, , "wtEviction" , "WTEVICT" , kWiredTiger) \
88+
X(kWiredTigerFileOps, , "wtFileOps" , "WTFILEOPS", kWiredTiger) \
8889
X(kWiredTigerHS, , "wtHS" , "WTHS" , kWiredTiger) \
90+
X(kWiredTigerLiveRestore, , "wtLiveRestore" , "WTLR" , kWiredTiger) \
8991
X(kWiredTigerRecovery, , "wtRecovery" , "WTRECOV" , kWiredTiger) \
9092
X(kWiredTigerRTS, , "wtRTS" , "WTRTS" , kWiredTiger) \
9193
X(kWiredTigerSalvage, , "wtSalvage" , "WTSLVG" , kWiredTiger) \

0 commit comments

Comments
 (0)