From 5cda2f90b3260d5edc28ff9b91bea41ea433821d Mon Sep 17 00:00:00 2001 From: Badrish Chandramouli Date: Wed, 14 Aug 2019 23:33:35 -0700 Subject: [PATCH] more tests, phew --- cs/src/core/ClientSession/FASTERAsync.cs | 1 + cs/src/core/Epochs/LightEpoch.cs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/cs/src/core/ClientSession/FASTERAsync.cs b/cs/src/core/ClientSession/FASTERAsync.cs index b8206958d..9ab509c92 100644 --- a/cs/src/core/ClientSession/FASTERAsync.cs +++ b/cs/src/core/ClientSession/FASTERAsync.cs @@ -109,6 +109,7 @@ internal async ValueTask CompleteCheckpointAsync(ClientSession clientSession) { epoch.ProtectAndDrain(); + epoch.Check(); // We check if we are in normal mode var newPhaseInfo = SystemState.Copy(ref _systemState); diff --git a/cs/src/core/Epochs/LightEpoch.cs b/cs/src/core/Epochs/LightEpoch.cs index c25304bd8..b28a5e7a9 100644 --- a/cs/src/core/Epochs/LightEpoch.cs +++ b/cs/src/core/Epochs/LightEpoch.cs @@ -321,6 +321,22 @@ private int ComputeNewSafeToReclaimEpoch(int currentEpoch) return SafeToReclaimEpoch; } + public void Check() + { + int count = 0; + for (int index = 1; index <= numEntries; ++index) + { + int entry_epoch = (*(tableAligned + index)).localCurrentEpoch; + if (0 != entry_epoch && entry_epoch < int.MaxValue) + { + count++; + } + } + + if (count > 1) + throw new Exception("Unexpected epoch entries"); + } + /// /// Reserve entry for thread. This method relies on the fact that no /// thread will ever have ID 0.