diff --git a/Version.props b/Version.props
index 7aeb0c359e..cd340d7a72 100644
--- a/Version.props
+++ b/Version.props
@@ -1,6 +1,6 @@
- 1.0.50
+ 1.0.51
diff --git a/libs/server/Storage/Session/Common/ArrayKeyIterationFunctions.cs b/libs/server/Storage/Session/Common/ArrayKeyIterationFunctions.cs
index 25aedc1ec4..5d84fc34cc 100644
--- a/libs/server/Storage/Session/Common/ArrayKeyIterationFunctions.cs
+++ b/libs/server/Storage/Session/Common/ArrayKeyIterationFunctions.cs
@@ -312,11 +312,9 @@ internal sealed class MainStoreGetDBSize : IScanIteratorFunctions 0 && ObjectSessionFunctions.CheckExpiry(value))
- cursorRecordResult = CursorRecordResult.Skip;
- else
+ cursorRecordResult = CursorRecordResult.Skip;
+ if (value.Expiration == 0 || !ObjectSessionFunctions.CheckExpiry(value))
{
- cursorRecordResult = CursorRecordResult.Accept;
++info.count;
}
return true;
diff --git a/libs/storage/Tsavorite/cs/src/core/Allocator/SpanByteScanIterator.cs b/libs/storage/Tsavorite/cs/src/core/Allocator/SpanByteScanIterator.cs
index 3f3cb086ba..3d75a0351a 100644
--- a/libs/storage/Tsavorite/cs/src/core/Allocator/SpanByteScanIterator.cs
+++ b/libs/storage/Tsavorite/cs/src/core/Allocator/SpanByteScanIterator.cs
@@ -182,18 +182,28 @@ public unsafe bool GetNext(out RecordInfo recordInfo)
// We will return control to the caller, which means releasing epoch protection, and we don't want the caller to lock.
// Copy the entire record into bufferPool memory, so we do not have a ref to log data outside epoch protection.
// Lock to ensure no value tearing while copying to temp storage.
- memory?.Return();
- memory = null;
if (currentAddress >= headAddress || forceInMemory)
{
OperationStackContext> stackCtx = default;
try
{
+ if (memory == null)
+ {
+ memory = hlog.bufferPool.Get(recordSize);
+ }
+ else
+ {
+ if (memory.AlignedTotalCapacity < recordSize)
+ {
+ memory.Return();
+ memory = hlog.bufferPool.Get(recordSize);
+ }
+ }
+
// GetKey() should work but for safety and consistency with other allocators use physicalAddress.
if (currentAddress >= headAddress && store is not null)
store.LockForScan(ref stackCtx, ref hlog._wrapper.GetKey(physicalAddress));
- memory = hlog.bufferPool.Get(recordSize);
unsafe
{
Buffer.MemoryCopy((byte*)currentPhysicalAddress, memory.aligned_pointer, recordSize, recordSize);
diff --git a/libs/storage/Tsavorite/cs/src/core/Utilities/BufferPool.cs b/libs/storage/Tsavorite/cs/src/core/Utilities/BufferPool.cs
index f27f1a1903..8461949ea3 100644
--- a/libs/storage/Tsavorite/cs/src/core/Utilities/BufferPool.cs
+++ b/libs/storage/Tsavorite/cs/src/core/Utilities/BufferPool.cs
@@ -136,6 +136,11 @@ public void Return()
pool?.Return(this);
}
+ ///
+ /// Get the total aligned memory capacity of the buffer
+ ///
+ public int AlignedTotalCapacity => buffer.Length - offset;
+
///
/// Get valid pointer
///