#2174·garnet

AOF recovery hangs when objects put the log heap over the size tracker budget

Author: LauriantiCreated Sep 27, 2026Updated Sep 27, 2026

Describe the bug

With the storage tier and AOF enabled, if hash objects push the log heap over the size tracker budget, --recover never completes after an unclean shutdown. The server never logs "Ready to accept connections", never binds its port, and sits at low CPU.

Steps to reproduce the bug

bash
docker network create garnet-repro
docker run -d --name garnet --network garnet-repro -v garnet-data:/data ghcr.io/microsoft/garnet \
  --storage-tier -m 4m --page 1m -i 1m --logdir /data --checkpointdir /data/ckpt --aof --recover

Load 30,000 hashes of about 2 KB each (load.py, run with python:3-alpine on the same network):

python
import socket

def cmd(*args):
    out = b"*%d\r\n" % len(args)
    for a in args:
        out += b"$%d\r\n%s\r\n" % (len(a), a)
    return out

value = b"x" * 2169
payload = b"".join(cmd(b"HSET", b"k:%d" % i, b"data", value) for i in range(30000))
sock = socket.create_connection(("garnet", 6379))
sock.sendall(payload)
received = b""
while received.count(b"\r\n") < 30000:
    received += sock.recv(65536)

Then:

bash
docker kill garnet
docker start garnet

After the restart the log stops at ScanForwardForCommit stopped at an invalid/torn commit record ... recovering to last valid commit, and "Ready to accept connections" never appears (waited over 2 minutes; over 8 minutes with an earlier, larger load).

The same load with SET instead of HSET recovers in about 2 seconds.

Expected behavior

The AOF replay completes and the server starts with all 30,000 keys.

Release version

v2.1.8 (ghcr.io/microsoft/garnet), also reproduced with the image built from the v2.1.8 tag.

OS version

Linux container on Docker Desktop (WSL2), Windows 11.

Additional context

Stack of the recovery thread (dotnet-stack):

SemaphoreSlim.WaitCore
AllocatorBase.TryAllocateRetryNow
TsavoriteKV.TryBlockAllocate
TsavoriteKV.TryAllocateRecord
TsavoriteKV.CreateNewRecordRMW
TsavoriteKV.InternalRMW
BasicContext.RMW
AofProcessor.ObjectStoreRMW
AofProcessor.ReplayOp
AofProcessor.ProcessAofRecordInternal
AofProcessor.SingleLogRecover
AofProcessor.Recover
StoreWrapper.ReplayAOF

During AOF replay the LogSizeTracker is not running yet. NeedToWaitForClose in AllocatorBase.cs still calls logSizeTracker.Signal() and returns true (RETRY_NOW) when IsBeyondSizeLimitAndCanEvict(addingPage: true) is true. When the heap alone is over budget and the page count is below MaxAllocatedPageCount, IssueShiftAddress does not shift HeadAddress, so the allocation retries forever. #1932 added the !logSizeTracker.IsRunning guard to IssueShiftAddress, but not to NeedToWaitForClose.