gavinchou commented on code in PR #66364:
URL: https://github.com/apache/doris/pull/66364#discussion_r3765610702


##########
cloud/src/meta-service/meta_service_helper.h:
##########
@@ -42,22 +43,30 @@
 #include "resource-manager/resource_manager.h"
 
 namespace doris::cloud {
-inline MetaServiceCode get_legacy_code(MetaServiceCode code) {
+// Converts a response code and message to values that older clients can read.
+// set_response_code() stores the original code in actual_code
+// Call this function only from set_response_code() or from unit tests; do not 
call it from other production code.
+// When adding an error code that may be returned to clients, must add its 
conversion here.
+inline std::pair<MetaServiceCode, std::string> 
resolve_response_code_and_msg(MetaServiceCode code,
+                                                                             
std::string msg) {
     switch (code) {
-    // MS_TOO_BUSY is a overload signal. Map it to KV_TXN_CONFLICT so the BE's 
existing
+    // MS_TOO_BUSY is an overload signal. Map it to KV_TXN_CONFLICT so the 
BE's existing
     // conflict-retry path can retry the request.
     case MetaServiceCode::MS_TOO_BUSY:
-        return MetaServiceCode::KV_TXN_CONFLICT;
+        msg += std::string((msg.empty() ? "" : ", ")) +
+               "[MS_TOO_BUSY will be converted to code=KV_TXN_CONFLICT for old 
version clients]";
+        return {MetaServiceCode::KV_TXN_CONFLICT, std::move(msg)};
     default:
-        return code;
+        return {code, std::move(msg)};

Review Comment:
   this code should be undefined_error?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to