Prove che cadevano con il runner carico (#46)
Le prove cadevano a ogni carico della CI, ogni volta prove diverse. Dietro alcune c'erano difetti veri: FebeDatabase lasciava i file aperti dopo DisposeAsync (comandi SQLite non chiusi, pool di lettura chiuso dopo lo scrittore), e il WAL spariva durante lo spostamento della cartella Dati; la scheda dell'account senza statistiche leggeva i file di tutta la libreria; l'arresto di FebeApp non aspettava i lavori aggiunti da un avvio in corso. Chromium ha 120 s per avviarsi e aprire la prima scheda, e il ricollegamento smette appena il processo cambia. Nelle prove i limiti di tempo diventano protezioni contro un blocco: attese per condizione con un aiuto comune, limiti per classe nella prova di scala con il tempo migliore, porta 0 e stderr di Chromium nel browser delle prove, e la prova di «Scollega» di WebView2 controlla che il processo esca davvero. Provato su Windows con tutti i core occupati. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e2e64c09e8
commit
0775a1460f
34 files changed
+875
-245
No files matched your search
@@ -118,16 +118,16 @@ public sealed class FebeDatabase : IFebeStorage, IDatabaseMaintenance
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
var mode = connection.Command("PRAGMA journal_mode = WAL").ExecuteScalar() as string;
|
||||
var mode = connection.Scalar("PRAGMA journal_mode = WAL") as string;
|
||||
if (!string.Equals(mode, "wal", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new DatabaseMigrationException(
|
||||
$"Febe non riesce a mettere il database in modalità WAL (modalità attuale: {mode}). La cartella dei dati deve stare su un disco locale.");
|
||||
}
|
||||
|
||||
connection.Command("PRAGMA synchronous = NORMAL").ExecuteNonQuery();
|
||||
connection.Command($"PRAGMA busy_timeout = {BusyTimeoutMs}").ExecuteNonQuery();
|
||||
connection.Command("PRAGMA foreign_keys = ON").ExecuteNonQuery();
|
||||
connection.Execute("PRAGMA synchronous = NORMAL");
|
||||
connection.Execute($"PRAGMA busy_timeout = {BusyTimeoutMs}");
|
||||
connection.Execute("PRAGMA foreign_keys = ON");
|
||||
var version = MigrationRunner.Apply(connection, migrations);
|
||||
return new FebeDatabase(path, connection, readConnectionString, version);
|
||||
}
|
||||
@@ -155,6 +155,7 @@ public sealed class FebeDatabase : IFebeStorage, IDatabaseMaintenance
|
||||
try
|
||||
{
|
||||
using var connection = OpenReadConnection();
|
||||
using var commands = CommandScope.Begin(); // disposed first: the connection then really closes
|
||||
return Task.FromResult(work(connection));
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
@@ -184,7 +185,8 @@ public sealed class FebeDatabase : IFebeStorage, IDatabaseMaintenance
|
||||
connection =>
|
||||
{
|
||||
// VACUUM INTO reads a consistent snapshot; it works on a read-only connection and does not block the writer.
|
||||
connection.Command("VACUUM INTO @destination").With("@destination", destination).ExecuteNonQuery();
|
||||
using var vacuum = connection.Command("VACUUM INTO @destination").With("@destination", destination);
|
||||
vacuum.ExecuteNonQuery();
|
||||
return true;
|
||||
},
|
||||
ct);
|
||||
@@ -210,9 +212,17 @@ public sealed class FebeDatabase : IFebeStorage, IDatabaseMaintenance
|
||||
}
|
||||
|
||||
Writer.Dispose();
|
||||
|
||||
// The idle read connections close first, so the writer is the last connection: only the writer can checkpoint
|
||||
// and delete febe.sqlite-wal and -shm when it closes (a read-only connection leaves them behind).
|
||||
using (var pooled = new SqliteConnection(_readConnectionString))
|
||||
{
|
||||
SqliteConnection.ClearPool(pooled);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_writerConnection.Command("PRAGMA wal_checkpoint(TRUNCATE)").ExecuteNonQuery();
|
||||
_writerConnection.Execute("PRAGMA wal_checkpoint(TRUNCATE)");
|
||||
}
|
||||
catch (SqliteException)
|
||||
{
|
||||
@@ -220,11 +230,6 @@ public sealed class FebeDatabase : IFebeStorage, IDatabaseMaintenance
|
||||
}
|
||||
|
||||
_writerConnection.Dispose();
|
||||
using (var pooled = new SqliteConnection(_readConnectionString))
|
||||
{
|
||||
SqliteConnection.ClearPool(pooled);
|
||||
}
|
||||
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user