@@ -151,8 +151,7 @@ bool MultiCommandSquasher::ExecuteStandalone(facade::RedisReplyBuilder* rb, Stor
151
151
}
152
152
153
153
auto * tx = cntx_->transaction ;
154
- tx->MultiSwitchCmd (cmd->Cid ());
155
- cntx_->cid = cmd->Cid ();
154
+ cntx_->SwitchTxCmd (cmd->Cid ());
156
155
157
156
if (cmd->Cid ()->IsTransactional ())
158
157
tx->InitByArgs (cntx_->ns , cntx_->conn_state .db_index , args);
@@ -189,8 +188,7 @@ OpStatus MultiCommandSquasher::SquashedHopCb(EngineShard* es, RespVersion resp_v
189
188
}
190
189
}
191
190
192
- local_tx->MultiSwitchCmd (cmd->Cid ());
193
- local_cntx.cid = cmd->Cid ();
191
+ local_cntx.SwitchTxCmd (cmd->Cid ());
194
192
crb.SetReplyMode (cmd->ReplyMode ());
195
193
196
194
local_tx->InitByArgs (cntx_->ns , local_cntx.conn_state .db_index , args);
@@ -205,7 +203,6 @@ OpStatus MultiCommandSquasher::SquashedHopCb(EngineShard* es, RespVersion resp_v
205
203
CheckConnStateClean (local_state);
206
204
}
207
205
208
- reverse (sinfo.replies .begin (), sinfo.replies .end ());
209
206
return OpStatus::OK;
210
207
}
211
208
@@ -255,24 +252,27 @@ bool MultiCommandSquasher::ExecuteSquashed(facade::RedisReplyBuilder* rb) {
255
252
bool aborted = false ;
256
253
257
254
for (auto idx : order_) {
258
- auto & replies = sharded_[idx].replies ;
259
- CHECK (!replies.empty ());
255
+ auto & sinfo = sharded_[idx];
256
+ auto & replies = sinfo.replies ;
257
+ DCHECK_LT (sinfo.reply_id , replies.size ());
260
258
261
- aborted |= opts_.error_abort && CapturingReplyBuilder::TryExtractError (replies.back ());
262
-
263
- current_reply_size_.fetch_sub (Size (replies.back ()), std::memory_order_relaxed);
264
- CapturingReplyBuilder::Apply (std::move (replies.back ()), rb);
265
- replies.pop_back ();
259
+ auto & reply = replies[sinfo.reply_id ++];
260
+ aborted |= opts_.error_abort && CapturingReplyBuilder::TryExtractError (reply);
266
261
262
+ current_reply_size_.fetch_sub (Size (reply), std::memory_order_relaxed);
263
+ CapturingReplyBuilder::Apply (std::move (reply), rb);
267
264
if (aborted)
268
265
break ;
269
266
}
270
267
uint64_t after_reply = proactor->GetMonotonicTimeNs ();
271
268
ServerState::SafeTLocal ()->stats .multi_squash_exec_hop_usec += (after_hop - start) / 1000 ;
272
269
ServerState::SafeTLocal ()->stats .multi_squash_exec_reply_usec += (after_reply - after_hop) / 1000 ;
273
270
274
- for (auto & sinfo : sharded_)
271
+ for (auto & sinfo : sharded_) {
275
272
sinfo.cmds .clear ();
273
+ sinfo.replies .clear ();
274
+ sinfo.reply_id = 0 ;
275
+ }
276
276
277
277
order_.clear ();
278
278
return !aborted;
0 commit comments