mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-10-01 00:32:05 +00:00
db: enable WAL and index the pending-task lease query
The lease/earliest_run_after queries full-scanned tasks, and the rollback journal blocked readers behind worker writes. journal_mode=WAL (persistent, idempotent) plus idx_tasks_pending(status, run_after) covers both without a schema migration.
This commit is contained in:
@@ -16,6 +16,10 @@ use std::time::Duration;
|
||||
pub fn open_db(path: &str) -> rusqlite::Result<Connection> {
|
||||
let conn = Connection::open(path)?;
|
||||
conn.busy_timeout(Duration::from_secs(5))?;
|
||||
// WAL lets readers run alongside writer leases instead of blocking on
|
||||
// the rollback journal; the mode persists in the DB header, so the
|
||||
// idempotent pragma here and in ensure_schema only needs to win once.
|
||||
conn.pragma_update(None, "journal_mode", "WAL")?;
|
||||
Ok(conn)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user