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


##########
src/config/config.cc:
##########
@@ -885,11 +885,20 @@ Status Config::Set(Server *srv, std::string key, const 
std::string &value) {
     if (!s.IsOK()) return s.Prefixed("invalid value");
   }
 
+  auto origin_value = field->ToString();
   auto s = field->Set(value);
   if (!s.IsOK()) return s.Prefixed("failed to set new value");
 
   if (field->callback) {
-    return field->callback(srv, key, value);
+    s = field->callback(srv, key, value);
+    if (!s.IsOK()) {
+      // rollback the value if the callback failed
+      auto setStatus = field->Set(origin_value);

Review Comment:
   This place is a bug fix, we should rollback the configuration value if it's 
failed in the callback function.



-- 
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