Make replica CLUSTER RESET flush async based on lazyfree-lazy-user-flush (#1190)

Currently, if the replica has a lot of data, CLUSTER RESET
will block for a while and report the slowlog, and it seems
that there is no harm in making it async so external components
can be easier when monitoring it.

Signed-off-by: Binbin <binloveplay1314@qq.com>
Co-authored-by: Ping Xie <pingxie@outlook.com>
This commit is contained in:
Binbin 2024-10-23 10:22:25 +08:00 committed by GitHub
parent 285064b114
commit 5d70ccd70e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -1230,7 +1230,7 @@ void clusterReset(int hard) {
if (nodeIsReplica(myself)) { if (nodeIsReplica(myself)) {
clusterSetNodeAsPrimary(myself); clusterSetNodeAsPrimary(myself);
replicationUnsetPrimary(); replicationUnsetPrimary();
emptyData(-1, EMPTYDB_NO_FLAGS, NULL); emptyData(-1, server.lazyfree_lazy_user_flush ? EMPTYDB_ASYNC : EMPTYDB_NO_FLAGS, NULL);
} }
/* Close slots, reset manual failover state. */ /* Close slots, reset manual failover state. */

View File

@ -1308,7 +1308,11 @@ lazyfree-lazy-user-del yes
# deletion, which can be controlled by passing the [SYNC|ASYNC] flags into the # deletion, which can be controlled by passing the [SYNC|ASYNC] flags into the
# commands. When neither flag is passed, this directive will be used to determine # commands. When neither flag is passed, this directive will be used to determine
# if the data should be deleted asynchronously. # if the data should be deleted asynchronously.
#
# When a replica performs a node reset via CLUSTER RESET, the entire
# database content is removed to allow the node to become an empty primary.
# This directive also determines whether the data should be deleted asynchronously.
#
# There are many problems with running flush synchronously. Even in single CPU # There are many problems with running flush synchronously. Even in single CPU
# environments, the thread managers should balance between the freeing and # environments, the thread managers should balance between the freeing and
# serving incoming requests. The default value is yes. # serving incoming requests. The default value is yes.