Skip to content

Commit

Permalink
retry_policy: replace query mentions with request
Browse files Browse the repository at this point in the history
  • Loading branch information
muzarski committed Dec 23, 2024
1 parent e4a4c77 commit cc87b86
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 82 deletions.
76 changes: 38 additions & 38 deletions scylla/src/transport/downgrading_consistency_retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ impl Default for DowngradingConsistencyRetrySession {
}

impl RetrySession for DowngradingConsistencyRetrySession {
fn decide_should_retry(&mut self, query_info: RequestInfo) -> RetryDecision {
let cl = match query_info.consistency {
fn decide_should_retry(&mut self, request_info: RequestInfo) -> RetryDecision {
let cl = match request_info.consistency {
Consistency::Serial | Consistency::LocalSerial => {
return match query_info.error {
return match request_info.error {
UserRequestError::DbError(DbError::Unavailable { .. }, _) => {
// JAVA-764: if the requested consistency level is serial, it means that the operation failed at
// the paxos phase of a LWT.
Expand Down Expand Up @@ -87,14 +87,14 @@ impl RetrySession for DowngradingConsistencyRetrySession {
decision
}

match query_info.error {
match request_info.error {
// Basic errors - there are some problems on this node
// Retry on a different one if possible
UserRequestError::BrokenConnectionError(_)
| UserRequestError::DbError(DbError::Overloaded, _)
| UserRequestError::DbError(DbError::ServerError, _)
| UserRequestError::DbError(DbError::TruncateError, _) => {
if query_info.is_idempotent {
if request_info.is_idempotent {
RetryDecision::RetryNextNode(None)
} else {
RetryDecision::DontRetry
Expand Down Expand Up @@ -141,7 +141,7 @@ impl RetrySession for DowngradingConsistencyRetrySession {
},
_,
) => {
if self.was_retry || !query_info.is_idempotent {
if self.was_retry || !request_info.is_idempotent {
RetryDecision::DontRetry
} else {
self.was_retry = true;
Expand All @@ -161,7 +161,7 @@ impl RetrySession for DowngradingConsistencyRetrySession {
}
}
}
// The node is still bootstrapping it can't execute the query, we should try another one
// The node is still bootstrapping it can't execute the request, we should try another one
UserRequestError::DbError(DbError::IsBootstrapping, _) => {
RetryDecision::RetryNextNode(None)
}
Expand Down Expand Up @@ -199,7 +199,7 @@ mod tests {
Consistency::Two,
];

fn make_query_info_with_cl(
fn make_request_info_with_cl(
error: &UserRequestError,
is_idempotent: bool,
cl: Consistency,
Expand All @@ -218,13 +218,13 @@ mod tests {
) {
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(&error, false, cl)),
policy.decide_should_retry(make_request_info_with_cl(&error, false, cl)),
RetryDecision::DontRetry
);

let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(&error, true, cl)),
policy.decide_should_retry(make_request_info_with_cl(&error, true, cl)),
RetryDecision::DontRetry
);
}
Expand Down Expand Up @@ -306,13 +306,13 @@ mod tests {
) {
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(&error, false, cl)),
policy.decide_should_retry(make_request_info_with_cl(&error, false, cl)),
RetryDecision::DontRetry
);

let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(&error, true, cl)),
policy.decide_should_retry(make_request_info_with_cl(&error, true, cl)),
RetryDecision::RetryNextNode(None)
);
}
Expand Down Expand Up @@ -360,13 +360,13 @@ mod tests {
for &cl in CONSISTENCY_LEVELS {
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(&error, false, cl)),
policy.decide_should_retry(make_request_info_with_cl(&error, false, cl)),
RetryDecision::RetryNextNode(None)
);

let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(&error, true, cl)),
policy.decide_should_retry(make_request_info_with_cl(&error, true, cl)),
RetryDecision::RetryNextNode(None)
);
}
Expand All @@ -390,22 +390,22 @@ mod tests {
let mut policy_not_idempotent = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy_not_idempotent
.decide_should_retry(make_query_info_with_cl(&error, false, cl)),
.decide_should_retry(make_request_info_with_cl(&error, false, cl)),
max_likely_to_work_cl(alive, cl)
);
assert_eq!(
policy_not_idempotent
.decide_should_retry(make_query_info_with_cl(&error, false, cl)),
.decide_should_retry(make_request_info_with_cl(&error, false, cl)),
RetryDecision::DontRetry
);

let mut policy_idempotent = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy_idempotent.decide_should_retry(make_query_info_with_cl(&error, true, cl)),
policy_idempotent.decide_should_retry(make_request_info_with_cl(&error, true, cl)),
max_likely_to_work_cl(alive, cl)
);
assert_eq!(
policy_idempotent.decide_should_retry(make_query_info_with_cl(&error, true, cl)),
policy_idempotent.decide_should_retry(make_request_info_with_cl(&error, true, cl)),
RetryDecision::DontRetry
);
}
Expand All @@ -430,15 +430,15 @@ mod tests {
// Not idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&enough_responses_no_data,
false,
cl
)),
RetryDecision::RetrySameNode(None)
);
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&enough_responses_no_data,
false,
cl
Expand All @@ -449,15 +449,15 @@ mod tests {
// Idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&enough_responses_no_data,
true,
cl
)),
RetryDecision::RetrySameNode(None)
);
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&enough_responses_no_data,
true,
cl
Expand All @@ -481,7 +481,7 @@ mod tests {
// Not idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&enough_responses_with_data,
false,
cl
Expand All @@ -492,7 +492,7 @@ mod tests {
// Idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&enough_responses_with_data,
true,
cl
Expand All @@ -518,7 +518,7 @@ mod tests {
// Not idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&not_enough_responses_with_data,
false,
cl
Expand All @@ -527,7 +527,7 @@ mod tests {
);
if let RetryDecision::RetrySameNode(new_cl) = expected_decision {
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&not_enough_responses_with_data,
false,
new_cl.unwrap_or(cl)
Expand All @@ -539,7 +539,7 @@ mod tests {
// Idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&not_enough_responses_with_data,
true,
cl
Expand All @@ -548,7 +548,7 @@ mod tests {
);
if let RetryDecision::RetrySameNode(new_cl) = expected_decision {
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&not_enough_responses_with_data,
true,
new_cl.unwrap_or(cl)
Expand All @@ -559,7 +559,7 @@ mod tests {
}
}

// WriteTimeout will retry once when the query is idempotent and write_type == BatchLog
// WriteTimeout will retry once when the request is idempotent and write_type == BatchLog
#[test]
fn downgrading_consistency_write_timeout() {
setup_tracing();
Expand All @@ -579,7 +579,7 @@ mod tests {
// Not idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&write_type_batchlog,
false,
cl
Expand All @@ -590,15 +590,15 @@ mod tests {
// Idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&write_type_batchlog,
true,
cl
)),
RetryDecision::RetrySameNode(None)
);
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&write_type_batchlog,
true,
cl
Expand All @@ -622,7 +622,7 @@ mod tests {
// Not idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&write_type_unlogged_batch,
false,
cl
Expand All @@ -633,15 +633,15 @@ mod tests {
// Idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&write_type_unlogged_batch,
true,
cl
)),
max_likely_to_work_cl(received, cl)
);
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&write_type_unlogged_batch,
true,
cl
Expand All @@ -665,7 +665,7 @@ mod tests {
// Not idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&write_type_other,
false,
cl
Expand All @@ -676,15 +676,15 @@ mod tests {
// Idempotent
let mut policy = DowngradingConsistencyRetryPolicy::new().new_session();
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&write_type_other,
true,
cl
)),
RetryDecision::IgnoreWriteError
);
assert_eq!(
policy.decide_should_retry(make_query_info_with_cl(
policy.decide_should_retry(make_request_info_with_cl(
&write_type_other,
true,
cl
Expand Down
Loading

0 comments on commit cc87b86

Please sign in to comment.