You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "LiuYuHui (via GitHub)" <gi...@apache.org> on 2024/03/15 14:58:55 UTC

[PR] Feat: add support of READONLY and READWRITE [kvrocks]

LiuYuHui opened a new pull request, #2173:
URL: https://github.com/apache/kvrocks/pull/2173

   closes #2166 
   local test pass
   ![image](https://github.com/apache/kvrocks/assets/13926137/4f337e8a-f07a-4d08-9ed0-0cb0d30be977)
   ![image](https://github.com/apache/kvrocks/assets/13926137/79ac87e8-6a3e-42df-9b64-6841f8d5b15c)
   TODO: add go test.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#issuecomment-2002421620

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2173) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_kvrocks&pullRequest=2173&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2173&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_kvrocks&pullRequest=2173&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [79.4% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2173&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2173&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2173)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#issuecomment-2002454610

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2173) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_kvrocks&pullRequest=2173&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2173&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_kvrocks&pullRequest=2173&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [79.4% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2173&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2173&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2173)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "LiuYuHui (via GitHub)" <gi...@apache.org>.
LiuYuHui commented on code in PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#discussion_r1527464814


##########
src/cluster/cluster.h:
##########
@@ -111,4 +118,6 @@ class Cluster {
 
   std::map<int, std::string> migrated_slots_;
   std::set<int> imported_slots_;
+
+  ClusterMode cluster_mode_{ClusterMode::READONLY};

Review Comment:
   thanks, fixed it.



##########
src/commands/cmd_cluster.cc:
##########
@@ -292,8 +292,25 @@ static uint64_t GenerateClusterFlag(const std::vector<std::string> &args) {
   return 0;
 }
 
+class CommandReadOnly : public Commander {
+ public:
+  Status Execute(Server *srv, Connection *conn, std::string *output) override {
+    *output = redis::SimpleString("READONLY");

Review Comment:
   thanks, fixed it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "caipengbo (via GitHub)" <gi...@apache.org>.
caipengbo commented on code in PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#discussion_r1527438876


##########
src/cluster/cluster.h:
##########
@@ -111,4 +118,6 @@ class Cluster {
 
   std::map<int, std::string> migrated_slots_;
   std::set<int> imported_slots_;
+
+  ClusterMode cluster_mode_{ClusterMode::READONLY};

Review Comment:
   These two commands should be in the **connection** dimension.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "jihuayu (via GitHub)" <gi...@apache.org>.
jihuayu commented on code in PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#discussion_r1527478982


##########
src/server/redis_connection.h:
##########
@@ -45,6 +45,7 @@ class Connection : public EvbufCallbackBase<Connection> {
     kCloseAfterReply = 1 << 6,
     kCloseAsync = 1 << 7,
     kMultiExec = 1 << 8,
+    KReadWrite = 1 << 9,

Review Comment:
   What is the logic for Redis? The original logic may be wrong.
   We need to align with Redis, not with the original.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "caipengbo (via GitHub)" <gi...@apache.org>.
caipengbo commented on code in PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#discussion_r1527440599


##########
src/commands/cmd_cluster.cc:
##########
@@ -292,8 +292,25 @@ static uint64_t GenerateClusterFlag(const std::vector<std::string> &args) {
   return 0;
 }
 
+class CommandReadOnly : public Commander {
+ public:
+  Status Execute(Server *srv, Connection *conn, std::string *output) override {
+    *output = redis::SimpleString("READONLY");

Review Comment:
   The reply should be `OK`.



##########
src/commands/cmd_cluster.cc:
##########
@@ -292,8 +292,25 @@ static uint64_t GenerateClusterFlag(const std::vector<std::string> &args) {
   return 0;
 }
 
+class CommandReadOnly : public Commander {
+ public:
+  Status Execute(Server *srv, Connection *conn, std::string *output) override {
+    *output = redis::SimpleString("READONLY");
+    return srv->cluster->SetClusterMode(Cluster::ClusterMode::READONLY);
+  }
+};
+
+class CommandReadWrite : public Commander {
+ public:
+  Status Execute(Server *srv, Connection *conn, std::string *output) override {
+    *output = redis::SimpleString("READWRITE");

Review Comment:
   The reply should be `OK`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "LiuYuHui (via GitHub)" <gi...@apache.org>.
LiuYuHui commented on code in PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#discussion_r1527477687


##########
src/server/redis_connection.h:
##########
@@ -45,6 +45,7 @@ class Connection : public EvbufCallbackBase<Connection> {
     kCloseAfterReply = 1 << 6,
     kCloseAsync = 1 << 7,
     kMultiExec = 1 << 8,
+    KReadWrite = 1 << 9,

Review Comment:
   It seems that the original logic is `KReadOnly` ==1, and the default flag is 0, so I choose `KReadWrite` here, which means the default option is `KReadWrite` ==0 (`KReadOnly` ==1).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#issuecomment-2002346747

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2173) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [39.4% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2173&metric=new_coverage&view=list) (required ≥ 50%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2173)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk merged PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "jihuayu (via GitHub)" <gi...@apache.org>.
jihuayu commented on code in PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#discussion_r1527475306


##########
src/server/redis_connection.h:
##########
@@ -45,6 +45,7 @@ class Connection : public EvbufCallbackBase<Connection> {
     kCloseAfterReply = 1 << 6,
     kCloseAsync = 1 << 7,
     kMultiExec = 1 << 8,
+    KReadWrite = 1 << 9,

Review Comment:
   The default state of the flag be disabled? Should it be `KReadOnly` here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#issuecomment-2002480478

   @LiuYuHui Thanks for your contribution.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#issuecomment-2002204270

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2173) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [33.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2173&metric=new_coverage&view=list) (required ≥ 50%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2173)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: add support of READONLY and READWRITE [kvrocks]

Posted by "LiuYuHui (via GitHub)" <gi...@apache.org>.
LiuYuHui commented on code in PR #2173:
URL: https://github.com/apache/kvrocks/pull/2173#discussion_r1527482135


##########
src/server/redis_connection.h:
##########
@@ -45,6 +45,7 @@ class Connection : public EvbufCallbackBase<Connection> {
     kCloseAfterReply = 1 << 6,
     kCloseAsync = 1 << 7,
     kMultiExec = 1 << 8,
+    KReadWrite = 1 << 9,

Review Comment:
   https://redis.io/commands/readonly/
   > Normally replica nodes will redirect clients to the authoritative master for the hash slot involved in a given command, however clients can use replicas in order to scale reads using the READONLY command.
   
   I see, Redis default option is `READWRTIE`, will change it .
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org