@@ -1146,9 +1146,10 @@ void Service::DispatchCommand(ArgSlice args, SinkReplyBuilder* builder,
11461146 DCHECK (!args.empty ());
11471147 DCHECK_NE (0u , shard_set->size ()) << " Init was not called" ;
11481148
1149- absl::Cleanup clear_last_error ([builder]() { builder->ConsumeLastError (); });
11501149 ServerState& etl = *ServerState::tlocal ();
11511150
1151+ builder->ResetLastError ();
1152+
11521153 string cmd = absl::AsciiStrToUpper (args[0 ]);
11531154 const auto [cid, args_no_cmd] = registry_.FindExtended (cmd, args.subspan (1 ));
11541155
@@ -1312,6 +1313,9 @@ bool Service::InvokeCmd(const CommandId* cid, CmdArgList tail_args,
13121313 DCHECK (builder);
13131314 DCHECK (cntx);
13141315
1316+ // Reset
1317+ builder->ResetLastError ();
1318+
13151319 if (auto err = VerifyCommandExecution (cid, cntx, tail_args); err) {
13161320 // We need to skip this because ACK's should not be replied to
13171321 // Bonus points because this allows to continue replication with ACL users who got
@@ -1320,7 +1324,6 @@ bool Service::InvokeCmd(const CommandId* cid, CmdArgList tail_args,
13201324 return true ;
13211325 }
13221326 builder->SendError (std::move (*err));
1323- builder->ConsumeLastError ();
13241327 return true ; // return false only for internal error aborts
13251328 }
13261329
@@ -1354,16 +1357,15 @@ bool Service::InvokeCmd(const CommandId* cid, CmdArgList tail_args,
13541357 ReplyGuard reply_guard (cid->name (), builder, cntx);
13551358#endif
13561359 uint64_t invoke_time_usec = 0 ;
1357- auto last_error = builder->ConsumeLastError ();
1358- DCHECK (last_error.empty ());
13591360 try {
13601361 invoke_time_usec = cid->Invoke (tail_args, cmd_cntx);
13611362 } catch (std::exception& e) {
13621363 LOG (ERROR) << " Internal error, system probably unstable " << e.what ();
13631364 return false ;
13641365 }
13651366
1366- if (std::string reason = builder->ConsumeLastError (); !reason.empty ()) {
1367+ if (builder->GetLastErrorStatus () != facade::OpStatus::OK) {
1368+ std::string_view reason = builder->GetLastError ();
13671369 VLOG (2 ) << FailedCommandToString (cid->name (), tail_args, reason);
13681370 LOG_EVERY_T (WARNING, 1 ) << FailedCommandToString (cid->name (), tail_args, reason);
13691371 }
0 commit comments