Repository navigation
BulkLoad write path + storage durability hardening (#382) - #383
Merged
Merged
Conversation
- BulkLoad write path (P1-P5): opt-in throughput API skipping per-row WAL via BulkBegin/BulkEnd manifest pair; new BulkLoadSession + recovery. - Engine ALC lifecycle fix: ArchetypeRegistry refcounts per-engine, releases Type refs on dispose so collectible session ALCs can GC-unload. - Workbench Data Browser (read-only) + non-generic entity access surface on the engine. - File Map per-kind rendering: dbmap colour scheme, L0 ordering, hit-test, metrics, scale tests. - CP-04 / #301 hardening: ChunkBasedSegment AllocateChunk/FreeChunk use ChangeSet-tracked IncrementDirty + new CP-04-safe accessor overload. - ChunkBasedSegment.Grow capped-doubling at 1024 pages: avoids catastrophic single-allocation requests at scale. - BitmapL3.SetL1 CAS fix: replaced non-undoable Interlocked.Or with CompareExchange; eliminates orphan-bit leak on partial-collision. - LogicalSegment.Grow patches OLD tail's NextRawDataPBID: chain is now an actively-maintained invariant, not vestigial dead code. - EnsureDirtyAtLeast(2) on every CreateOrGrow write path: closes the lost-write window when callers pass null ChangeSet. - Chain<->Directory cross-check at LogicalSegment.Load: throws with precise diff on mismatch; loud detector for lost-writes. - CheckpointManager shutdown fixes: unconditional final cycle (no LSN gate) + removed _shutdown early-exit that skipped fsync. - DatabaseEngine.RunStorageIntegrityCheck + StorageIntegrityReport: audit API for popcount canary, chain/dir check, chunk-segment capacity invariant. - PagedMMF short-disk-read defensive Debug.Assert against stale bytes in cache slot from partial reads. - Workbench fixture: directory-per-database layout + Dev Fixture useBulkLoad toggle + stale dockview-API cleanup on session close. - Tests: BulkLoadReopenIntegration, UnknownPagesDiagnostic, BulkLoadRecovery, BulkLoadWrite, BulkManifest, BitmapL3FreeRange, ArchetypeRegistryLifecycle. - Comment width pass: all added prose comments rewrap at ~150 cols per .editorconfig. Known residual: #381 (page-cache durability flake at scale) now deterministically caught by the chain/directory integrity check. Closes #382.
…durability-hardening # Conflicts: # tools/Typhon.Workbench/ClientApp/src/libs/dbmap/dbMapRenderer.ts # tools/Typhon.Workbench/ClientApp/src/panels/SystemDag/SystemDagCanvas.tsx # tools/Typhon.Workbench/ClientApp/src/panels/SystemsQueriesNavigator/SystemsQueriesNavigatorPanel.tsx # tools/Typhon.Workbench/ClientApp/src/panels/SystemsQueriesNavigator/__tests__/SystemsQueriesNavigator.test.tsx # tools/Typhon.Workbench/ClientApp/src/shell/DockHost.tsx # tools/Typhon.Workbench/ClientApp/src/shell/MenuBar.tsx # tools/Typhon.Workbench/ClientApp/src/shell/Shell.tsx # tools/Typhon.Workbench/ClientApp/src/shell/WelcomeScreen.tsx # tools/Typhon.Workbench/ClientApp/src/shell/__tests__/conformance.test.tsx # tools/Typhon.Workbench/ClientApp/src/shell/__tests__/viewRegistry.test.ts # tools/Typhon.Workbench/ClientApp/src/shell/commands/baseCommands.ts # tools/Typhon.Workbench/ClientApp/src/shell/commands/openDbMap.ts # tools/Typhon.Workbench/ClientApp/src/shell/dialogs/ConnectDialog.tsx # tools/Typhon.Workbench/ClientApp/src/shell/dialogs/tabs/DevFixtureTab.tsx # tools/Typhon.Workbench/ClientApp/src/shell/viewRegistry.ts
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #382.
Umbrella PR for the work on
feature/bulkload-and-durability-hardening. Squash-merge expected.What's in this PR
BulkLoad write path (P1-P5)
Opt-in throughput-first write API that skips per-row WAL and brackets a bulk with a
BulkBegin/BulkEndmanifest pair. Trades per-row durability for throughput on a strictly opt-in API.BulkLoadSession— exclusive per-engine, thread-affine; wraps aUnitOfWork+ recyclingTransactions with internalSuppressWalSerialization(BL-01)BulkLoadOptions/BulkLoadProgress,BulkLoadCheckpointTimeoutException/BulkSessionAlreadyActiveException/BulkSessionClosedExceptionBulkManifestHeader+BulkPageRange+WalChunkType.BulkBegin/BulkEndDatabaseEngine.BeginBulkLoad+ bulk-session gateTransaction.DestroyBulkfast path (skipsIsAlive's random EntityMap lookup)BitmapL3.FreeRange+ManagedPagedMMF.FreePages(int firstPage, int count)for the discarded-bulk recovery pathWalRecoveryrecognises the new chunk types; v1 deviation: visibility correctness via the existingUowRegistryvoid path (UR-03 / UR-05), not explicit page-free at Phase 3b — documented inclaude/design/Durability/BulkLoad/03-recovery.mdEngine ALC lifecycle fix
ArchetypeRegistrynow refcounts per-engine, releases everyTypereference on dispose so collectible session ALCs can be GC-reclaimed. Resolves the Workbench session-close leak.Workbench Data Browser + File Map per-kind rendering
EntityAccessor.ECS.cs,EntityRef.cs)dbmap*): per-kind colouring, L0 ordering, region/hit-test rework, metrics, search, scale testsCP-04 / #301 hardening
ChunkBasedSegment.AllocateChunk+FreeChunkuse ChangeSet-trackedIncrementDirty(not bareEnsureDirtyAtLeast(1)) to close the bitmap-revert race on contended metadata pagesAllocateChunk(ChangeSet, ref ChunkAccessor)overload keeps ACW > 0 continuously fromClearChunkthrough caller's first writeChunkBasedSegment.Growcapped-doubling at 1024 pages — avoids catastrophic single-allocation requests at scaleStorage integrity hardening + detector
BitmapL3.SetL1—Interlocked.Or→Interlocked.CompareExchange; bulk-of-64 allocator no longer leaks orphan bits on partial-collisionLogicalSegment.Growpatches OLD tail'sLogicalSegmentNextRawDataPBID— chain is now an actively-maintained invariantEnsureDirtyAtLeast(2)on every CreateOrGrow write path — closes lost-write window when callers passnullChangeSetLoad— throws with precise diff on mismatchCheckpointManagershutdown fixes — unconditional final cycle (no LSN gate) + removed_shutdownearly-exit that skipped fsync + DC-decrementDatabaseEngine.RunStorageIntegrityCheck()+StorageIntegrityReport— popcount canary, in-memory chain/dir check, ChunkBasedSegment capacity invariantDebug.Assert(bytesRead == PageSize)inPagedMMF.RequestPageEpoch— defensive against short async readsWorkbench fixture infrastructure
Directory-per-database layout (no schema-DLL collisions across DBs), Dev Fixture API + UI
useBulkLoadtoggle, stale dockview-API cleanup on session close.Tests
BulkLoadReopenIntegrationTest[Explicit]— 1M / 3M / 8.5M / 17M scales, reopen state assertionUnknownPagesDiagnosticTest[Explicit]— std/bulk × scale {1, 10, 100}, full integrity + raw-disk probingBulkLoadRecoveryTests,BulkLoadWriteTests,BulkManifestTests,BitmapL3FreeRangeTests,ArchetypeRegistryLifecycleTestsComment width pass
All added prose comments rewrap at ~150 cols, never exceed 160 per
.editorconfig.Known residual
#381 — Page-cache durability flake at scale on clean shutdown — non-deterministic. The chain ↔ directory integrity check added on this PR catches it deterministically at Load; smaller scales (1× / 10×) stably clean; x100 fails ~60% with precise diagnostics. Investigation paths A–E documented in #381 — next session.
Acceptance criteria
See #382 — all 15 acceptance items checked; remaining boxes for PR review + squash-merge.
🤖 Generated with Claude Code