|
|
@@ -74,7 +74,19 @@ namespace InvercargillSqlInversion {
|
|
|
private static Lifecycle detect_lifecycle(ConnectionString cs) {
|
|
|
bool is_in_memory = cs.database == ":memory:" ||
|
|
|
(cs.has_option("mode") && cs.get_option("mode") == "memory");
|
|
|
- return is_in_memory ? Lifecycle.SINGLETON : Lifecycle.SCOPED;
|
|
|
+ if (is_in_memory) {
|
|
|
+ return Lifecycle.SINGLETON;
|
|
|
+ }
|
|
|
+ // File-backed databases share ONE process-wide connection.
|
|
|
+ // Per-scope connections were never reliably finalised
|
|
|
+ // (request object graphs retain their scoped instances),
|
|
|
+ // leaking a db+wal fd pair per request until FD exhaustion
|
|
|
+ // silently killed the listener and timers. A single
|
|
|
+ // serialized connection (WAL journal mode + busy timeout,
|
|
|
+ // both set by the provider) is SQLite's recommended
|
|
|
+ // single-process pattern, and everything here runs on one
|
|
|
+ // GLib main loop anyway.
|
|
|
+ return Lifecycle.SINGLETON;
|
|
|
}
|
|
|
}
|
|
|
}
|