Restore coherent durable Subscription snapshots (OPC 10000-4)#4045
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Improves durability/coherence of persisted Subscription snapshots by moving to immutable, generation-based records with a committed manifest, and strengthening restore-time validation to prevent mixed/partial/tampered state from being loaded.
Changes:
- Persist snapshots into per-generation immutable keys and publish a protected manifest used for restore.
- Restore only from the committed generation (or legacy keys when manifest is absent) with added identity/completeness validation.
- Expand test coverage for concurrent snapshot commits, process restart behavior, empty snapshots, tamper/corruption handling, and legacy fallback.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/Opc.Ua.Redundancy.Server.Tests/Subscriptions/SharedKeyValueSubscriptionStoreTests.cs | Adds/updates tests validating generation-commit semantics, restart/legacy fallback, and tamper/corruption behavior. |
| src/Opc.Ua.Redundancy.Server/Subscriptions/SharedKeyValueSubscriptionStore.cs | Implements generation+manifest snapshot persistence and stricter restore-time validation; updates cache replacement behavior. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #4045 +/- ##
==========================================
- Coverage 73.55% 73.50% -0.05%
==========================================
Files 1345 1345
Lines 180036 180213 +177
Branches 31677 31702 +25
==========================================
+ Hits 132427 132470 +43
- Misses 36911 37031 +120
- Partials 10698 10712 +14
🚀 New features to boost your workflow:
|
…ueSubscriptionStore Add deterministic NUnit coverage for the snapshot-generation/manifest rework: duplicate subscription-id rejection, cancellation before the commit semaphore, commit-lock release and cache/manifest integrity on a mid-write store failure, generation retention across sequential commits, tampered/malformed manifests, malformed generation keys (bare prefix, non-numeric suffix, numeric overflow), duplicate records surfaced by a non-idempotent scan, incomplete generations, persisted records with invalid monitored-item identities, and trailing data after a decoded record. Raises measured patch coverage for the changed lines in src/Opc.Ua.Redundancy.Server/Subscriptions/SharedKeyValueSubscriptionStore.cs from 127/154 (82.47%) to 154/154 (100%).
Failure
Durable Subscription restore depended on a process-local cache, while full snapshots were written record-by-record under shared mutable keys. A restart or concurrent writer could therefore expose stale, mixed, or partially committed Subscription state.
Fix
Standard
OPC 10000-4 §6.6.2.4.4 and §6.6.2.4.5.5 require durable Subscription and retransmission state to remain coherent across redundant Server failover and restart.
Tests
dotnet test tests\Opc.Ua.Redundancy.Server.Tests\Opc.Ua.Redundancy.Server.Tests.csproj -f net10.0 --no-restore --nologo --verbosity minimal— 542 passedCustomTestTarget=net48 dotnet test tests\Opc.Ua.Redundancy.Server.Tests\Opc.Ua.Redundancy.Server.Tests.csproj --no-restore --nologo --verbosity minimal -m:1— 542 passedReview follow-up:
SharedKeyValueSubscriptionStoreTests— 39 passed on net10.0 and 39 passed on net48.Split
Split from #4021.