Commit Graph

20 Commits

Author SHA1 Message Date
Josh Voyles
522ca671b5 fix: remove no-op autoFinalizeStatement wrapper and redundant busy_timeout (#2120)
better-sqlite3 11.x exposes no Statement.finalize() — the wrapper threw and
swallowed a TypeError on every query (verified: 'Statement.finalize exists:
undefined' in the runner image) while adding +122% per-statement overhead
(3.90 -> 8.66 us/op, 200k-op in-container microbench) and freeing nothing.
Statement lifecycle is GC-managed by the driver; drizzle-orm prepares fresh
per query, so nothing accumulates unbounded.

busy_timeout=5000 duplicates better-sqlite3's default timeout option, which
already arms sqlite3_busy_timeout(db, 5000) at open (lib/database.js).

With ENABLE_SQLITE_WAL_MODE unset the driver is now runtime-identical to
pre-1.18.3 (zero pragmas). The env-gated WAL block stays: journal_mode is
sticky in the DB file, so removing it would strand opted-in databases on
WAL+synchronous=FULL.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 14:53:16 -04:00
Josh Voyles
d94af2b8ea fix(sqlite): remove cache_size and mmap_size PRAGMAs (#2120)
A 64 MB page cache plus a 256 MB memory-mapped region inflate RSS and
cause page-cache thrashing on small (~1 GB) instances. The PRAGMAs were
added to reduce event-loop blocking on TraefikConfigManager JOINs but
the memory cost outweighs the I/O benefit on the deployment shapes that
hit #2120. Leave SQLite on its conservative defaults.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-13 14:53:07 -04:00
Owen
c8e7e0ee1e WAL off default ENABLE_SQLITE_WAL_MODE to enable 2026-05-04 17:54:28 -07:00
Josh Voyles
2154811ffb removed possible introduced HA Redis bug; improved comment 2026-05-03 09:39:27 -04:00
Josh Voyles
9bd33072f4 cleaned comments - more concise 2026-05-03 00:00:11 -04:00
Josh Voyles
2c85bcd06b fix(db): deterministically finalize prepared statements after execution
Wrap Statement .all()/.get()/.run() via autoFinalizeStatement() with
try/finally calling stmt.finalize() post-execution, releasing native
sqlite3_stmt memory immediately instead of waiting for GC.

Safe because:
- Drizzle one-time queries invoke each statement once only
- Drizzle does not access statement after .all()/.get()/.run() returns
- Migration scripts use isolated new Database() instances (unpatched)
- No app code holds persistent .prepare() refs on main db
2026-05-02 15:50:54 -04:00
Josh Voyles
d6abe83fdc fix: memory improvements
- SQLite: enable WAL mode and PRAGMA performance settings

- ws.ts (public + private): fix clientConfigVersions memory leak

- internal server: add rate limiting and request timeouts

- audit log: fix flush re-queue feedback loop

- memory: add monitoring instrumentation

- security: remove debug log of full request body
2026-05-02 07:37:18 -04:00
Owen
edfeec900d Define db type 2026-03-31 14:25:47 -07:00
Owen
3e01bfef7d Move primaryDb into driver 2025-12-18 17:08:50 -05:00
Owen
6b609bb078 Force big queries onto primary db to prevent 40001 2025-12-18 16:03:15 -05:00
miloschwartz
cc62cd4add remove sqlite driver logger 2025-10-30 21:23:05 -07:00
Fred KISSIE
c7df70143e ♻️ log only in DEV 2025-10-29 03:50:36 +01:00
Fred KISSIE
4dd741cc3f 🔊 log all SQL queries 2025-10-25 02:55:19 +02:00
miloschwartz
9af206b69a move schemas to folder 2025-10-13 14:13:26 -07:00
Owen
3a8f04cf14 Add transaction type 2025-09-04 14:01:12 -07:00
miloschwartz
92c09b8843 fix sqlite crash on code 13 bug 2025-07-16 17:26:15 -07:00
miloschwartz
d6fdb38c22 remove vacuum 2025-07-14 16:27:18 -07:00
Adrian Astles
db76558944 refactor: rename passkeyChallenge to webauthnChallenge
- Renamed table for consistency with webauthnCredentials
- Created migration script 1.8.1.ts for table rename
- Updated schema definitions in SQLite and PostgreSQL
- Maintains WebAuthn standard naming convention
2025-07-03 21:53:07 +08:00
miloschwartz
ead5df0a8c simplify installer and remove parsing from read config 2025-06-21 16:35:22 -04:00
miloschwartz
2cca561e51 support postgresql as database option 2025-06-04 12:02:07 -04:00