diff --git a/docs/fork-differences.md b/docs/fork-differences.md index 74b046ad2..c9e07cf97 100644 --- a/docs/fork-differences.md +++ b/docs/fork-differences.md @@ -30,7 +30,7 @@ entry `retired`. Upstream status is as last reviewed; open gaps are tracked as | DD-027 | Cache operators forward completion and errors; `MergeMany` child errors now propagate. | Rx terminal contract (#1143). | Open PR [#1146](https://github.com/reactivemarbles/DynamicData/pull/1146). | | DD-028 | List operators forward completion and errors; selected list operators use shared delivery queues, including `AutoRefresh`/`AutoRefreshOnObservable` and `FilterOnObservable`, whose source and refresh inputs share one queue merged without a gate (DD-016). | Rx terminal contract (#1144) and list deadlocks (fork issue #3). | Open PRs [#1147](https://github.com/reactivemarbles/DynamicData/pull/1147), [#1115](https://github.com/reactivemarbles/DynamicData/pull/1115); the `AutoRefresh`/`FilterOnObservable` queues are fork only. | | DD-029 | Zero-size viewports are valid; specialized `Switch` for virtualized changesets (returns base keyed changesets). | #1037, #1164. | Open PR [#1166](https://github.com/reactivemarbles/DynamicData/pull/1166). | -| DD-030 | Refresh-aware `Sum`, new `SumImmutable`, refresh-aware `Minimum`/`Maximum`; direct `StdDev` overloads project like `Avg` (DD-031) and aggregate `StdDev` retains projections. Projected `Avg`/`StdDev` accumulator failures reach `OnError` in both flavors. | Stale aggregates after inline updates (#896, fork issue #4). | Open PR [#1167](https://github.com/reactivemarbles/DynamicData/pull/1167) (Sum only); StdDev fork only. | +| DD-030 | Refresh-aware `Sum`, new `SumImmutable`, refresh-aware `Minimum`/`Maximum`; direct `StdDev` overloads project like `Avg` (DD-031) and aggregate `StdDev` retains projections. Projected `Avg`/`StdDev` accumulator failures reach `OnError` in both flavors. | Stale aggregates after inline updates (#896, fork issue #4). | [#1167](https://github.com/reactivemarbles/DynamicData/pull/1167) merged on 2026-11-07 (Sum only, without `SumImmutable`); open PR [#1219](https://github.com/reactivemarbles/DynamicData/pull/1219) covers `Avg`, `StdDev`, `Maximum` and `Minimum`. `SumImmutable` is fork only. | | DD-031 | `Avg` fallback and direct mutable projections; inherited skipped tests enabled. | Follow-up to #1168. | Fork only. | | DD-032 | List `ExpireAfter` tracks deadlines per occurrence. | Duplicate rows expired together (#1115, #1025). | Fork only. | | DD-033 | List observable filtering excludes initially false items and tracks occurrences. | #1039, #1044. | Open issues. | diff --git a/docs/upstream/README.md b/docs/upstream/README.md index 7a5b0c20d..3daa4e802 100644 --- a/docs/upstream/README.md +++ b/docs/upstream/README.md @@ -19,6 +19,14 @@ Later upstream activity is summarized each month by the `Upstream review YYYY-MM` issue. Its raw inventory is a workflow artifact and is never committed. +## Monthly reviews + +Outcome of each `Upstream review YYYY-MM` issue. The tables below include its items. + +| Review | Upstream main | Outcome | +| --- | --- | --- | +| [2026-11](https://github.com/Runic-Artifex/DynamicData/issues/46) | [`fd20189`](https://github.com/reactivemarbles/DynamicData/commit/fd20189036554e2b68017846500a13431a0e32ab) | No sync: deps/CI only. The six commits since the baseline `65016e5` are dependency and workflow bumps (#1090, #1108, #1117, #1121, #1172, #1204). The virtual merge conflicts only in the fork's own workflows and `src/Directory.Packages.props`. #1213 ported as a test; #1214/#1219 already covered by DD-030/DD-031, with the incremental extremum deferred. New gaps from #1208 and #1209 are fork issues #47 and #48. #1167 merged upstream on 2026-11-07, after this review; the next review compares it with DD-030. | + ## Adopted | Upstream items | Fork difference | @@ -36,23 +44,27 @@ never committed. | #1142, #1144, #1147, #1115 (selected list queues), #1073 (list `AutoRefresh`/`FilterOnObservable` queues) | DD-028 | | #1037, #1164, #1166, #1115 (list viewport) | DD-029 | | #1167, #896, #1196 | DD-030 | +| #1214, #1219 (refresh-aware `Avg`, `StdDev`, `Maximum`, `Minimum`; upstream's randomized aggregate oracle passes against the fork) | DD-030, DD-031 | | #1115, #1025 (list expiration) | DD-032 | | #1039, #1044 | DD-033 | | #1066 | DD-034 | | #1142, #1147 (list `AutoRefreshOnObservable` child errors) | DD-041 | | #1073 (`ExpireAfter`, `ToObservableChangeSet` and list predicate-state `Filter` gates) | DD-043 | | #1099 | Existing behavior kept; concurrency tests enabled | +| #896, #1196 (fork issue #4) | DD-007, DD-030 | +| #1142, #1205, #1207 (fork issue #5) | DD-039 | +| #1142, #1206 (fork issue #6) | DD-040 | +| #1150 (fork issue #8) | DD-042 | +| #1213 | Test port: deterministic cross-feeding `CacheParentSubscription` test | ## Open gaps -Verified against the code after the October 2026 integration: +Verified against `main` in the 2026-11 review (the October gaps #4, #5, #6 and #8 are closed; see Adopted): | Gap | Upstream | Fork issue | | --- | --- | --- | -| `StdDev` ignores Refresh | #896, #1196 | [#4](https://github.com/Runic-Artifex/DynamicData/issues/4) | -| Lock-free cache `Watch` and `Watcher` drop terminal notifications | #1142 | [#5](https://github.com/Runic-Artifex/DynamicData/issues/5) | -| Cache `EditDiff` over an observable drops late errors | #1142 | [#6](https://github.com/Runic-Artifex/DynamicData/issues/6) | -| `Switch` emits removals and additions as two changesets | #1150 | [#8](https://github.com/Runic-Artifex/DynamicData/issues/8) | +| Parallel `SubscribeMany` rethrows source errors | #1208, #1142 | [#47](https://github.com/Runic-Artifex/DynamicData/issues/47) | +| Sorted, paged and distinct `AsAggregator` rethrow source errors | #1209, #1142 | [#48](https://github.com/Runic-Artifex/DynamicData/issues/48) | ## Deferred @@ -61,6 +73,7 @@ Verified against the code after the October 2026 integration: | #1114 Orchestrator refactor | Terminal/queue behavior is stable and a benefit is measured. | | #1174 TransformVirtual | A workload needs lazy pure projection; virtualize before expensive projections meanwhile. | | #981 inline-update scheduler | Removal/disposal ordering and scheduler ownership are defined; use explicit stages meanwhile. | +| #1219 incremental `Maximum`/`Minimum` (rebuild only when the extreme leaves) | A workload shows the O(n) recompute per Refresh, Update or Remove batch matters. | | #954 MaximumBy/MinimumBy | Empty, tie and comparer behavior is needed and defined. | | #899 forced TransformMany | A measured need exists; prefer child changesets. | | #887 R3, #853 bidirectional BindingList, #836 LINQ aliases | Runic adopts the ecosystem or needs the adapter. | @@ -75,3 +88,8 @@ Verified against the code after the October 2026 integration: composable `Sort`, independent dependency policy). - #1103, #1104, #1105, #1107, #1108, #1109, #1117: dependency updates for packages the fork does not use or already pins (TUnit, .NET 10 only). +- #1199, #1200, #1202, #1203, #1204, #1215, #1216, #1217, #1218, #1220, #1221, #1222, #1223: + upstream polyfill, Central Package Management, dependency and action updates; the fork + has its own package management and SHA-pinned workflows (DD-025). +- #1210, #1211 (upstream 9.5.0 release) and #1212 (Lock Threads workflow permission): + upstream release and repository automation. diff --git a/src/DynamicData.Tests/Internal/CacheParentSubscriptionFixture.cs b/src/DynamicData.Tests/Internal/CacheParentSubscriptionFixture.cs index fe06bf321..9fccbe44f 100644 --- a/src/DynamicData.Tests/Internal/CacheParentSubscriptionFixture.cs +++ b/src/DynamicData.Tests/Internal/CacheParentSubscriptionFixture.cs @@ -215,66 +215,73 @@ public async Task Serialization_ParentAndChildDoNotInterleave() } /// - /// Proves CPS delivery runs without holding the lock. Two TestSubscription instances - /// whose EmitChanges callbacks write into each other's source cache — creating a - /// cross-cache cycle. Deadlocks on unfixed code, passes after the fix. + /// Two subscriptions whose emissions feed each other, both through the other's child observable and through + /// the other's source cache. Each writer thread is parked inside its own subscription's delivery until the + /// other is too, and only then feeds the other, so the cycle is exercised on every run. If either the + /// subscription or the cache held its lock while delivering, each writer would block on the lock the other + /// holds. Ported from upstream #1213. /// [Test] - public async Task DeadlockProof_CrossFeedingSubscriptions() + [Timeout(10_000)] + public async Task CrossFeedingSubscriptions_FeedEachOtherDuringDelivery_DoNotDeadlock(CancellationToken cancellationToken) { - var iterations = _rand.Number(50, 150); + // Arrange + var keys = _rand.Shuffle(Enumerable.Range(1, 1_000)).Take(4).ToArray(); + var (seedA, seedB) = (new TestItem(keys[0], _rand.String2(8)), new TestItem(keys[1], _rand.String2(8))); + var (crossFromA, crossFromB) = (new TestItem(keys[2], _rand.String2(8)), new TestItem(keys[3], _rand.String2(8))); + var (childValueFromA, childValueFromB) = (_rand.String2(8), _rand.String2(8)); using var sourceA = new SourceCache(x => x.Key); using var sourceB = new SourceCache(x => x.Key); + using var childOfA = new ReactiveUI.Primitives.Signals.Signal(); + using var childOfB = new ReactiveUI.Primitives.Signals.Signal(); + using var rendezvous = new Barrier(2); - // Each TestSubscription's EmitChanges writes into the OTHER source (limited to prevent infinite loops) - var observerA = new CrossFeedObserver(sourceB, 100_001, iterations); - using var subA = new TestSubscription(observerA); + // The child is fed before the cache, so it only reaches the subscription made for the seed. + var observerA = new CrossFeedObserver(rendezvous, () => { childOfB.OnNext(childValueFromA); sourceB.AddOrUpdate(crossFromA); }); + using var subA = new TestSubscription(observerA, _ => childOfA); subA.ExposeCreateParent(sourceA.Connect()); - var observerB = new CrossFeedObserver(sourceA, 200_001, iterations); - using var subB = new TestSubscription(observerB); + var observerB = new CrossFeedObserver(rendezvous, () => { childOfA.OnNext(childValueFromB); sourceA.AddOrUpdate(crossFromB); }); + using var subB = new TestSubscription(observerB, _ => childOfB); subB.ExposeCreateParent(sourceB.Connect()); - using var barrier = new Barrier(2); + // Act: the writers get threads of their own, so they never wait on a starved thread pool. + var writerA = Task.Factory.StartNew(() => sourceA.AddOrUpdate(seedA), cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); + var writerB = Task.Factory.StartNew(() => sourceB.AddOrUpdate(seedB), cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); + await Task.WhenAll(writerA, writerB); - var taskA = Task.Run(() => - { - var tRand = new Randomizer(56); - barrier.SignalAndWait(); - for (var i = 0; i < iterations; i++) - sourceA.AddOrUpdate(new TestItem(tRand.Number(1, 50_000), tRand.String2(5))); - }); - - var taskB = Task.Run(() => - { - var tRand = new Randomizer(57); - barrier.SignalAndWait(); - for (var i = 0; i < iterations; i++) - sourceB.AddOrUpdate(new TestItem(tRand.Number(50_001, 100_000), tRand.String2(5))); - }); - - var completed = Task.WhenAll(taskA, taskB); - var finished = await Task.WhenAny(completed, Task.Delay(TimeSpan.FromSeconds(30))); - await Assert.That(finished).IsSameReferenceAs(completed); + // Assert + await Assert.That(sourceA.Items).IsEquivalentTo(new[] { seedA, crossFromB }); + await Assert.That(sourceB.Items).IsEquivalentTo(new[] { seedB, crossFromA }); + await Assert.That(observerA.Received).IsEquivalentTo(new[] { seedA, seedA with { Value = childValueFromB }, crossFromB }); + await Assert.That(observerB.Received).IsEquivalentTo(new[] { seedB, seedB with { Value = childValueFromA }, crossFromA }); } // ═══════════════════════════════════════════════════════════════ // Test Infrastructure // ═══════════════════════════════════════════════════════════════ - /// Observer that writes into another cache on every emission — creates cross-cache cycle. - private sealed class CrossFeedObserver(SourceCache target, int idBase, int maxCrossWrites) : IObserver> + /// + /// Records every item it receives. On its first emission it waits at for the + /// other writer, then runs . + /// + private sealed class CrossFeedObserver(Barrier rendezvous, Action crossFeed) : IObserver> { - private int _counter; + private bool _hasCrossFed; + + public List Received { get; } = []; public void OnNext(IChangeSet value) { - // Limit cross-writes to prevent infinite feedback loops - if (Interlocked.Increment(ref _counter) <= maxCrossWrites) - { - target.AddOrUpdate(new TestItem(idBase + _counter, "cross")); - } + Received.AddRange(value.Select(change => change.Current)); + + if (_hasCrossFed) + return; + + _hasCrossFed = true; + rendezvous.SignalAndWait(); + crossFeed(); } public void OnError(Exception error) { }