fix(checklist): recover only system-key duplicate races

This commit is contained in:
cesnimda
2026-11-18 18:53:20 +01:00
parent be984f1b5f
commit 63db9c8a34
44 changed files with 804 additions and 2 deletions
@@ -0,0 +1,129 @@
using System.Data.Common;
using System.Text.Json;
using JobTrackerApi.Models;
using JobTrackerApi.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Xunit;
using Xunit.Abstractions;
namespace JobTrackerApi.MariaDb.Tests;
public sealed class AnalyticsStatsPersistenceTests(ITestOutputHelper output)
{
private const string Owner = "rd21-owner";
[Theory]
[InlineData(0)]
[InlineData(250)]
[InlineData(2500)]
public async Task Stats_keep_owned_results_with_bounded_native_roundtrips(int size)
{
await using var database = await MariaDbDatabase.CreateAsync();
var recorder = new Reads();
await using var db = database.Context(interceptor: recorder);
var company = new Company { Name = "Synthetic analytics", OwnerUserId = Owner };
db.Companies.Add(company);
await db.SaveChangesAsync();
var date = DateTime.Now.AddDays(-10);
db.JobApplications.AddRange(Enumerable.Range(0, size).Select(_ => Job(company.Id, Owner, "Applied", date)));
db.JobApplications.Add(Job(company.Id, "foreign-owner", "Private", date));
db.JobApplications.Add(Job(company.Id, null, "Unowned", date));
await db.SaveChangesAsync();
db.ChangeTracker.Clear();
recorder.Sql.Clear();
var stats = await new AnalyticsService(db).GetStatsAsync(default);
Assert.Equal(size, stats.Total);
Assert.Equal(size, stats.Active);
Assert.Equal(0, stats.Deleted);
Assert.Equal(size, stats.AppliedLast30Days);
Assert.Equal(size == 0 ? 0 : 10, stats.AverageDaysSinceApplied);
Assert.Equal(size == 0 ? 0 : 1, stats.ByStatus.Count);
if (size > 0) Assert.Equal(size, stats.ByStatus["Applied"]);
Assert.Empty(db.ChangeTracker.Entries());
Assert.All(recorder.Sql, sql =>
{
Assert.DoesNotContain("Description", sql);
Assert.DoesNotContain("CoverLetterText", sql);
});
output.WriteLine(JsonSerializer.Serialize(new { database.ActualVersion, OwnedRows = size,
Commands = recorder.Sql.Count, Sql = recorder.Sql }));
Assert.Equal(size == 0 ? 2 : 3, recorder.Sql.Count);
}
[Fact]
public async Task Stats_preserve_native_nullable_dates_deletion_ownership_and_mutation()
{
await using var database = await MariaDbDatabase.CreateAsync();
await using var db = database.Context();
var company = new Company { Name = "Synthetic semantics", OwnerUserId = Owner };
db.Add(company);
await db.SaveChangesAsync();
var now = DateTime.Now;
db.JobApplications.AddRange(
Job(company.Id, Owner, "Applied", now.AddDays(-29)),
Job(company.Id, Owner, "Interview", now.AddDays(-31)),
Job(company.Id, Owner, "", null),
Job(company.Id, Owner, " ", now.AddDays(2)),
Job(company.Id, Owner, "Unknown", null),
Job(company.Id, Owner, "Deleted", now, deleted: true),
Job(company.Id, "foreign-owner", "Private", now),
Job(company.Id, null, "Unowned", now));
await db.SaveChangesAsync();
var service = new AnalyticsService(db);
var stats = await service.GetStatsAsync(default);
Assert.Equal(6, stats.Total);
Assert.Equal(5, stats.Active);
Assert.Equal(1, stats.Deleted);
Assert.Equal(2, stats.AppliedLast30Days);
Assert.Equal(20, stats.AverageDaysSinceApplied);
Assert.Equal(3, stats.ByStatus["Unknown"]);
Assert.Equal(1, stats.ByStatus["Applied"]);
Assert.Equal(1, stats.ByStatus["Interview"]);
await using var other = database.Context("foreign-owner");
Assert.Equal(1, (await new AnalyticsService(other).GetStatsAsync(default)).Total);
await using var anonymous = database.Context(null!);
var denied = await new AnalyticsService(anonymous).GetStatsAsync(default);
Assert.Equal(0, denied.Total);
Assert.Empty(denied.ByStatus);
db.JobApplications.Add(Job(company.Id, Owner, "Saved", null));
await db.SaveChangesAsync();
Assert.Equal(7, (await service.GetStatsAsync(default)).Total);
output.WriteLine(database.ActualVersion);
}
[Fact]
public async Task Cancellation_at_native_command_boundary_prevents_later_stats_reads()
{
await using var database = await MariaDbDatabase.CreateAsync();
using var cancellation = new CancellationTokenSource();
var recorder = new Reads { BeforeRead = cancellation.Cancel };
await using var db = database.Context(interceptor: recorder);
await Assert.ThrowsAnyAsync<OperationCanceledException>(() =>
new AnalyticsService(db).GetStatsAsync(cancellation.Token));
Assert.Single(recorder.Sql);
output.WriteLine(database.ActualVersion);
}
private static JobApplication Job(int companyId, string? owner, string status, DateTime? date, bool deleted = false) => new()
{
CompanyId = companyId, OwnerUserId = owner, JobTitle = "Synthetic analyst", Status = status,
DateApplied = date, IsDeleted = deleted, Description = "Synthetic wide data must not be selected",
CoverLetterText = "Synthetic private letter must not be selected",
};
private sealed class Reads : DbCommandInterceptor
{
public List<string> Sql { get; } = [];
public Action? BeforeRead { get; init; }
public override ValueTask<InterceptionResult<DbDataReader>> ReaderExecutingAsync(DbCommand command,
CommandEventData eventData, InterceptionResult<DbDataReader> result, CancellationToken cancellationToken = default)
{
Sql.Add(command.CommandText);
BeforeRead?.Invoke();
return base.ReaderExecutingAsync(command, eventData, result, cancellationToken);
}
}
}
@@ -0,0 +1,124 @@
using JobTrackerApi.Models;
using JobTrackerApi.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using MySqlConnector;
using Xunit;
using Xunit.Abstractions;
namespace JobTrackerApi.MariaDb.Tests;
public sealed class ApplicationChecklistPersistenceTests(ITestOutputHelper output)
{
private const string Owner = "rd21-owner";
[Theory]
[InlineData("system-key")]
[InlineData("foreign-key")]
[InlineData("unrelated-unique")]
public async Task Seed_recovers_only_its_actual_unique_constraint(string scenario)
{
await using var database = await MariaDbDatabase.CreateAsync();
int jobId;
const string spoof = "IX_ApplicationChecklistItems_JobApplicationId_SystemKey";
await using (var seed = database.Context())
{
seed.Users.Add(new ApplicationUser { Id = Owner, UserName = spoof, NormalizedUserName = spoof });
var job = new JobApplication { OwnerUserId = Owner, Company = new Company { OwnerUserId = Owner, Name = "Synthetic checklist" }, Status = "Interview", Version = 7 };
seed.JobApplications.Add(job);
await seed.SaveChangesAsync();
jobId = job.Id;
seed.ApplicationChecklistItems.AddRange(
new ApplicationChecklistItem { OwnerUserId = Owner, JobApplicationId = jobId, SystemKey = "prepare-cv", AutoSignal = ChecklistSignalKeys.Cv,
IsSystemGenerated = true, Title = "Prepare CV", Category = ChecklistCategories.Preparation, Status = ChecklistStatuses.Dismissed },
new ApplicationChecklistItem { OwnerUserId = Owner, JobApplicationId = jobId, Title = "Manual decision", Category = ChecklistCategories.Custom,
Status = ChecklistStatuses.Done, SortOrder = 90 });
await seed.SaveChangesAsync();
}
var race = new Race();
await using var winner = database.Context(interceptor: new Gate(race, winner: true));
var losingGate = new Gate(race, winner: false, saveOtherFirst: scenario == "unrelated-unique");
await using var loser = database.Context(interceptor: losingGate);
if (scenario == "foreign-key")
loser.ApplicationChecklistItems.Add(new ApplicationChecklistItem { OwnerUserId = Owner, JobApplicationId = int.MaxValue,
Title = "Invalid parent must fail", Status = ChecklistStatuses.Done });
if (scenario == "unrelated-unique")
loser.Users.Add(new ApplicationUser { Id = "other-user", UserName = spoof, NormalizedUserName = spoof });
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var winningRead = new ApplicationChecklistService(winner).GetAsync(Owner, jobId, timeout.Token);
var losingRead = new ApplicationChecklistService(loser).GetAsync(Owner, jobId, timeout.Token);
Assert.NotNull(await winningRead);
var observed = await Record.ExceptionAsync(async () => await losingRead);
var saveError = Assert.IsType<DbUpdateException>(losingGate.Failure);
var native = Assert.IsType<MySqlException>(saveError.InnerException);
output.WriteLine($"Server={database.ActualVersion}; scenario={scenario}; native={native.Number}; message={native.Message}; service={observed?.GetType().Name ?? "none"}");
if (scenario == "system-key")
{
Assert.Equal(1062, native.Number);
Assert.Null(observed);
var first = (await winningRead)!;
var second = (await losingRead)!;
Assert.Equal(first.Items.Select(item => item.Id).Order(), second.Items.Select(item => item.Id).Order());
Assert.Equal(ChecklistStatuses.Dismissed, second.Items.Single(item => item.SystemKey == "prepare-cv").Status);
Assert.Equal(ChecklistStatuses.Done, second.Items.Single(item => item.SystemKey == null).Status);
}
else
{
if (scenario == "unrelated-unique")
{
Assert.EndsWith("for key 'UserNameIndex'", native.Message);
Assert.Contains(spoof, native.Message, StringComparison.Ordinal);
}
Assert.IsType<DbUpdateException>(observed);
Assert.Equal(scenario == "foreign-key" ? 1452 : 1062, native.Number);
Assert.True(loser.ChangeTracker.Entries().Any(entry => entry.State == EntityState.Added));
}
await using var verify = database.Context();
Assert.Equal(15, await verify.ApplicationChecklistItems.CountAsync());
Assert.Equal(7, (await verify.JobApplications.SingleAsync()).Version);
Assert.Equal(1, await verify.Users.CountAsync());
}
private sealed class Race
{
private int _arrivals;
public TaskCompletionSource BothReady { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);
public TaskCompletionSource Committed { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);
public void Arrive() { if (Interlocked.Increment(ref _arrivals) == 2) BothReady.TrySetResult(); }
}
private sealed class Gate(Race race, bool winner, bool saveOtherFirst = false) : SaveChangesInterceptor
{
private bool _used;
public Exception? Failure { get; private set; }
public override async ValueTask<InterceptionResult<int>> SavingChangesAsync(DbContextEventData data, InterceptionResult<int> result, CancellationToken ct = default)
{
if (_used) return result;
_used = true;
race.Arrive();
await race.BothReady.Task.WaitAsync(ct);
if (!winner) await race.Committed.Task.WaitAsync(ct);
if (saveOtherFirst)
{
// Force the unrelated tracked write first; normal batch ordering hits checklist duplicates first.
var context = data.Context!;
var seeds = context.ChangeTracker.Entries<ApplicationChecklistItem>()
.Where(entry => entry.State == EntityState.Added).ToList();
foreach (var seed in seeds) seed.State = EntityState.Detached;
try { await context.SaveChangesAsync(ct); }
finally { foreach (var seed in seeds) context.Add(seed.Entity); }
}
return result;
}
public override ValueTask<int> SavedChangesAsync(SaveChangesCompletedEventData data, int result, CancellationToken ct = default)
{
if (winner) race.Committed.TrySetResult();
return ValueTask.FromResult(result);
}
public override Task SaveChangesFailedAsync(DbContextErrorEventData data, CancellationToken ct = default)
{
Failure = data.Exception;
return Task.CompletedTask;
}
}
}
@@ -0,0 +1,134 @@
using JobTrackerApi.Data;
using JobTrackerApi.Models;
using JobTrackerApi.Services;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Moq;
using Xunit;
using Xunit.Abstractions;
namespace JobTrackerApi.Tests;
public sealed class ApplicationChecklistConcurrencyTests(ITestOutputHelper output)
{
[Fact]
public async Task Native_duplicate_seed_race_recovers_both_reads_without_losing_user_decisions()
{
await using var database = await Database.Create();
var race = new SeedRace();
await using var winner = database.Context(new SeedGate(race, winner: true));
var loserGate = new SeedGate(race, winner: false);
await using var loser = database.Context(loserGate);
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(20));
var results = await Task.WhenAll(
new ApplicationChecklistService(winner).GetAsync(Database.Owner, database.JobId, timeout.Token),
new ApplicationChecklistService(loser).GetAsync(Database.Owner, database.JobId, timeout.Token));
Assert.All(results, result => Assert.NotNull(result));
Assert.Equal(results[0]!.Items.Select(x => x.Id).Order(), results[1]!.Items.Select(x => x.Id).Order());
Assert.All(results, result =>
{
Assert.Equal(14, result!.Items.Count(x => x.SystemKey != null));
Assert.Equal(ChecklistStatuses.Dismissed, result.Items.Single(x => x.SystemKey == "prepare-cv").Status);
Assert.Equal("Manual decision", result.Items.Single(x => x.SystemKey == null).Title);
Assert.Equal(ChecklistStatuses.Done, result.Items.Single(x => x.SystemKey == null).Status);
});
var duplicate = Assert.IsType<SqliteException>(Assert.IsType<DbUpdateException>(loserGate.Failure).InnerException);
Assert.Equal(2067, duplicate.SqliteExtendedErrorCode);
await using var verify = database.Context();
Assert.Equal(15, await verify.ApplicationChecklistItems.CountAsync());
Assert.Equal(7, (await verify.JobApplications.SingleAsync()).Version);
Assert.DoesNotContain(loser.ChangeTracker.Entries<ApplicationChecklistItem>(), entry => entry.State == EntityState.Added);
output.WriteLine("Native SQLite duplicate2067 observed and recovered; both calls returned the same15 persisted IDs, user decisions and job revision7 preserved.");
}
[Fact]
public async Task Concurrent_seed_recovery_does_not_swallow_an_unrelated_native_foreign_key_failure()
{
await using var database = await Database.Create();
var race = new SeedRace();
await using var winner = database.Context(new SeedGate(race, winner: true));
var loserGate = new SeedGate(race, winner: false);
await using var loser = database.Context(loserGate);
var invalidCustom = new ApplicationChecklistItem { OwnerUserId = Database.Owner, JobApplicationId = int.MaxValue, Title = "Invalid parent must fail", Status = ChecklistStatuses.Done };
loser.ApplicationChecklistItems.Add(invalidCustom);
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(20));
var winningRead = new ApplicationChecklistService(winner).GetAsync(Database.Owner, database.JobId, timeout.Token);
var losingRead = new ApplicationChecklistService(loser).GetAsync(Database.Owner, database.JobId, timeout.Token);
Assert.NotNull(await winningRead);
var observed = await Record.ExceptionAsync(async () => await losingRead);
output.WriteLine($"Native save error={((loserGate.Failure as DbUpdateException)?.InnerException as SqliteException)?.SqliteExtendedErrorCode}; service exception={observed?.GetType().Name ?? "none"}.");
var error = Assert.IsType<DbUpdateException>(observed);
var native = Assert.IsType<SqliteException>(error.InnerException);
Assert.Equal(787, native.SqliteExtendedErrorCode);
Assert.Equal(EntityState.Added, loser.Entry(invalidCustom).State);
await using var verify = database.Context();
Assert.Equal(15, await verify.ApplicationChecklistItems.CountAsync());
Assert.False(await verify.ApplicationChecklistItems.AnyAsync(x => x.Title == invalidCustom.Title));
output.WriteLine("Native SQLite foreign-key787 propagated despite another request having persisted all missing default keys.");
}
private sealed class SeedRace
{
private int _arrivals;
public TaskCompletionSource BothReady { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);
public TaskCompletionSource WinnerCommitted { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);
public void Arrive() { if (Interlocked.Increment(ref _arrivals) == 2) BothReady.TrySetResult(); }
}
private sealed class SeedGate(SeedRace race, bool winner) : SaveChangesInterceptor
{
private bool _used;
public Exception? Failure { get; private set; }
public override async ValueTask<InterceptionResult<int>> SavingChangesAsync(DbContextEventData eventData, InterceptionResult<int> result, CancellationToken cancellationToken = default)
{
if (_used) return result;
_used = true;
race.Arrive();
await race.BothReady.Task.WaitAsync(cancellationToken);
if (!winner) await race.WinnerCommitted.Task.WaitAsync(cancellationToken);
return result;
}
public override ValueTask<int> SavedChangesAsync(SaveChangesCompletedEventData eventData, int result, CancellationToken cancellationToken = default)
{
if (winner) race.WinnerCommitted.TrySetResult();
return ValueTask.FromResult(result);
}
public override Task SaveChangesFailedAsync(DbContextErrorEventData eventData, CancellationToken cancellationToken = default)
{
Failure = eventData.Exception;
return Task.CompletedTask;
}
}
private sealed class Database(string file) : IAsyncDisposable
{
public const string Owner = "owner";
public int JobId { get; private set; }
public JobTrackerContext Context(SaveChangesInterceptor? interceptor = null)
{
var options = new DbContextOptionsBuilder<JobTrackerContext>().UseSqlite($"Data Source={file};Pooling=False");
if (interceptor != null) options.AddInterceptors(interceptor);
var user = new Mock<ICurrentUserService>();
user.SetupGet(x => x.UserId).Returns(Owner);
return new JobTrackerContext(options.Options, user.Object);
}
public static async Task<Database> Create()
{
var database = new Database(Path.Combine(Path.GetTempPath(), $"checklist-race-{Guid.NewGuid():N}.db"));
await using var db = database.Context();
await db.Database.EnsureCreatedAsync();
db.Users.Add(new ApplicationUser { Id = Owner });
var job = new JobApplication { OwnerUserId = Owner, Company = new Company { OwnerUserId = Owner, Name = "Synthetic" }, Status = "Interview", Version = 7 };
db.JobApplications.Add(job);
await db.SaveChangesAsync();
database.JobId = job.Id;
db.ApplicationChecklistItems.AddRange(
new ApplicationChecklistItem { OwnerUserId = Owner, JobApplicationId = job.Id, SystemKey = "prepare-cv", AutoSignal = ChecklistSignalKeys.Cv, IsSystemGenerated = true, Title = "Prepare CV", Category = ChecklistCategories.Preparation, Status = ChecklistStatuses.Dismissed },
new ApplicationChecklistItem { OwnerUserId = Owner, JobApplicationId = job.Id, Title = "Manual decision", Category = ChecklistCategories.Custom, Status = ChecklistStatuses.Done, SortOrder = 90 });
await db.SaveChangesAsync();
return database;
}
public ValueTask DisposeAsync() { File.Delete(file); return ValueTask.CompletedTask; }
}
}
@@ -388,7 +388,7 @@ public sealed class ApplicationChecklistService : IApplicationChecklistService
await _db.SaveChangesAsync(ct);
return items;
}
catch (DbUpdateException)
catch (DbUpdateException ex) when (IsDuplicateSystemKey(ex))
{
foreach (var item in seeded) _db.Entry(item).State = EntityState.Detached;
@@ -401,6 +401,17 @@ public sealed class ApplicationChecklistService : IApplicationChecklistService
}
}
private static bool IsDuplicateSystemKey(DbUpdateException exception) => exception.InnerException switch
{
Microsoft.Data.Sqlite.SqliteException sqlite => sqlite.SqliteErrorCode == 19
&& sqlite.SqliteExtendedErrorCode == 2067
&& sqlite.Message.EndsWith("UNIQUE constraint failed: ApplicationChecklistItems.JobApplicationId, ApplicationChecklistItems.SystemKey'.", StringComparison.Ordinal),
MySqlConnector.MySqlException mysql => mysql.Number == 1062
&& (mysql.Message.EndsWith("for key 'IX_ApplicationChecklistItems_JobApplicationId_SystemKey'", StringComparison.Ordinal)
|| mysql.Message.EndsWith("for key 'ApplicationChecklistItems.IX_ApplicationChecklistItems_JobApplicationId_SystemKey'", StringComparison.Ordinal)),
_ => false,
};
private async Task SyncAutoCompletionAsync(List<ApplicationChecklistItem> items, ChecklistSignals signals, CancellationToken ct)
{
var changed = false;
@@ -0,0 +1,35 @@
# Native MariaDB qualification: statistics and checklist recovery
18November2026. Isolated codex/perf-mariadb-qualification started at1db5f488; analytics41134d8f was cherry-picked asbe984f1b, then the recovered checklist correction was tested alongside it. No startup-script, existing app container, persistent development data, production service or model was changed.
## Actual provider evidence
Docker Desktop's local Linux engine became available after the user started the local app. The existing disposable MariaDB lane was used with its cached pinned12.2.2 manifest, a generated jobtracker-it project, fresh loopback port, tmpfs database,1CPU/768MiB limit and existing generated jt_it schema guard. Exact observed version: **12.2.2-MariaDB-ubu2404**. The fixture initialises the actual startup schema, uses independent TCP contexts and drops only each successfully-created schema. Locked restore used the existing NuGet cache with package sources cleared; no package versions changed or network restore was needed.
| Execution | Result | Meaning |
| --- | --- | --- |
| Original statistics, five new cases |3 expected budget failures /2 passes | Owned results/cancellation remained correct; measured5 commands for250/2500 active rows and4 empty |
| Original checklist, corrected native ordering |1 pass /2 failures | Genuine duplicate recovery succeeds; unrelated FK1452 and username-unique1062 errors were swallowed |
| Optimised statistics and narrowed checklist |8/8 passed,0skips | New actual-provider cases pass; statistics uses3 active/2 empty commands |
| Complete MariaDB persistence project |**98/98 passed,0skips**,169seconds | Includes those8; never add98+8 |
| Ordinary affected checklist project subset |**17/17 passed**,0skips | Includes two new SQLite concurrency cases and15 existing service cases; earlier2-case runs overlap17 |
This supersedes the prior NOT RUN boundary for these specific local MariaDB operations. It does not establish hosted CI, production equivalence, query plans/rows examined, load/p95/throughput, connection-pool tuning, restore/rollback, TLS, physical PDF fidelity or human/device/provider/model acceptance. Statistics' date projection still grows with applied active rows; only the measured roundtrips are reduced. No new cache, schema, migration, controller/DTO or overview change was introduced.
## Checklist defect and minimal correction
The original seed method recovered any DbUpdateException once another request had persisted all missing system keys. Native SQLite reproduced FK787 being swallowed; real MariaDB reproduced FK1452 and an unrelated username-unique1062 being swallowed. The catch now handles only the actual checklist system-key unique constraint. Unknown/foreign-key/concurrency failures propagate through existing error handling. MySQL matching uses the terminal key identity, so a duplicate value containing the checklist index's name cannot impersonate that index. SQLite requires its exact unique column-list suffix and native19/2067 codes. Existing missing-key revalidation and detach-only-this-call's-seeds behaviour remain.
Positive races retain the same15 persisted IDs,14 system items, dismissed/manual user decisions and job revision7. Other pending writes remain tracked after failure. This is bounded recovery correctness, not an unrestricted retry or proof that every network-uncertain write is idempotent.
The first native unrelated-unique proposal hit the genuine checklist constraint before the intended username error. Its corrected test interceptor temporarily detaches only new checklist seeds, flushes the unrelated tracked user first and restores those seeds; real EF/MySqlConnector still produces the error. The final synthetic duplicate value was shortened so MariaDB's diagnostic truncation retains the entire index-name text. Original and corrected negative runs are retained; these verifier changes are not application fixes. Red test-file snapshots were not frozen at execution; original production Git baseline and native failure outputs are retained, rather than claiming complete immutable red test sources.
The historical reminders log contains two distinct observations: expected duplicate-key diagnostics and a separate OperationCanceledException stack in GetReminders. Deterministic duplicate races can return both successful service results despite EF logging. No request correlation proves the cause or harmlessness of the historical cancelled HTTP request, and this package does not claim to fix it.
## Isolation and evidence
After the98-case run, zero jt_it schemas remained. Cleanup verified generated project/service labels, pinned image and tmpfs at /var/lib/mysql with **no persistent mounts**, retained server logs, then removed only the owned mariadb-test service with Compose rm--stop--force. No down/-v was used. Docker reports this tmpfs in HostConfig.Tmpfs rather than Mounts; an initial stricter inspection failed safely before cleanup, then was corrected from the actual fields. The user's three local app containers remained healthy.
Exact source/native gzip/TRX, target identity, cleanup and counts: [receipts](native-mariadb-20261118/evidence/SOURCE_RECEIPTS.json). All data/accounts are synthetic; application credentials and browser traces are excluded. The ordinary test source and API classifier were copied byte-for-byte from the recovered worktree; current source hashes bind both test projects. Adding the ordinary test file after the MariaDB run changes neither the API nor the separate MariaDB assembly, so unchanged native evidence is reused. Source/API/tests have no pending product changes beyond those listed.
AST-only update passed19,974nodes/49,552edges with existing PDF/SQL/symbol-free input warnings; no model processing. Rollback restores the small predicate/count deltas and removes their tests; no data migration or rollback is required. Formal roadmap/security/release gates remain open.
+5 -1
View File
@@ -1,4 +1,4 @@
# PERF-06 · Analytics stats aggregate queries
# PERF-06 · Analytics stats aggregate queries
Application baseline `1db5f488f6138e4f0f33749452b7d9f47658f4b0`, isolated `codex/analytics-query-batch`. Roadmap source `271d37d1`, `docs/direct-roadmap/LATEST_CHECKPOINT.md` and PERF-06 in `ROADMAP_TODO.md`, required a measured baseline before combining queries. The only application edit is inside `AnalyticsService.GetStatsAsync`; controller, DTO, overview, schema, configuration, Career completeness and caching are unchanged.
@@ -37,3 +37,7 @@ Nine of those dedicated cases execute SQLite. The legacy **null Status** case us
**Actual MariaDB execution/server acceptance, EXPLAIN/rows examined, native cancellation and provider-specific status collation remain NOT RUN.** Pomelo SQL generation alone does not establish those properties. Before MariaDB qualification, execute the actual service against a disposable pinned MariaDB fixture with the same ownership/deletion/date/status cases and measure its command/plan behavior. SQLite results do not qualify the standard MariaDB deployment or infer throughput gains. The change adds no cross-query transaction snapshot; status/date queries remain separate, as before.
No full backend suite, frontend regression, browser, hosted CI, production workload, provider/model, deployment or orchestrator work was performed. Parent review/integration and real-provider qualification remain separate decisions. No main merge or push was performed by this worker.
## Subsequent actual-provider qualification
The historical boundaries above describe this original package. The later [native MariaDB qualification](NATIVE_MARIADB_20261118.md) records 98 passing local persistence tests, including the real-provider statistics cases and measured command counts. Hosted/production, query plans and workload performance remain separate.
@@ -0,0 +1,365 @@
{
"baseline": "1db5f488f6138e4f0f33749452b7d9f47658f4b0",
"candidateHead": "be984f1b",
"candidateDelta": "Reviewed ApplicationChecklistService narrow classifier; source hashes below",
"native": [
{
"file": "state.json.gz",
"rawBytes": 263,
"rawSha256": "14a8a012e7af5f731540d6c539187a1b9590536e43fceb97170154a010dae5b6",
"gzipSha256": "081326aef36aec9879e4b51c063ec87151f287a0417e35224fe54b8372604edf"
},
{
"file": "target.json.gz",
"rawBytes": 480,
"rawSha256": "3094a11fbbbad68ca01ca9668438564a29b4142752abeafb0b5afcb755ecb177",
"gzipSha256": "eca5d54bd9672274af0fad1e0005a08722dbfa941fb06a20a771ef42b7484f5c"
},
{
"file": "start.txt.gz",
"rawBytes": 1698,
"rawSha256": "ed8b02e69cda13fa442dac34fc5bf1d046b481cfd77a436c2b001099871667a6",
"gzipSha256": "2bed921ad2d3cc917a6b8360a1cbeea2779e235aa9f25f17dd1219b93710150f"
},
{
"file": "restore.txt.gz",
"rawBytes": 1708,
"rawSha256": "e2e1cd7fe736511fa682d7f6f1d458fa00be57e44bbd3fb12a4e5e9996f93a84",
"gzipSha256": "e47176aab7f430b34dfe9af83cd3fe03b6c43c0639b23f68b27becaa10335225"
},
{
"file": "baseline.txt.gz",
"rawBytes": 18572,
"rawSha256": "0c7ba5b475c16b561c955c3dad149a4ebf15ff6796c31438d963420fa70f93a7",
"gzipSha256": "ddbdfe2febf5c72ff53e7fd60fe0650f4eb340d35a1520e1d382e5bd690b64ed"
},
{
"file": "baseline.trx.gz",
"rawBytes": 26073,
"rawSha256": "76ba28b8d14eac934492ef5d1b9e66ec828015c2e1cea60251fb5db833583121",
"gzipSha256": "06a80722382e3de1c6d1b65fd72eaf1003fbe59116f73edd812e66e5f1112fae"
},
{
"file": "baseline.exit.txt.gz",
"rawBytes": 3,
"rawSha256": "f1b2f662800122bed0ff255693df89c4487fbdcf453d3524a42d4ec20c3d9c04",
"gzipSha256": "baf0683e1103b94b68d94e8a12d7e144b4e0571e9948de7fb0d85103b045460e"
},
{
"file": "checklist-baseline.txt.gz",
"rawBytes": 11890,
"rawSha256": "6f18ee0c89d2671fe77885cf9e6fea6eb217b0b881659aa88661e760d52478c7",
"gzipSha256": "eb4e72dc1dcc4f0b825a223fdbb04030494fd8bdc1018598b56990ed9d18b9b8"
},
{
"file": "checklist-baseline.trx.gz",
"rawBytes": 15303,
"rawSha256": "80a736c8c7f10dd008512a84b85d2ef70fe7781f694e7c4070d278b195b44db3",
"gzipSha256": "949cc22dc48cfde8cb0db7c6c1c660419550f43286c27a985d1a4f1bc3819d5b"
},
{
"file": "checklist-baseline.exit.txt.gz",
"rawBytes": 3,
"rawSha256": "f1b2f662800122bed0ff255693df89c4487fbdcf453d3524a42d4ec20c3d9c04",
"gzipSha256": "baf0683e1103b94b68d94e8a12d7e144b4e0571e9948de7fb0d85103b045460e"
},
{
"file": "checklist-baseline-corrected.txt.gz",
"rawBytes": 11916,
"rawSha256": "0b0ecfa6ea70e76a87991e40c3390513d0040388af1ed880956bf322fcce52a7",
"gzipSha256": "ee4585a14dc3db7ec102a612d5206fda90814d02a47ade651912142a64586347"
},
{
"file": "checklist-baseline-corrected.trx.gz",
"rawBytes": 15307,
"rawSha256": "00948a9f9bbf5ecc0f013e1ef99613248fc57949532d529eab6cd6760fb1b586",
"gzipSha256": "9a8a4f35f256ad58ec336bc33e036f259e005adf0c9b14797fc2ae0acffb2184"
},
{
"file": "checklist-baseline-corrected.exit.txt.gz",
"rawBytes": 3,
"rawSha256": "f1b2f662800122bed0ff255693df89c4487fbdcf453d3524a42d4ec20c3d9c04",
"gzipSha256": "baf0683e1103b94b68d94e8a12d7e144b4e0571e9948de7fb0d85103b045460e"
},
{
"file": "candidate.txt.gz",
"rawBytes": 2868,
"rawSha256": "9fb27fcbb311262987c7358323cc95049a4243d4eb6063c06742218f2cbba51f",
"gzipSha256": "af3b11c6ac1d10339a9ee88e124509a34f3cfa2b455867be4753525d4dd74f56"
},
{
"file": "candidate.trx.gz",
"rawBytes": 19793,
"rawSha256": "765b4c7d01de8d1b2110e7e598d6d3fdb849333bb5135a9a92038110b7639043",
"gzipSha256": "2ffd80b6496310b4ea3260a852008590d92c756ced5d63c4c2d6ef6215464fe5"
},
{
"file": "candidate.exit.txt.gz",
"rawBytes": 3,
"rawSha256": "13bf7b3039c63bf5a50491fa3cfd8eb4e699d1ba1436315aef9cbe5711530354",
"gzipSha256": "7f636460b48b02e48ffda30b26e6cf24cebee6b983bfd77e79a2f7205a71497f"
},
{
"file": "full.txt.gz",
"rawBytes": 1204,
"rawSha256": "cdd7e671c5f3f1d448537268abc8ba21179cf8a0ff285ee876a4da8938266665",
"gzipSha256": "5cb8bc51c0dc2114843da48065dc0655a6822465fd127505f8af3910dd94fc86"
},
{
"file": "full.trx.gz",
"rawBytes": 167700,
"rawSha256": "f132ccbdf646187418f5e98fd2f501ba88ade812e5f12feba485026c0203873d",
"gzipSha256": "1fb3eed294d94ce4d4a173bd7b241ea375134742e655e026fa089dfcffcc6f09"
},
{
"file": "full.exit.txt.gz",
"rawBytes": 3,
"rawSha256": "13bf7b3039c63bf5a50491fa3cfd8eb4e699d1ba1436315aef9cbe5711530354",
"gzipSha256": "7f636460b48b02e48ffda30b26e6cf24cebee6b983bfd77e79a2f7205a71497f"
},
{
"file": "server.txt.gz",
"rawBytes": 6252,
"rawSha256": "49263816a13229f4fad67c3408abd580651a1036bc5fd8baed18a9ed806de695",
"gzipSha256": "b4f5d10e4b0bfb7fbdf2f33b02abb02a8ea6ac2e4e8c7e94bcd68a7659703aca"
},
{
"file": "remaining-schemas.txt.gz",
"rawBytes": 2,
"rawSha256": "9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa",
"gzipSha256": "8afc61325213625995e1de8b0d2df70f01b1d5304993484a41cc9df249f00fad"
},
{
"file": "cleanup.txt.gz",
"rawBytes": 408,
"rawSha256": "6f14edd5ae32f306d6d9fe6e0462430dcc52a7f097a718dc2e233b6d2316a0c7",
"gzipSha256": "6c384ac059786a9bdeb8f4310aac50f6c1053e40ed981c4f56adb41028fe73ec"
},
{
"file": "cleanup.exit.txt.gz",
"rawBytes": 3,
"rawSha256": "13bf7b3039c63bf5a50491fa3cfd8eb4e699d1ba1436315aef9cbe5711530354",
"gzipSha256": "7f636460b48b02e48ffda30b26e6cf24cebee6b983bfd77e79a2f7205a71497f"
},
{
"file": "cleanup.py.gz",
"rawBytes": 2509,
"rawSha256": "942ef2644c4d8078f5db05ee2e4227a75e8922433b77dd0f1a791e34cf6b537b",
"gzipSha256": "22ca184e044bf336caebbc3fe0a28d703dcaf0f02080b3693bf9af160ec85f1e"
},
{
"file": "serial.runsettings.gz",
"rawBytes": 147,
"rawSha256": "5a1dc26f49fa2a9874e30aa868ca5de5973449bd5325d23ae1e3e84fcd560fc5",
"gzipSha256": "cf64d8cbc38b1cf9677671e4e1ea6e9d944e3cea6965235b1df73f37536e8006"
},
{
"file": "resources.compose.yml.gz",
"rawBytes": 58,
"rawSha256": "102bff56fc8f487656fecb2aa308f4b79972dbca2c259d7ee931546a206d3b03",
"gzipSha256": "e10009fa468b5f677d955e1151b125efbf746380428ab4aecd9aba14d841d781"
},
{
"file": "NuGet.Config.gz",
"rawBytes": 74,
"rawSha256": "9508cae5f76364f56e80eb97cb16493977243cf38e5cca6284e3d74f83b20a2c",
"gzipSha256": "05db889e8047b1623c559f092197f603f433f4d73b1774ff936736ba488fe087"
},
{
"file": "unit-baseline.stdout.txt.gz",
"rawBytes": 4856,
"rawSha256": "0bbb5b8c9b03be13f83127bc850d86efe3a1d32864611b37d22e79767ec56eec",
"gzipSha256": "f6999c1104c316f34f69fb96a2f8122e453ff154d89a4015e6e9a4240f041206"
},
{
"file": "unit-baseline.stderr.txt.gz",
"rawBytes": 193,
"rawSha256": "142203fabbdb3da84197036c836b727f68b527336a2f5b5dd7ac6d4baeab9e21",
"gzipSha256": "2aa698372ab8697ad475e4a6824a8b226cc486cd31a6f3fd5959f45547a64b8e"
},
{
"file": "unit-baseline.exit.json.gz",
"rawBytes": 478,
"rawSha256": "908fe0dc4832b47d8f80f791afae55e892ae64e6ee1c8da70ebfe95ee46b6955",
"gzipSha256": "eccb1d15d394dcbc636c0930476d2e5a217309bde7a0deb082066df56fb1c458"
},
{
"file": "unit-final.stdout.txt.gz",
"rawBytes": 1634,
"rawSha256": "d74c1aa6cb7d281ecae4aa24fb2eb4fbcf9bfb7f7529552cdf29755a4f871580",
"gzipSha256": "e5c6468347a57a83c4ecdb6a85687f294214ddf226b34b14e7aea9aa9ef460c0"
},
{
"file": "unit-final.exit.json.gz",
"rawBytes": 473,
"rawSha256": "d0e384c114af6e1454f9ce7bd596509c635774e9a32d6dbb07c0ee9387650da8",
"gzipSha256": "f71572b28404d28cf64457bdc55adbf0cb76b5d854683ffb119418a3b1e6d593"
},
{
"file": "unit-qualified-related.stdout.txt.gz",
"rawBytes": 1658,
"rawSha256": "76025529ace3e58eea933eada5957a694af8aa1ef487b3e26dbbb91b2fc21d08",
"gzipSha256": "613acb0ab3cd2d02a9fa93a646374c8b24fc1fcc456765101bd0b79229e0c074"
},
{
"file": "unit-qualified-related.exit.json.gz",
"rawBytes": 497,
"rawSha256": "f9fb6160fd85e2bb0c4151931742847a235df35361865f6bc3b62fe148f78fc7",
"gzipSha256": "5ec423cd4f69b05058ed1c9f9122dfd87d13f1a8c43305e4c96e4746fc0b9220"
},
{
"file": "unit-checklist-all.stdout.txt.gz",
"rawBytes": 3368,
"rawSha256": "527f0a8189d6c04d32b8afad1f182034397e101d9729259a36af87376c7ebecb",
"gzipSha256": "579fab8fa01132747591fcdc15007e29484f755785b9a54641fb25cd8a633b95"
},
{
"file": "unit-checklist-all.exit.json.gz",
"rawBytes": 472,
"rawSha256": "80f0fea9a71d254f6fbf3582f4029447e2399710a93cdc70692f22ce528d713c",
"gzipSha256": "23b9b1bca5c2aa2e9ac1ce26abb33f3844883a9d6b2c7c69106f27e4aa459a72"
},
{
"file": "unit-checklist-all.trx.gz",
"rawBytes": 27089,
"rawSha256": "6ff38bc16958b118cdea606df44f1c69114b79d7f4ff4069c9ef9cfa8b80c99b",
"gzipSha256": "f9e28cc034f78897835ae493485adbcd8d7f95feeb83d4bd5f13eeb9a71dee83"
}
],
"sources": {
"JobTrackerApi/Services/AnalyticsService.cs": "0859ad9202bbaf4de810f8b1bc9946cbed061f69105c02993f079715f59aa2b1",
"JobTrackerApi/Services/ApplicationChecklistService.cs": "0c807ab96cbb4a638d3f5ba62b2608cdfb599751df2de4e3d58b6d599b69b5e8",
"JobTrackerApi.MariaDb.Tests/AnalyticsStatsPersistenceTests.cs": "7b95ba1a69456aaf61aa6fd7825e7f0374756d6997066275b8e48f77910b9e68",
"JobTrackerApi.MariaDb.Tests/ApplicationChecklistPersistenceTests.cs": "4e455291fdc786ed368891cd20c0aec3fac20fe32b84201fbebdbd784ab19bf0",
"JobTrackerApi.MariaDb.Tests/MariaDbDatabase.cs": "1375d97093f686f77d511ef6d81ad2d62ecf329aa6e7bf53036cd6e199035e40",
"JobTrackerApi.MariaDb.Tests/JobTrackerApi.MariaDb.Tests.csproj": "2df22a5b79fae14566b437081932218254eb811c8dc1b2af3d51692d8e0d6825",
"JobTrackerApi.MariaDb.Tests/packages.lock.json": "0389a52bfdf31aac07feac5c2ad2ce6771d9b450c899caf9c53ef7ecace0db49",
"JobTrackerApi/JobTrackerApi.csproj": "50164c5dceafc805cc73018bfcd444428736029f6fdad220e4ff07cf38e116c4",
"JobTrackerApi/packages.lock.json": "f63bbf68503fd46effda290a29551ebacac84d0faf8c367fe28caa11ec404abf",
"JobTrackerApi.Tests/ApplicationChecklistConcurrencyTests.cs": "b8c520e15d7886b501d39367acaa4e08529b0605a8f470242eec09c8ae23f84c",
"JobTrackerApi.Tests/JobTrackerApi.Tests.csproj": "6564ff0044af2ce8c55d557b180c57e16e238395424778878b56eb9e3e082c0d",
"JobTrackerApi.Tests/packages.lock.json": "548f67d1ef3b5a9acfe5fc6124891583b6073ac4b6ca515241330e097152bc4a"
},
"trx": {
"baseline.trx": {
"total": "5",
"executed": "5",
"passed": "2",
"failed": "3",
"error": "0",
"timeout": "0",
"aborted": "0",
"inconclusive": "0",
"passedButRunAborted": "0",
"notRunnable": "0",
"notExecuted": "0",
"disconnected": "0",
"warning": "0",
"completed": "0",
"inProgress": "0",
"pending": "0"
},
"checklist-baseline.trx": {
"total": "3",
"executed": "3",
"passed": "1",
"failed": "2",
"error": "0",
"timeout": "0",
"aborted": "0",
"inconclusive": "0",
"passedButRunAborted": "0",
"notRunnable": "0",
"notExecuted": "0",
"disconnected": "0",
"warning": "0",
"completed": "0",
"inProgress": "0",
"pending": "0"
},
"checklist-baseline-corrected.trx": {
"total": "3",
"executed": "3",
"passed": "1",
"failed": "2",
"error": "0",
"timeout": "0",
"aborted": "0",
"inconclusive": "0",
"passedButRunAborted": "0",
"notRunnable": "0",
"notExecuted": "0",
"disconnected": "0",
"warning": "0",
"completed": "0",
"inProgress": "0",
"pending": "0"
},
"candidate.trx": {
"total": "8",
"executed": "8",
"passed": "8",
"failed": "0",
"error": "0",
"timeout": "0",
"aborted": "0",
"inconclusive": "0",
"passedButRunAborted": "0",
"notRunnable": "0",
"notExecuted": "0",
"disconnected": "0",
"warning": "0",
"completed": "0",
"inProgress": "0",
"pending": "0"
},
"full.trx": {
"total": "98",
"executed": "98",
"passed": "98",
"failed": "0",
"error": "0",
"timeout": "0",
"aborted": "0",
"inconclusive": "0",
"passedButRunAborted": "0",
"notRunnable": "0",
"notExecuted": "0",
"disconnected": "0",
"warning": "0",
"completed": "0",
"inProgress": "0",
"pending": "0"
},
"unit-checklist-all.trx": {
"total": "17",
"executed": "17",
"passed": "17",
"failed": "0",
"error": "0",
"timeout": "0",
"aborted": "0",
"inconclusive": "0",
"passedButRunAborted": "0",
"notRunnable": "0",
"notExecuted": "0",
"disconnected": "0",
"warning": "0",
"completed": "0",
"inProgress": "0",
"pending": "0"
}
},
"isolation": {
"name": "jobtracker-it-fc0e8c29a256416d8b911f07f80fef8d-mariadb-test-1",
"id": "e4e7603940fdd67f7e24787867036f8436b1fc7320c1c36f6e1d5fdf67a0aac6",
"project": "jobtracker-it-fc0e8c29a256416d8b911f07f80fef8d",
"service": "mariadb-test",
"image": "mariadb:12.2.2@sha256:42a27baaba3e8f3f0159d16381d5a7156661aa91dcc65f663cabb6a6f9503c00",
"tmpfsDatabase": true,
"persistentMounts": [],
"memoryBytes": 805306368,
"cpuNano": 1000000000,
"port": 56408
}
}