-
Notifications
You must be signed in to change notification settings - Fork 111
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
errors: pager API errors refactor #1160
Open
muzarski
wants to merge
14
commits into
scylladb:main
Choose a base branch
from
muzarski:iterator-errors-refactor
base: main
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
Conversation
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
See the following report for details: cargo semver-checks output
|
github-actions
bot
added
the
semver-checks-breaking
cargo-semver-checks reports that this PR introduces breaking API changes
label
Dec 27, 2024
muzarski
force-pushed
the
iterator-errors-refactor
branch
2 times, most recently
from
December 30, 2024 13:16
c4b17fe
to
3cfdcc7
Compare
Previously, it would return `Option<Result<_, _>>`. This option was meant to represent an empty plan. This additional layer was unnecessary and introduced additional noise. In addition, notice that following part in speculative_execution::execute(): ``` res = async_tasks.select_next_some() => { if let Some(r) = res { if !can_be_ignored(&r) { return r; } else { last_error = Some(r) } } if async_tasks.is_empty() && retries_remaining == 0 { return last_error.unwrap_or({ Err(EMPTY_PLAN_ERROR) }); } } ``` would unnecessarily try to run remaining retries if `None` was returned. This means, we would do the retries (and sleep in between retries) with empty plan. Now, the empty plan error is returned instead of option, and can be handled accordinly in `can_be_ignoed` (we decide not to ignore such error - no point in retrying on another node - there is no other node). I also added a regression test case. The test's timeout is set to 5s. What we try to do, is to run a request with speculative execution policy (6s retry interval) and a LBP that always returns an empty plan. The expected behaviour is that the test completes in less than 5s (no timeout occurs). Otherwise, this would imply that driver was waiting 6s for speculative retry (which was the case before this commit). I've run the test before the change, and it indeed fails.
Introduced "new" error type and adjusted session.rs, speculative_execution module and iterator module to this type. This error represents a definite request failure (after potential retries).
Introduced: - RequestTimeout(std::time::Duration) - for requests that timed out with provided client timeout - SchemaAgreementTimeout(std::time::Duration) - for schema agreement timeouts
RequestError will be passed to HistoryListener when the request either fails or times out.
- `log_attempt_error` will now accept an error representing a single request failure - namely `RequestAttemptError` - `log_query_error` will now accept RequestError, which represents a definite request failure. This is a superset of RequestAttemptError, as it also contains information about potential timeout, empty plan etc.
I marked `PartitionKeyError` as non_exhaustive. Narrowed the return type of remaining funtions that returned `QueryError` to `PartitionKeyError`. Added an explicit conversion function PartitionKeyError -> QueryError.
Narrowed the error types in multiple places in internal API of iterator module. Now the error type we manipulate on mainly is `NextPageError` (instead of `QueryError`). I did not change the return type of public methods yet. I want to do it in a separate commit.
Without this change, tests fail, because we propagate the error for Cassandra clusters, instead of ignoring it.
muzarski
force-pushed
the
iterator-errors-refactor
branch
from
January 16, 2025 14:44
3cfdcc7
to
dc72120
Compare
muzarski
requested review from
wprzytula and
Lorak-mmk
and removed request for
wprzytula
January 16, 2025 15:41
6 tasks
muzarski
changed the title
errors: iterator API errors refactor
errors: pager API errors refactor
Jan 16, 2025
wprzytula
approved these changes
Jan 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
API-stability
Part of the effort to stabilize the API
semver-checks-breaking
cargo-semver-checks reports that this PR introduces breaking API changes
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.
Ref: #519
Motivation
There are three main objectives:
Purge pager.rs module of QueryError
It's yet another module where usage of
QueryError
was abused. It's taken care of in this PRNarrow return error type of
[poll_]next()
methods on iterators/streamsThey now return a self-contained
NextRow
error. It's independent ofQueryError
.Step forward narrowing error type of metadata related functions
Currently all top-level metadata related functions/methods (e.g.
Session::refresh_metadata
) returnQueryError
. This is because low-level methods useQueryPager
API under the hood. Before this PR, the pager API would returnQueryError
. In the follow-up PR we will continue on purging the metadata methods ofQueryError
. It will be replaced with an error type designated for these operations - namelyMetadataError
.Note: I did not check the
All commits compile, pass static checks and pass test.
box, since penultimate commit breaks tests for cassandra. The fix for this is introduced in the last commit. I believe that this is cleaner than introducing the fix in the same commit that change the flow of errors.Pre-review checklist
[ ] I added relevant tests for new features and bug fixes.[ ] I have adjusted the documentation in./docs/source/
.Fixes:
annotations to PR description.