Prototype crash-resilient TRX writes#10106
Closed
nohwnd wants to merge 6 commits into
Closed
Conversation
Add isolated padded in-place and journal plus snapshot writers without wiring the production lifecycle. Run deterministic operation and byte-cut interruption matrices, concurrent readers, compatibility probes, and 10k diagnostics. The evidence disproves arbitrary-termination validity for padded mutation and supports append-only journal recovery plus atomic sibling snapshots. Fix torn journal tails before resumed appends and keep prototype summary children in schema order. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> 🤖
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> 🤖
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> 🤖
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> 🤖
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> 🤖
Contributor
There was a problem hiding this comment.
Pull request overview
Prototypes and evaluates crash-resilient TRX persistence without integrating either approach into production.
Changes:
- Adds padded incremental and journal/snapshot TRX prototypes.
- Adds atomic file publication and fault-injection infrastructure.
- Adds semantic, interruption, compatibility, and performance evidence tests.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/Platform/Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Unshipped.txt |
Tracks new internal APIs. |
src/Platform/Microsoft.Testing.Extensions.TrxReport/Streaming/Prototype/ITrxPrototypeFileOperations.cs |
Defines prototype file abstractions. |
src/Platform/Microsoft.Testing.Extensions.TrxReport/Streaming/Prototype/TrxIncrementalWriterPrototype.cs |
Implements padded incremental writes. |
src/Platform/Microsoft.Testing.Extensions.TrxReport/Streaming/Prototype/TrxJournalSnapshotPrototype.cs |
Implements journal replay and snapshots. |
src/Platform/Microsoft.Testing.Extensions.TrxReport/Streaming/Prototype/TrxPrototypeFileOperations.cs |
Provides real filesystem operations. |
src/Platform/Microsoft.Testing.Extensions.TrxReport/Streaming/Prototype/TrxPrototypeXmlRenderer.cs |
Renders prototype TRX XML. |
src/Platform/Microsoft.Testing.Extensions.TrxReport/Streaming/Prototype/TrxSnapshotPublisherPrototype.cs |
Publishes snapshots by sibling replacement. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/Helpers/TrxDocumentClassifier.cs |
Classifies TRX consistency. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/Helpers/TrxFaultInjectingFileOperations.cs |
Simulates filesystem faults. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/Helpers/TrxPrototypeDiagnostics.cs |
Collects prototype metrics. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/Helpers/TrxPrototypeScenarioFactory.cs |
Builds deterministic scenarios. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxCompatibilityEvidenceTests.cs |
Records compatibility boundaries. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxConcurrentReaderTests.cs |
Exercises concurrent readers. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxCrashConsistencyContractTests.cs |
Captures canonical TRX semantics. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxDocumentClassifierTests.cs |
Tests semantic classification. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxFaultInjectingFileOperationsTests.cs |
Tests fault simulation behavior. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxIncrementalWriterInterruptionTests.cs |
Sweeps padded-writer interruptions. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxIncrementalWriterPrototypeTests.cs |
Tests incremental rendering. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxJournalSnapshotPrototypeTests.cs |
Tests journal recovery and publication. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxPrototypeDiagnosticsTests.cs |
Verifies large-run diagnostics. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxPrototypeFileOperationsTests.cs |
Tests real file operations. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxPrototypeRealFileSystemTests.cs |
Exercises real replacement behavior. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxPrototypeWarningSuppressions.cs |
Suppresses prototype-test style warnings. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxSnapshotPublisherPrototypeTests.cs |
Tests reflow and atomic publication. |
Comment on lines
+176
to
+179
| if (!_operations.Exists(_journalPath)) | ||
| { | ||
| _journalTailValidated = true; | ||
| return; |
| Replay( | ||
| record => | ||
| { | ||
| byte[] fragment = _renderer.RenderCompletedResult(record.Result, record.ExecutionId, _startTime); |
| $"Received two different test definition names ('{existingDefinitionName}' and '{definitionName}') for test id '{testId}'."); | ||
| } | ||
|
|
||
| byte[] resultBytes = _renderer.RenderCompletedResult(result, executionId, _startTime); |
Comment on lines
+244
to
+247
| bool addDefinition = !_definitionNames.TryGetValue(testId, out string? existingDefinitionName); | ||
| if (!addDefinition | ||
| && result.TrxTestDefinitionName is not null | ||
| && !string.Equals(existingDefinitionName, definitionName, StringComparison.Ordinal)) |
Comment on lines
+333
to
+334
| byte[] summaryAdditions = _renderer.RenderSummaryAdditions(completion); | ||
| EnsureCapacity("summary", summaryAdditions.Length, _summaryBytesRemaining); |
Comment on lines
+584
to
+585
| ValidateOutput(actual, expected, i, errors); | ||
| ValidateRelativeOrder(actual, ["Output", "ResultFiles"], $"Result[{i}] child order", errors); |
| Assert.Contains( | ||
| observation => observation.Dimension == TrxPhase3EvidenceDimension.ByteCutFault | ||
| && observation.WriteRole == role | ||
| && observation.Cut == observation.RequestedBytes, |
| Assert.Contains( | ||
| observation => observation.Scenario == "startup-absent" | ||
| && observation.Dimension == TrxPhase3EvidenceDimension.ByteCutFault | ||
| && observation.Cut == observation.RequestedBytes |
| report.FaultObservations); | ||
| Assert.Contains( | ||
| observation => observation.WriteRole == TrxPhase3WriteRole.ResultTail | ||
| && observation.Cut == observation.RequestedBytes |
| EnsureDeleteShareIsCompatible(source, temporaryPath); | ||
|
|
||
| long preLength = _files.TryGetValue(destinationPath, out VirtualFileEntry? destination) | ||
| ? destination.Bytes.LongLength |
Comment on lines
+491
to
+505
| foreach (TrxFileOperationKind required in new[] | ||
| { | ||
| TrxFileOperationKind.Seek, | ||
| TrxFileOperationKind.Write, | ||
| TrxFileOperationKind.Flush, | ||
| }) | ||
| { | ||
| if (baseline.Any(operation => operation.Kind == required)) | ||
| { | ||
| Assert.AreEqual( | ||
| baseline.Count(operation => operation.Kind == required), | ||
| operationCases.Count(observation => observation.OperationKind == required), | ||
| $"{scenario}: {required}"); | ||
| } | ||
| } |
Comment on lines
+850
to
+852
| _temporaryDirectory = System.IO.Path.Combine( | ||
| System.IO.Path.GetTempPath(), | ||
| $"trx-incremental-prototype-{Guid.NewGuid():N}"); |
| $"trx-incremental-prototype-{Guid.NewGuid():N}"); | ||
| Directory.CreateDirectory(_temporaryDirectory); | ||
| operations = new TrxPrototypeFileOperations(); | ||
| Path = System.IO.Path.Combine(_temporaryDirectory, "results.trx"); |
| { | ||
| string uniqueName = Guid.NewGuid().ToString("N"); | ||
| Path = subdirectoryName is null | ||
| ? System.IO.Path.Combine(System.IO.Path.GetTempPath(), uniqueName) |
| string uniqueName = Guid.NewGuid().ToString("N"); | ||
| Path = subdirectoryName is null | ||
| ? System.IO.Path.Combine(System.IO.Path.GetTempPath(), uniqueName) | ||
| : System.IO.Path.Combine(System.IO.Path.GetTempPath(), subdirectoryName, uniqueName); |
Comment on lines
+472
to
+474
| catch | ||
| { | ||
| } |
Member
Author
|
Closing the investigation after recording the findings and recommendation in #10016. The prototype disproved the padded writer guarantee and supports journal plus atomic snapshots instead. This branch remains available as evidence, but the prototype is intentionally not wired into production and is not intended for merge. 🤖 |
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.
Related #10016
Wanted to implement both options and see what actually survives interrupted writes. Neither implementation is wired into production.
The padded file cannot provide the guarantee from the issue. Across 5,656 injected operation failures and byte cuts:
The append-only journal recovered a complete prefix in all 246 interruption cases, including restart and append after a torn final record. Publishing complete streamed snapshots through sibling-file replacement kept the destination old or new and truthful in all 3,519 observations.
For 10k synthetic results, journal plus snapshots did 10,004 flushes and wrote 18.3 MB. The padded writer did 89,959 flushes and wrote 24.6 MB. Replay keeps one record, no result collection, and no
XDocument.Changes
Verification
net462,net472,net8.0, andnet9.0.This does not claim XSD, Visual Studio, Azure DevOps, third-party reader, network filesystem, antivirus, physical power-loss, or actual attachment-copying compatibility. Atomic overwrite intentionally fails closed on .NET Framework where the same replacement guarantee is not available.
LMK if this should stay as evidence only, or if I should follow with the production journal and snapshot path.
🤖