Skip to content

Commit

Permalink
fix: UB during cmd squashing reply size calculation (#4149)
Browse files Browse the repository at this point in the history
* fix: UB during cmd squashing reply size calculation

* feat: add promtheus metric commands_squashing_replies_bytes
  • Loading branch information
BorysTheDev authored Nov 19, 2024
1 parent 794bd1c commit 4e7800f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/server/multi_command_squasher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ bool MultiCommandSquasher::ExecuteSquashed(facade::RedisReplyBuilder* rb) {

aborted |= error_abort_ && CapturingReplyBuilder::TryExtractError(replies.back());

CapturingReplyBuilder::Apply(std::move(replies.back()), rb);
current_reply_size_.fetch_sub(Size(replies.back()), std::memory_order_relaxed);
CapturingReplyBuilder::Apply(std::move(replies.back()), rb);
replies.pop_back();

if (aborted)
Expand Down
5 changes: 3 additions & 2 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,6 @@ void PrintPrometheusMetrics(uint64_t uptime, const Metrics& m, DflyCmd* dfly_cmd
MetricType::GAUGE, &resp->body());
AppendMetricWithoutLabels("dispatch_queue_bytes", "", conn_stats.dispatch_queue_bytes,
MetricType::GAUGE, &resp->body());
AppendMetricWithoutLabels("pipeline_cache_bytes", "", conn_stats.pipeline_cmd_cache_bytes,
MetricType::GAUGE, &resp->body());
AppendMetricWithoutLabels("pipeline_queue_length", "", conn_stats.dispatch_queue_entries,
MetricType::GAUGE, &resp->body());
AppendMetricWithoutLabels("pipeline_throttle_total", "", conn_stats.pipeline_throttle_count,
Expand All @@ -1313,6 +1311,9 @@ void PrintPrometheusMetrics(uint64_t uptime, const Metrics& m, DflyCmd* dfly_cmd
AppendMetricWithoutLabels("pipeline_commands_duration_seconds", "",
conn_stats.pipelined_cmd_latency * 1e-6, MetricType::COUNTER,
&resp->body());
AppendMetricWithoutLabels("commands_squashing_replies_bytes", "",
MultiCommandSquasher::GetRepliesMemSize(), MetricType::GAUGE,
&resp->body());
string connections_libs;
AppendMetricHeader("connections_libs", "Total number of connections by libname:ver",
MetricType::GAUGE, &connections_libs);
Expand Down

0 comments on commit 4e7800f

Please sign in to comment.