Skip to content
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

Make SQLite wrapper more resilient #4196

Merged
merged 2 commits into from
Feb 26, 2024
Merged

Conversation

JohnMcPMS
Copy link
Member

@JohnMcPMS JohnMcPMS commented Feb 23, 2024

We are seeing some errors from the SQLite usage that appear to largely be related to contention and the FAIL_FAST behavior for savepoint errors. This change is attempting to address the issue by making contention less impactful and moving away from FAIL_FAST.

Change

  • Adds a busy timeout to SQLite connections by default and provides a method to change the value if callers desire. This should prevent small contentions from causing errors.
  • Moves from using FAIL_FAST on critical errors to simply "closing" the connection, making it non-functional for standard use.
  • No longer requests this failure behavior for savepoint commit errors; the rollback can handle that if needed.

Validation

Added tests for the busy timeout and connection closing.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS JohnMcPMS requested a review from a team as a code owner February 23, 2024 06:39
florelis
florelis previously approved these changes Feb 23, 2024
Comment on lines +171 to 172
m_dbconn = std::make_shared<details::SharedConnection>();
m_id = GetNextConnectionId();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to not do these in initializer list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but there isn't really a big reason to do them in the list either.

@JohnMcPMS JohnMcPMS merged commit 22fba89 into microsoft:master Feb 26, 2024
8 checks passed
@JohnMcPMS JohnMcPMS deleted the fail-slow branch February 26, 2024 18:02
JohnMcPMS added a commit to JohnMcPMS/winget-cli that referenced this pull request Feb 27, 2024
We are seeing some errors from the SQLite usage that appear to largely
be related to contention and the `FAIL_FAST` behavior for savepoint
errors. This change is attempting to address the issue by making
contention less impactful and moving away from `FAIL_FAST`.

## Change
- Adds a busy timeout to SQLite connections by default and provides a
method to change the value if callers desire. This should prevent small
contentions from causing errors.
- Moves from using `FAIL_FAST` on critical errors to simply "closing"
the connection, making it non-functional for standard use.
- No longer requests this failure behavior for savepoint commit errors;
the rollback can handle that if needed.
ryfu-msft pushed a commit that referenced this pull request Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants