Skip to content

Commit 4b4a508

Browse files
committed
code review from madelyn
Signed-off-by: Binbin <[email protected]>
1 parent a575969 commit 4b4a508

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

src/cluster_migrateslots.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ typedef struct slotMigrationJob {
7676
* cleanup is done. */
7777
sds description; /* Description, used for
7878
* logging. */
79+
size_t stat_cow_bytes; /* Copy on write bytes during slot migration fork. */
7980

8081
/* State needed during client establishment */
8182
connection *conn; /* Connection to slot import source node. */
@@ -1297,7 +1298,7 @@ int slotExportJobBeginSnapshotToTargetSocket(slotMigrationJob *job) {
12971298
close(server.rdb_pipe_read);
12981299

12991300
serverSetProcTitle("valkey-slot-migration-to-target");
1300-
serverSetCpuAffinity(server.slot_migration_cpulist);
1301+
serverSetCpuAffinity(server.bgsave_cpulist);
13011302

13021303
int retval = childSnapshotForSyncSlot(&aof, job);
13031304
if (retval == C_OK && rioFlush(&aof) == 0) retval = C_ERR;
@@ -1366,6 +1367,7 @@ void backgroundSlotMigrationDoneHandler(int exitcode, int bysignal) {
13661367
}
13671368
if (!bysignal && exitcode == 0) {
13681369
slotExportBeginStreaming(job);
1370+
job->stat_cow_bytes = server.stat_slot_migration_cow_bytes;
13691371
} else {
13701372
serverLog(LL_WARNING,
13711373
"Child process failed to snapshot slot migration %s",
@@ -2043,6 +2045,8 @@ void clusterCommandGetSlotMigrations(client *c) {
20432045
addReplyBulkCString(c, slotMigrationJobStateToString(job->state));
20442046
addReplyBulkCString(c, "message");
20452047
addReplyBulkCString(c, job->status_msg ? job->status_msg : "");
2048+
addReplyBulkCString(c, "last_cow_size");
2049+
addReplyLongLong(c, (long long)job->stat_cow_bytes);
20462050
}
20472051
}
20482052

src/commands/cluster-getslotmigrations.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
"pattern": "^([0-9]+-[0-9]+)( [0-9]+-[0-9]+)*$"
4141
},
4242
"node": {
43-
"type": "string"
43+
"description": "The source node name in an import job or the target node name in an export job.",
44+
"type": "string",
45+
"pattern": "^[0-9a-fA-F]{40}$"
4446
},
4547
"create_time": {
4648
"description": "Creation time, in seconds since the unix epoch.",
@@ -55,10 +57,16 @@
5557
"type": "integer"
5658
},
5759
"state": {
60+
"description": "Human readable string representing the migration job state.",
5861
"type": "string"
5962
},
6063
"message": {
64+
"description": "Human readable status message with more details.",
6165
"type": "string"
66+
},
67+
"last_cow_size": {
68+
"description": "Copy on write bytes during slot migration fork.",
69+
"type": "integer"
6270
}
6371
}
6472
}

src/config.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3252,7 +3252,6 @@ standardConfig static_configs[] = {
32523252
createStringConfig("bio-cpulist", "bio_cpulist", IMMUTABLE_CONFIG, EMPTY_STRING_IS_NULL, server.bio_cpulist, NULL, NULL, NULL),
32533253
createStringConfig("aof-rewrite-cpulist", "aof_rewrite_cpulist", IMMUTABLE_CONFIG, EMPTY_STRING_IS_NULL, server.aof_rewrite_cpulist, NULL, NULL, NULL),
32543254
createStringConfig("bgsave-cpulist", "bgsave_cpulist", IMMUTABLE_CONFIG, EMPTY_STRING_IS_NULL, server.bgsave_cpulist, NULL, NULL, NULL),
3255-
createStringConfig("slot-migration-cpulist", NULL, IMMUTABLE_CONFIG, EMPTY_STRING_IS_NULL, server.slot_migration_cpulist, NULL, NULL, NULL),
32563255
createStringConfig("ignore-warnings", NULL, MODIFIABLE_CONFIG, ALLOW_EMPTY_STRING, server.ignore_warnings, "", NULL, NULL),
32573256
createStringConfig("proc-title-template", NULL, MODIFIABLE_CONFIG, ALLOW_EMPTY_STRING, server.proc_title_template, CONFIG_DEFAULT_PROC_TITLE_TEMPLATE, isValidProcTitleTemplate, updateProcTitleTemplate),
32583257
createStringConfig("bind-source-addr", NULL, MODIFIABLE_CONFIG, EMPTY_STRING_IS_NULL, server.bind_source_addr, NULL, NULL, NULL),

src/server.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,7 @@ void checkChildrenDone(void) {
13911391
"child_type: %s, child_pid = %d",
13921392
strerror(errno), strChildType(server.child_type), (int)server.child_pid);
13931393
} else if (pid == server.child_pid) {
1394+
if (!bysignal && exitcode == 0) receiveChildInfo();
13941395
if (server.child_type == CHILD_TYPE_RDB) {
13951396
backgroundSaveDoneHandler(exitcode, bysignal);
13961397
} else if (server.child_type == CHILD_TYPE_AOF) {
@@ -1403,7 +1404,6 @@ void checkChildrenDone(void) {
14031404
serverPanic("Unknown child type %d for child pid %d", server.child_type, server.child_pid);
14041405
exit(1);
14051406
}
1406-
if (!bysignal && exitcode == 0) receiveChildInfo();
14071407
resetChildState();
14081408
} else {
14091409
if (!ldbRemoveChild(pid)) {
@@ -6041,8 +6041,7 @@ sds genValkeyInfoString(dict *section_dict, int all_sections, int everything) {
60416041
"aof_last_cow_size:%zu\r\n", server.stat_aof_cow_bytes,
60426042
"module_fork_in_progress:%d\r\n", server.child_type == CHILD_TYPE_MODULE,
60436043
"module_fork_last_cow_size:%zu\r\n", server.stat_module_cow_bytes,
6044-
"slot_migration_fork_in_progress:%d\r\n", server.child_type == CHILD_TYPE_SLOT_MIGRATION,
6045-
"slot_migration_fork_last_cow_size:%zu\r\n", server.stat_slot_migration_cow_bytes));
6044+
"slot_migration_fork_in_progress:%d\r\n", server.child_type == CHILD_TYPE_SLOT_MIGRATION));
60466045

60476046
if (server.aof_enabled) {
60486047
info = sdscatprintf(

tests/unit/introspection.tcl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,6 @@ start_server {tags {"introspection"}} {
12091209
bio-cpulist
12101210
aof-rewrite-cpulist
12111211
bgsave-cpulist
1212-
slot-migration-cpulist
12131212
server_cpulist
12141213
bio_cpulist
12151214
aof_rewrite_cpulist

valkey.conf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,11 +2602,8 @@ jemalloc-bg-thread yes
26022602
# Set aof rewrite child process to cpu affinity 8,9,10,11:
26032603
# aof-rewrite-cpulist 8-11
26042604
#
2605-
# Set bgsave child process to cpu affinity 1,10,11:
2605+
# Set bgsave (or slot migration) child process to cpu affinity 1,10,11:
26062606
# bgsave-cpulist 1,10-11
2607-
#
2608-
# Set slot migration child process to cpu affinity 1,8,9,10:
2609-
# slot-migration-cpulist 1,8-10
26102607

26112608
# In some cases the server will emit warnings and even refuse to start if it detects
26122609
# that the system is in bad state, it is possible to suppress these warnings

0 commit comments

Comments
 (0)