Skip to content

Commit 0cddd6b

Browse files
akichidismwtian
authored andcommitted
[MFP] enhance metrics with additional labels. Refactor tx retry back off (#23725)
## Description This PR: * Enhances some metrics with additional labels * Refactors the back off strategy when retrying the tx submission Running for `10` times the back off with the current settings yields results like: ``` 58.618524ms 1.717898302s 626.285083ms 8.890868961s 6.853596566s 1.27459605s 8.60306108s 2.898520074s 1.538756239s 2.389480396s ``` Although we are using an exponential back off, the current setup and jitter seems to mess up a bit the back off latency to be used. It's not very scalar in the sense that we should expect using a bigger and bigger step every time. With the proposed changes we'll have something like: ``` 136.153155ms 172.376361ms 315.614501ms 460.543044ms 866.642052ms 1.196423s 1.584154394s 3.647710108s 4.406361196s 8.318059196s ``` ## Test plan How did you test the new or updated feature? --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK:
1 parent 07009cc commit 0cddd6b

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

crates/sui-core/src/transaction_driver/metrics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ impl TransactionDriverMetrics {
7272
validator_submit_transaction_errors: register_int_counter_vec_with_registry!(
7373
"transaction_driver_validator_submit_transaction_errors",
7474
"Number of submit transaction errors by validator",
75-
&["validator", "error_type"],
75+
&["validator", "error_type", "tx_type", "ping"],
7676
registry,
7777
)
7878
.unwrap(),
7979
validator_submit_transaction_successes: register_int_counter_vec_with_registry!(
8080
"transaction_driver_validator_submit_transaction_successes",
8181
"Number of successful submit transactions by validator",
82-
&["validator"],
82+
&["validator", "tx_type", "ping"],
8383
registry,
8484
)
8585
.unwrap(),
@@ -149,7 +149,7 @@ impl TransactionDriverMetrics {
149149
validator_selections: register_int_counter_vec_with_registry!(
150150
"transaction_driver_validator_selections",
151151
"Number of times each validator was selected for transaction submission",
152-
&["validator"],
152+
&["validator", "tx_type", "ping"],
153153
registry,
154154
)
155155
.unwrap(),

crates/sui-core/src/transaction_driver/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod transaction_submitter;
1010
/// Exports
1111
pub use error::TransactionDriverError;
1212
pub use metrics::*;
13-
use tokio_retry::strategy::{jitter, ExponentialBackoff};
13+
use tokio_retry::strategy::ExponentialBackoff;
1414

1515
use std::{
1616
net::SocketAddr,
@@ -263,7 +263,7 @@ where
263263
// Exponential backoff with jitter to prevent thundering herd on retries
264264
let mut backoff = ExponentialBackoff::from_millis(100)
265265
.max_delay(MAX_RETRY_DELAY)
266-
.map(jitter);
266+
.map(|duration| duration.mul_f64(rand::thread_rng().gen_range(0.5..1.0)));
267267
let mut attempts = 0;
268268
let mut latest_retriable_error = None;
269269

crates/sui-core/src/transaction_driver/transaction_submitter.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ impl TransactionSubmitter {
7272
tx_type,
7373
options.allowed_validators.clone(),
7474
);
75+
76+
let ping_label = if request.ping.is_some() {
77+
"true"
78+
} else {
79+
"false"
80+
};
7581
let mut retries = 0;
7682
let mut request_rpcs = FuturesUnordered::new();
7783

@@ -85,7 +91,7 @@ impl TransactionSubmitter {
8591
let display_name = authority_aggregator.get_display_name(&name);
8692
self.metrics
8793
.validator_selections
88-
.with_label_values(&[&display_name])
94+
.with_label_values(&[&display_name, tx_type.as_str(), ping_label])
8995
.inc();
9096

9197
// Create a future that returns the name and display_name along with the result
@@ -132,7 +138,7 @@ impl TransactionSubmitter {
132138
Some((name, display_name, Ok(result))) => {
133139
self.metrics
134140
.validator_submit_transaction_successes
135-
.with_label_values(&[&display_name])
141+
.with_label_values(&[&display_name, tx_type.as_str(), ping_label])
136142
.inc();
137143
self.metrics
138144
.submit_transaction_retries
@@ -150,7 +156,12 @@ impl TransactionSubmitter {
150156
};
151157
self.metrics
152158
.validator_submit_transaction_errors
153-
.with_label_values(&[&display_name, error_type])
159+
.with_label_values(&[
160+
&display_name,
161+
error_type,
162+
tx_type.as_str(),
163+
ping_label,
164+
])
154165
.inc();
155166

156167
retries += 1;

0 commit comments

Comments
 (0)