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
SQLStore: Fix SQLite error propagation if query retries are disabled #64904
Conversation
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.
Looks good to me overall! Just one small suggestion.
i := 0 | ||
callback := func(sess *DBSession) error { | ||
i++ | ||
return sqlite3.Error{Code: sqlite3.ErrBusy} |
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.
Should we also have a test case for the error being sqlite3.ErrLocked
?
@@ -44,6 +44,19 @@ func TestRetryingDisabled(t *testing.T) { | |||
require.Equal(t, 1, i) | |||
}) | |||
|
|||
t.Run(fmt.Sprintf("%s should return the sqlite3.Error immediately", name), func(t *testing.T) { |
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.
Nit: Might be nice to change sqlite3.Error
to sqlite3.ErrBusy
/sqlite3.ErrLocked
depending on the test case.
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-64904-to-v9.3.x origin/v9.3.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 41843464d17df3800df447af4eec1ebfcc54d42b
# Push it to GitHub
git push --set-upstream origin backport-64904-to-v9.3.x
git switch main
# Remove the local backport branch
git branch -D backport-64904-to-v9.3.x Then, create a pull request where the |
the bug was introduced in |
…disabled (#64948) SQLStore: Fix SQLite error propagation if query retries are disabled (#64904) * SQLStore: Add test when query retrying is disabled * Fix condition * Add test cases for sqlite3.ErrLocked (cherry picked from commit 4184346) Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
What is this feature?
The following condition (introduced in #58559) used to fail if the query retries are disabled (equal to zero) (default behaviour):
grafana/pkg/services/sqlstore/session.go
Line 98 in 998b035
As a result due to retryer behaviour:
grafana/pkg/util/retryer/retryer.go
Lines 43 to 45 in 998b035
the
sqlite3.ErrLocked
andsqlite3.ErrBusy
were not propagatedThis fix changes the above condition to check for greater or equal instead
Why do we need this feature?
[Add a description of the problem the feature is trying to solve.]
Who is this feature for?
[Add information on what kind of user the feature is for.]
Which issue(s) does this PR fix?:
Fixes #
Special notes for your reviewer: