Skip to content

Commit

Permalink
Make replica CLUSTER RESET flush async based on lazyfree-lazy-user-fl…
Browse files Browse the repository at this point in the history
…ush (valkey-io#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 <[email protected]>
Co-authored-by: Ping Xie <[email protected]>
  • Loading branch information
enjoy-binbin and PingXie authored Oct 23, 2024
1 parent 285064b commit 5d70ccd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ void clusterReset(int hard) {
if (nodeIsReplica(myself)) {
clusterSetNodeAsPrimary(myself);
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. */
Expand Down
6 changes: 5 additions & 1 deletion valkey.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,11 @@ lazyfree-lazy-user-del yes
# 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
# 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
# environments, the thread managers should balance between the freeing and
# serving incoming requests. The default value is yes.
Expand Down

0 comments on commit 5d70ccd

Please sign in to comment.