From e5e5a6fd04b09eb10c198f77e8510607a9e3151c Mon Sep 17 00:00:00 2001 From: Raymond Welch Date: Fri, 26 Aug 2022 08:33:13 -0400 Subject: [PATCH] Update MemoryCache.cs When readable page is updated from a writable page buffer, the ShareCounter was set to 1 before it is copied, but when writable page is discarded the Ensure will throw an exception because the ShareCounter isn't set to BUFFER_WRITABLE. --- LiteDB/Engine/Disk/MemoryCache.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LiteDB/Engine/Disk/MemoryCache.cs b/LiteDB/Engine/Disk/MemoryCache.cs index 112bf58a6..f82947dba 100644 --- a/LiteDB/Engine/Disk/MemoryCache.cs +++ b/LiteDB/Engine/Disk/MemoryCache.cs @@ -222,6 +222,10 @@ public PageBuffer MoveToReadable(PageBuffer page) added = false; + // Bug 2184: readable page was updated, need to set the page.ShareCounter back to writeable + // so that DiscardPage can free the page and put it into the queue. + page.ShareCounter = BUFFER_WRITABLE; + return current; });