Procházet zdrojové kódy

fix: 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 + busy timeout) is SQLite's recommended single-process pattern

clanker před 5 dny
rodič
revize
6d4c551766
1 změnil soubory, kde provedl 13 přidání a 1 odebrání
  1. 13 1
      src/DatabaseConfigurator.vala

+ 13 - 1
src/DatabaseConfigurator.vala

@@ -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;
         }
     }
 }