test-infra: UserTenant writes from test scopes are intermittently invisible to API request scopes on the shared SQLite connection #202
Labels
No labels
epic
phase-0
phase-1
phase-2
phase-3
phase-4
phase-5
phase-6
phase-7
phase-8
phase-9
priority/P0
priority/P1
priority/P2
type/backend
type/client
type/docs
type/ops
type/security
type/spike
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/failsulit#202
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom (found while building 7.15 slice 1)
In
ClassificationUploadGatingTests, promoting a member to tenant-admin (either viaPATCH /api/tenants/{id}/members/{uid}— which returns 200role:"admin"and even survives a same-connection raw readback inside the request — or via a direct test-scope DB write + SaveChanges) was not visible to a later API request's EF query: the request re-read the row asRole=Member.Facts established:
SqliteConnection(DataSource=:memory:) across all scopes (FailSulitFactory) — one database by constructionSaveChangesAsyncreturns the new value (TEMP-DIAG raw-role-after-save = admin)SeedTenantAdminAsync(direct DB write) — which STILL failed — so the final tests exercise the owner path (fully valid per CLS-07) and the member-403 path; the tenant-admin happy path is covered byCanReclassifyAsync's role check semanticsSuspicion
Some request path leaves the shared connection with an open/aborted SQLite transaction; Microsoft.Data.Sqlite auto-enlists subsequent commands, and the pending transaction is rolled back at scope disposal — silently discarding writes from the requests in between. Would explain: same-connection readback sees the write, later reads don't, flaky ordering dependence, and why short isolated flows pass.
Impact
Any future test that seeds state via a test-scope write and expects an API request to see it can hit this intermittently. Production is NOT implicated (API-request writes persist correctly across requests; staging/postgres paths unaffected).
Suggested next step
A dedicated spike: repro the seeding sequence under
Microsoft.Data.Sqliteconnection/transaction logging (SqliteEventSourceor EFLogTotransaction events) and identify which endpoint leaves the pending transaction. Fix = ensure commit/dispose on all paths (or an interceptor that enforces autocommit on the shared connection).