Consider WAL mode as default for sqlite
Currently the use of sqlite is in journal mode, this as you've noted in your documentation isn't great for multiple workers.
With this in mind could you consider some better defaults to allow it to work more seamlessly across multiple workers?
await knex.raw("PRAGMA journal_mode = WAL;");
await knex.raw("PRAGMA busy_timeout = 5000;");
await knex.raw("PRAGMA synchronous = NORMAL;");
await knex.raw("PRAGMA cache_size = 2000;");
await knex.raw("PRAGMA foreign_keys = ON;");
Interesting. Let me talk to @merencia about this. Seems doable. Since SQLite is not recommended for production anyway, we can test it and break stuff.
Looking for it.
My use case, using a full RDMS is overkill
BTW for long time i used sqilte (in WAL mode) as database in an app with ~30-50 simultaneous connection without issues
@Mortalife I have created a new PR for this. Thanks for the suggestion. Even the tests are a bit faster now.
:tada: This issue has been resolved in version 1.10.0 :tada:
The release is available on:
v1.10.0- GitHub release
Your semantic-release bot :package::rocket:
Just a PSA, the migration for enabling WAL didn't actually enable WAL in my case.
So I now manually enable the WAL when creating sidequest.
Sidequest.start({
backend: {
driver: "@sidequest/sqlite-backend",
config: {
client: "better-sqlite3",
connection: {
filename: `sidequest.sqlite`,
},
pool: {
afterCreate: (conn: any, cb: any) => {
console.log("Sidequest database connection created");
conn.prepare("PRAGMA journal_mode = WAL").run();
conn.prepare("PRAGMA busy_timeout = 5000").run();
conn.prepare("PRAGMA synchronous = NORMAL").run();
conn.prepare("PRAGMA cache_size = 2000").run();
cb(null, conn);
},
},
},
},
})