Repository navigation
Adopt what Auditing 1.0.0-preview.3 makes possible - #7
Merged
Merged
Conversation
Three optional changes that preview.3 of Auditing and MultiLingual make safe: - Drop the HiLo keys. Category and Product are identity columns again, so a creation's Created entry is written in Auditing's nested save. DatabaseInitialiser.RestoreIdentityKeysAsync replaces the sequence upgrade: it gives a HiLo-era volume's key columns their identity back and moves the counter past the existing rows, forward only. SchemaUpgradeTests now covers both kinds of older volume (created with HiLo keys, or kept its identity through the HiLo builds); both fail with the restore disabled. Stop an older build before the new one first boots: it keeps handing out HiLo ids. - EnableRetryOnFailure() on the Npgsql options. A replayed save is now recorded once. The suite also passes with UseAuditing(sp) registered before UseMultiLingual(sp); the shipped order is unchanged. - OnLostAtomicity through the Auditing:OnLostAtomicity setting (default Report). The test host sets it to Throw, so a non-atomic composition fails a test instead of logging an error. Two tests check the retrying strategy and the Throw setting are in force. README section 6, the test counts and the comments that gave HiLo as the reason for one save per creation are updated. 168 tests pass against the published packages (UseLocalDotNetBoost=false). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Running the sample through Aspire on a real data volume from the HiLo builds found that RestoreIdentityKeysAsync moved the identity counter only past the highest surviving row. A product created and deleted during those builds left no row but kept its audit trail, so its id was handed out again and the new product's trail began with the old one's history. The counter now also goes past the last block each HiLo sequence handed out (its last value plus the increment, less one). SchemaUpgradeTests leaves a deleted block in both kinds of older database; both tests failed before the fix. Two tests in AuditTrailTests, in both modes, for the save path the identity keys bring in: - A trigger fails a creation's translation write: no product, text or Created entry is left. Against Auditing preview.2 with Auditing registered first and no retrying strategy it fails, in both modes. - A trigger raises one transient serialization failure: EF's retrying strategy replays the save, the trigger is seen to run twice, and the product and its Created entry exist once. With the strategy off it fails. Also checked by hand through Aspire against the published packages: the API life cycle and the dashboard on the real volume, and a database created from scratch by the HiLo build on main, upgraded by this build. 172 tests pass against the published packages (UseLocalDotNetBoost=false). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Auditing 1.0.0-preview.3 (with MultiLingual 1.0.0-preview.3) makes three things safe that this sample used to avoid. This PR adopts all three, and fixes an upgrade bug that running the sample through Aspire on a real data volume turned up.
What changes
HiLo keys dropped.
CategoryandProductare identity columns again. A creation'sCreatedentry is now written in Auditing's nested save, after the INSERT generates the id, in the same transaction.DatabaseInitialiser.RestoreIdentityKeysAsyncupgrades a volume from the HiLo builds. It adds the identity where a key column has none, then moves the counter past the highest row and past the last block each HiLo sequence handed out.CategoryIds/ProductIdssequences are left in place and unused. Stop an older build before the new one first boots.EnableRetryOnFailure()on the Npgsql options. A save MultiLingual replays under the retrying strategy is now recorded once. The interceptor registration order is unchanged; the suite also passes withUseAuditing(sp)registered first.OnLostAtomicityis read from theAuditing:OnLostAtomicitysetting (defaultReport). The test host sets it toThrow.Tests
172 tests pass against the published packages (
-p:UseLocalDotNetBoost=false), up from 163.SchemaUpgradeTestscovers both kinds of HiLo-era database (key created without identity, or identity kept), each with a deleted HiLo block. Both tests fail without the restore, and failed before the HiLo-block fix.AuditTrailTests, in both modes:Throw.Checked by hand
Through
aspire run, built against the published packages:main(HiLo), then booted with this branch: the identity was added, new ids started after the HiLo block, and a product deleted under HiLo kept its own trail.Not covered
aspire run(covered by the test suite's fresh databases).🤖 Generated with Claude Code