From 40581981221a4f071a22dd8b0ab8a60bccb58249 Mon Sep 17 00:00:00 2001 From: Alex Peck Date: Mon, 13 Apr 2026 19:21:59 -0700 Subject: [PATCH 1/2] extra diag --- .../Lfu/ConcurrentLfuSoakTests.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuSoakTests.cs b/BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuSoakTests.cs index 310e84f0..f569b4e5 100644 --- a/BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuSoakTests.cs +++ b/BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuSoakTests.cs @@ -495,9 +495,11 @@ private async Task RunIntegrityCheckAsync(ConcurrentLfu lfu, int { this.output.WriteLine($"iteration {iteration} keys={string.Join(" ", lfu.Keys)}"); - var scheduler = lfu.Scheduler as BackgroundThreadScheduler; - scheduler.Dispose(); - await scheduler.Completion; + if (lfu.Scheduler is BackgroundThreadScheduler scheduler) + { + scheduler.Dispose(); + await scheduler.Completion; + } RunIntegrityCheck(lfu, this.output); } @@ -571,6 +573,13 @@ private void VerifyLruInDictionary(LfuNodeList lfuNodes, ITestOutputHelper node.WasRemoved.Should().BeFalse(); node.WasDeleted.Should().BeFalse(); + // additional diagnbostics + if (!cache.TryGet(node.Key, out _)) + { + output.WriteLine($"Orphaned node at {node.Position} with key {node.Key} and value {node.Value}."); + output.WriteLine($"Read buffer {cache.readBuffer.Count} write buffer {cache.writeBuffer.Count}."); + } + cache.TryGet(node.Key, out _).Should().BeTrue($"Orphaned node with key {node.Key} detected."); node = node.Next; From acc4b2670072bda8d2774077615eb9af3b3c499c Mon Sep 17 00:00:00 2001 From: Alex Peck Date: Mon, 13 Apr 2026 19:42:43 -0700 Subject: [PATCH 2/2] check ex --- BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuSoakTests.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuSoakTests.cs b/BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuSoakTests.cs index f569b4e5..d028a832 100644 --- a/BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuSoakTests.cs +++ b/BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuSoakTests.cs @@ -8,6 +8,7 @@ using BitFaster.Caching.Lfu; using BitFaster.Caching.Scheduler; using FluentAssertions; +using FluentAssertions.Equivalency; using Xunit; using Xunit.Abstractions; @@ -547,6 +548,12 @@ public void Validate(ITestOutputHelper output) { cache.DoMaintenance(); + if (cache.Scheduler.LastException.HasValue) + { + output.WriteLine($"Last scheduler exception {cache.Scheduler.LastException.Value}"); + cache.Scheduler.LastException.Should().BeNull("scheduler should not have thrown"); + } + // buffers should be empty after maintenance this.readBuffer.Count.Should().Be(0); this.writeBuffer.Count.Should().Be(0);