perf(store-and-forward): enable WAL + per-connection busy_timeout on the S&F SQLite store

This commit is contained in:
Joseph Doherty
2026-07-08 21:01:53 -04:00
parent 7626d5ba34
commit 499a37ac78
2 changed files with 70 additions and 30 deletions
@@ -656,4 +656,31 @@ public class StoreAndForwardStorageTests : IAsyncLifetime, IDisposable
Directory.Delete(directory, recursive: true);
}
}
[Fact]
public async Task Initialize_EnablesWalJournalMode_OnFileDatabase()
{
// WAL lets the retry-sweep lanes, script enqueues, and standby replication
// applies read/write concurrently without "database is locked". journal_mode
// is persistent + file-scoped, so a fresh connection observes it.
var directory = Path.Combine(Path.GetTempPath(), "sf-wal-test-" + Guid.NewGuid().ToString("N"));
var path = Path.Combine(directory, "wal-test.db");
try
{
var storage = new StoreAndForwardStorage(
$"Data Source={path}", NullLogger<StoreAndForwardStorage>.Instance);
await storage.InitializeAsync();
await using var conn = new SqliteConnection($"Data Source={path}");
await conn.OpenAsync();
await using var cmd = conn.CreateCommand();
cmd.CommandText = "PRAGMA journal_mode";
Assert.Equal("wal", (string)(await cmd.ExecuteScalarAsync())!);
}
finally
{
if (Directory.Exists(directory))
Directory.Delete(directory, recursive: true);
}
}
}