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

[bugfix] add workaround for Xsqlite_interrupt() permanently breaking connection #2731

Conversation

NyaaaWhatsUpDoc
Copy link
Member

Description

After our modernc.org/sqlite version bump v1.28.0 -> v1.29.2 (further narrowed to be changes in v1.29.0 -> v1.29.2) we started experiencing a regresion, in which canceling a context on an ongoing database query in the right way now causes an Xsqlite_interrupt() call to be made internally, which returns error code SQLITE_INTERRUPT on that connection's running query. Oddly, that then continually gets returned by all subsequent queries on that connection, leaving the instance in a broken state.

We still haven't narrowed this down to an SQLite library change revealing a bug on our end, or whether it's an SQLite library bug.

This is a quick workaround, which works as follows (text copied from matrix dev chat):

"okay i've found a workaround for now. so between v1.29.0 and v1.29.2 is that slightly tweaked interruptOnDone() behaviour, which causes interrupt to (imo, correctly) get called when a context is cancelled to cancel the running query. the issue is that every single query after that point seems to still then return interrupted. so as you thought, maybe that query count isn't being decremented. i don't think it's our code, but i haven't ruled it out yet.

the workaround for now is adding to our sqlite error processor to replace an SQLITE_INTERRUPTED code with driver.ErrBadConn, which hints to the golang sql package that the conn needs to be closed and a new one opened"

Checklist

Please put an x inside each checkbox to indicate that you've read and followed it: [ ] -> [x]

If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have not leveraged AI to create the proposed changes.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc changed the title add workaround for Xsqlite_interrupt() permanently breaking connection [bugfix] add workaround for Xsqlite_interrupt() permanently breaking connection Mar 7, 2024
Copy link
Member

@daenney daenney left a comment

Choose a reason for hiding this comment

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

Thanks for the excellent detective work!

@tsmethurst
Copy link
Contributor

Good workaround! 👍

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.

3 participants