-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(scan_operations): add retry policy to cql query #9600
Open
aleksbykov
wants to merge
2
commits into
scylladb:master
Choose a base branch
from
aleksbykov:fix-scan-operations
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
from cassandra import ConsistencyLevel, OperationTimedOut, ReadTimeout | ||
from cassandra.cluster import ResponseFuture, ResultSet # pylint: disable=no-name-in-module | ||
from cassandra.query import SimpleStatement # pylint: disable=no-name-in-module | ||
from cassandra.policies import ExponentialBackoffRetryPolicy | ||
|
||
from sdcm.remote import LocalCmdRunner | ||
from sdcm.sct_events import Severity | ||
|
@@ -106,6 +107,10 @@ def __init__(self, generator: random.Random, thread_params: ThreadParams, thread | |
self.db_node = self._get_random_node() | ||
self.current_operation_stat = None | ||
self.log.info("FullscanOperationBase init finished") | ||
self._exp_backoff_retry_policy_params = { | ||
"max_num_retries": 15.0, "min_interval": 1.0, "max_interval": 1800.0 | ||
} | ||
self._request_default_timeout = 1800 | ||
|
||
def _get_random_node(self) -> BaseNode: | ||
return self.generator.choice(self.fullscan_params.db_cluster.data_nodes) | ||
|
@@ -120,6 +125,8 @@ def execute_query( | |
| FullPartitionScanReversedOrderEvent]) -> ResultSet: | ||
# pylint: disable=unused-argument | ||
self.log.debug('Will run command %s', cmd) | ||
session.cluster.default_retry_policy = ExponentialBackoffRetryPolicy(**self._exp_backoff_retry_policy_params) | ||
session.default_timeout = self._request_default_timeout | ||
return session.execute(SimpleStatement( | ||
cmd, | ||
fetch_size=self.fullscan_params.page_size, | ||
|
@@ -242,6 +249,8 @@ def get_table_clustering_order(self) -> str: | |
with self.fullscan_params.db_cluster.cql_connection_patient(node=node, connect_timeout=300) as session: | ||
# Using CL ONE. No need for a quorum since querying a constant fixed attribute of a table. | ||
session.default_consistency_level = ConsistencyLevel.ONE | ||
session.cluster.default_retry_policy = ExponentialBackoffRetryPolicy( | ||
**self._exp_backoff_retry_policy_params) | ||
return get_table_clustering_order(ks_cf=self.fullscan_params.ks_cf, | ||
ck_name=self.fullscan_params.ck_name, session=session) | ||
except Exception as error: # pylint: disable=broad-except # noqa: BLE001 | ||
|
@@ -266,6 +275,8 @@ def randomly_form_cql_statement(self) -> Optional[tuple[str, str]]: # pylint: d | |
|
||
with self.fullscan_params.db_cluster.cql_connection_patient( | ||
node=db_node, connect_timeout=300) as session: | ||
session.cluster.default_retry_policy = ExponentialBackoffRetryPolicy( | ||
**self._exp_backoff_retry_policy_params) | ||
ck_random_min_value = self.generator.randint(a=1, b=self.fullscan_params.rows_count) | ||
ck_random_max_value = self.generator.randint(a=ck_random_min_value, b=self.fullscan_params.rows_count) | ||
self.ck_filter = ck_filter = self.generator.choice(list(self.reversed_query_filter_ck_by.keys())) | ||
|
@@ -351,6 +362,9 @@ def execute_query( | |
self.log.debug('Will run command "%s"', cmd) | ||
session.default_fetch_size = self.fullscan_params.page_size | ||
session.default_consistency_level = ConsistencyLevel.ONE | ||
session.cluster.default_retry_policy = ExponentialBackoffRetryPolicy(**self._exp_backoff_retry_policy_params) | ||
session.default_timeout = self._request_default_timeout | ||
|
||
return session.execute_async(cmd) | ||
|
||
def reset_output_files(self): | ||
|
@@ -460,6 +474,9 @@ def execute_query(self, session, cmd: str, | |
| FullPartitionScanReversedOrderEvent]) -> None: | ||
self.log.debug('Will run command %s', cmd) | ||
validate_mapreduce_service_requests_start_time = time.time() | ||
session.cluster.default_retry_policy = ExponentialBackoffRetryPolicy(**self._exp_backoff_retry_policy_params) | ||
session.default_timeout = self._session_execution_timeout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a difference between |
||
|
||
try: | ||
cmd_result = session.execute( | ||
query=cmd, trace=False, timeout=self._session_execution_timeout) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit weird it comes next to the code executing the query, and no the code creating the session.
I would recommend consolidating the session creating code into something like:
there way too many repetitions of applying this retry, and it should be across the board for all of the sessions.