Skip to content

Commit

Permalink
fix server: fix stats of pipeline squashed commands (#4132)
Browse files Browse the repository at this point in the history
Signed-off-by: adi_holden <[email protected]>
  • Loading branch information
adiholden authored Nov 14, 2024
1 parent a887d82 commit db67b35
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/server/main_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1407,13 +1407,13 @@ size_t Service::DispatchManyCommands(absl::Span<CmdArgList> args_list, SinkReply
}

dfly_cntx->transaction = dist_trans.get();
MultiCommandSquasher::Execute(absl::MakeSpan(stored_cmds),
static_cast<RedisReplyBuilder*>(builder), dfly_cntx, this, true,
false);
size_t squashed_num = MultiCommandSquasher::Execute(absl::MakeSpan(stored_cmds),
static_cast<RedisReplyBuilder*>(builder),
dfly_cntx, this, true, false);
dfly_cntx->transaction = nullptr;

dispatched += stored_cmds.size();
ss->stats.squashed_commands += stored_cmds.size();
ss->stats.squashed_commands += squashed_num;
stored_cmds.clear();
};

Expand Down
3 changes: 2 additions & 1 deletion src/server/multi_command_squasher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ bool MultiCommandSquasher::ExecuteSquashed(facade::RedisReplyBuilder* rb) {
return !aborted;
}

void MultiCommandSquasher::Run(RedisReplyBuilder* rb) {
size_t MultiCommandSquasher::Run(RedisReplyBuilder* rb) {
DVLOG(1) << "Trying to squash " << cmds_.size() << " commands for transaction "
<< cntx_->transaction->DebugId();

Expand Down Expand Up @@ -291,6 +291,7 @@ void MultiCommandSquasher::Run(RedisReplyBuilder* rb) {

VLOG(1) << "Squashed " << num_squashed_ << " of " << cmds_.size()
<< " commands, max fanout: " << num_shards_ << ", atomic: " << atomic_;
return num_squashed_;
}

bool MultiCommandSquasher::IsAtomic() const {
Expand Down
12 changes: 6 additions & 6 deletions src/server/multi_command_squasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ namespace dfly {
// contains a non-atomic multi transaction to execute squashed commands.
class MultiCommandSquasher {
public:
static void Execute(absl::Span<StoredCmd> cmds, facade::RedisReplyBuilder* rb,
ConnectionContext* cntx, Service* service, bool verify_commands = false,
bool error_abort = false) {
MultiCommandSquasher{cmds, cntx, service, verify_commands, error_abort}.Run(rb);
static size_t Execute(absl::Span<StoredCmd> cmds, facade::RedisReplyBuilder* rb,
ConnectionContext* cntx, Service* service, bool verify_commands = false,
bool error_abort = false) {
return MultiCommandSquasher{cmds, cntx, service, verify_commands, error_abort}.Run(rb);
}

private:
Expand Down Expand Up @@ -62,8 +62,8 @@ class MultiCommandSquasher {
// Execute all currently squashed commands. Return false if aborting on error.
bool ExecuteSquashed(facade::RedisReplyBuilder* rb);

// Run all commands until completion.
void Run(facade::RedisReplyBuilder* rb);
// Run all commands until completion. Returns number of squashed commands.
size_t Run(facade::RedisReplyBuilder* rb);

bool IsAtomic() const;

Expand Down

0 comments on commit db67b35

Please sign in to comment.