git-hulk commented on code in PR #2495:
URL: https://github.com/apache/kvrocks/pull/2495#discussion_r1720987911


##########
src/commands/cmd_server.cc:
##########
@@ -477,7 +477,53 @@ class CommandClient : public Commander {
       }
       return Status::OK();
     }
-    return {Status::RedisInvalidCmd, "Syntax error, try CLIENT LIST|INFO|KILL 
ip:port|GETNAME|SETNAME"};
+
+    if ((subcommand_ == "pause")) {
+      if (args.size() != 3 && args.size() != 4) {
+        return {Status::RedisParseErr, errInvalidSyntax};
+      }
+
+      pause_timeout_ms_ = atoi(args[2].c_str());
+
+      if (args.size() == 3) {
+        pause_type_ = kPauseAll;
+      } else {
+        if (!strcasecmp(args[3].c_str(), "all")) {

Review Comment:
   Can use the CommandParser to parse command arguments.



##########
src/server/redis_connection.cc:
##########
@@ -396,6 +413,13 @@ void Connection::ExecuteCommands(std::deque<CommandTokens> 
*to_process_cmds) {
     auto cmd_name = attributes->name;
     auto cmd_flags = attributes->GenerateFlags(cmd_tokens);
 
+    // Pause the processing of only the write commands, and push them back
+    // to a list that adds them back to the queue to process them when we 
unpause
+    if (srv_->GetCommandPauseType() == kPauseWrite && (cmd_flags & kCmdWrite)) 
{

Review Comment:
   I didn't check the Redis codebase, but it looks like the entire connection 
will be suspended like `PAUSE ALL` once found the write command from the 
documentation: https://redis.io/docs/latest/commands/client-pause/
   
   > WRITE: Clients are only blocked if they attempt to execute a write command.
   
   And from the current implementation, it will let read commands go through 
and it might cause unmatched responses in client side. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to