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] move SQLite pragmas into connection string #2171

Conversation

NyaaaWhatsUpDoc
Copy link
Member

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc commented Aug 31, 2023

Description

As the title says really! Moves the SQLite connection pragmas into the connection string, just to ensure that all our connection preferences are set on every created new connection, considering that it's a little unclear what data is shared across SQLite connections. These are set using the _pragma URI query key as specified in the modernc.org/sqlite.Driver{}.Open() documentation.

An example of a connection string with this:
timestamp="01/09/2023 09:02:20.915" func=bundb.sqliteConn level=INFO msg="connected to SQLITE database with address file:/data/sqlite.db?_pragma=busy_timeout%28300000%29&_pragma=journal_mode%28WAL%29&_pragma=synchronous%28NORMAL%29&_pragma=cache_size%28-8192%29&_txlock=immediate"

Checklist

  • 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 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 marked this pull request as ready for review August 31, 2023 14:48
@NyaaaWhatsUpDoc NyaaaWhatsUpDoc marked this pull request as draft September 1, 2023 08:37
@NyaaaWhatsUpDoc NyaaaWhatsUpDoc marked this pull request as ready for review September 1, 2023 09:06
// `busy_timeout` handler in the case that a data race occurs contending for
// table locks. THERE ARE STILL OTHER SITUATIONS IN WHICH THIS MAY BE RETURNED!
// As such, we use our wrapping DB{} and Tx{} types (in "db.go") which make use
// of our own retry-busy handler.
Copy link
Contributor

Choose a reason for hiding this comment

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

excellent explanation, thanks for writing this up (and thanks from future you and me as well, reading this in two years, who would have had no idea why we did things this way if it wasn't for this comment)

@tsmethurst tsmethurst merged commit 4eb77ff into superseriousbusiness:main Sep 1, 2023
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.

2 participants