-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem
The LocalDB optimization (AUTO_UPDATE_STATISTICS_ASYNC ON) has exposed 34+ latent race conditions where database objects with FK dependencies are created without intermediate commits.
Root Cause
With async statistics enabled, INSERT operations may not be immediately visible to subsequent FK constraint checks. When parent-child objects are created in rapid succession:
// RISKY
var parent = new TableInfo(repo, "Table");
var child = new ColumnInfo(repo, "Column", "int", parent); // FK check may failImpact
- Tests: Intermittent failures ("FK constraint violation")
- Production: At least one production code path affected
- CI: Timing-dependent failures hard to debug
Affected FK Relationships
TableInfo → ColumnInfoCatalogue → CatalogueItemCatalogueItem → ExtractionInformationColumnInfo → ExtractionInformation
Locations (34+ instances)
Priority 1 (Highest Impact)
Tests.Common/UnitTests.cs- Helper methods used by all testsRdmp.Core/CommandExecution/ExecuteCommandCreateNewCohortFromTable.cs- PRODUCTION CODEAggregateBuilderTestsBase.cs- Affects many test classes
Priority 2 (Individual Tests)
- 30+ test files with SetUp methods or test code
Solution Pattern
// SAFE
var parent = new TableInfo(repo, "Table");
parent.SaveToDatabase(); // Explicit commit
var child = new ColumnInfo(repo, "Column", "int", parent);Action Plan
- Fix
Tests.Common/UnitTests.cshelper methods - Fix production code in
ExecuteCommandCreateNewCohortFromTable.cs - Fix test base classes (
AggregateBuilderTestsBase.cs, etc.) - Systematic cleanup of remaining test files
- Add coding guideline to prevent recurrence
- Consider static analysis rule
Already Fixed
- ✅
Rdmp.Core.Tests/CohortCommitting/CreateNewCohortDatabaseWizardTests.cs
Related
- Exposed by commit: a1ee79e (LocalDB optimization with async statistics)
- Branch: fix/bundle-build-workflow
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels