-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement: CLUSTER REPLICATE NO ONE #1674
base: unstable
Are you sure you want to change the base?
Implement: CLUSTER REPLICATE NO ONE #1674
Conversation
91589d1
to
ff96c0f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1674 +/- ##
============================================
+ Coverage 71.04% 71.08% +0.04%
============================================
Files 121 123 +2
Lines 65254 65548 +294
============================================
+ Hits 46357 46596 +239
- Misses 18897 18952 +55
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cluster-replicate.json
file should be updated and as part of the build commands.def
will get updated. or if it was accidentally not staged, please add that.
Also, could you run the clang-format on your end to fix some of the formatting issue.
src/cluster_legacy.c
Outdated
if (server.primary != NULL) { | ||
replicationUnsetPrimary(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other invocation of replicationUnsetPrimary()
don't have this wrapped under the condition. Is it unnecessary to invoke it if server.primary is NULL ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also unsure why clusterPromoteSelfToPrimary
was introduced, seems like it's the same behavior at this point but good to call this abstraction if there will be additional steps introduced in the future for cluster mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also unsure why clusterPromoteSelfToPrimary was introduced, seems like it's the same behavior at this point but good to call this abstraction if there will be additional steps introduced in the future for cluster mode.
Ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other invocation of replicationUnsetPrimary() don't have this wrapped under the condition. Is it unnecessary to invoke it if server.primary is NULL ?
Probably not needed. It looks like left over from KeyDB's implementation where primary needed to be passed to replicationUnsetMaster
fde1ab6
to
4abbae8
Compare
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature makes sense to me.
@valkey-io/core-team New arguments = major decision. Please approve or vote if you agree.
4abbae8
to
85238e6
Compare
The CI job "DCO" is failing. You need to use Why we need it? See here: https://github.com/valkey-io/valkey/blob/unstable/CONTRIBUTING.md#developer-certificate-of-origin thanks! |
85238e6
to
3789227
Compare
Signed-off-by: Sergey Kolosov <[email protected]>
3789227
to
e4e8b24
Compare
Done |
/* Lookup the specified node in our table. */ | ||
if (c->argc == 4) { | ||
if (0 != strcasecmp(c->argv[2]->ptr, "NO") || 0 != strcasecmp(c->argv[3]->ptr, "ONE")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't do this 0 != xxx trick, let's keep the same style for the code
/* Reset manual failover state. */ | ||
resetManualFailover(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it become a primary, do we need this reset? it has no way to enter the failover check logic. or at least we remove the comment since this line is super easy.
/* Reset manual failover state. */ | |
resetManualFailover(); | |
resetManualFailover(); |
int empty_db_flags = server.repl_replica_lazy_flush ? EMPTYDB_ASYNC : EMPTYDB_NO_FLAGS; | ||
emptyData(-1, empty_db_flags, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int empty_db_flags = server.repl_replica_lazy_flush ? EMPTYDB_ASYNC : EMPTYDB_NO_FLAGS; | |
emptyData(-1, empty_db_flags, NULL); | |
emptyData(-1, server.repl_replica_lazy_flush ? EMPTYDB_ASYNC : EMPTYDB_NO_FLAGS, NULL); |
addReply(c, shared.ok); | ||
return 1; | ||
} | ||
serverLog(LL_NOTICE, "Stop replication and turning myself into empty primary."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also use catClientInfoShortString
to get the client info for a better audit.
Currently, ValKey doesn't allow to detach replica attached to primary node. So, if you want to change cluster topology the only way to do it is to reset (
CLUSTER RESET
command) the node. However, this results into removing node from the cluster what affects clients. All clients will keep sending traffic to this node (with getting inaccurate responses) until they refresh their topology.In this change we implement supporting of new argument for CLUSTER REPLICATE command:
CLUSTER REPLICATE NO ONE
. When calling this command the node will be converted from replica to empty primary node but still staying in the cluster. Thus, all traffic coming from the clients to this node can be redirected to correct node.