fix: leave some free space in log buffer during syncLogBufferInit

This commit is contained in:
Benguang Zhao 2022-11-24 16:43:26 +08:00
parent 22d64b9c0b
commit 6729c130f8
1 changed files with 2 additions and 1 deletions

View File

@ -182,7 +182,8 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
}
bool taken = false;
if (toIndex <= index + pBuf->size - 1) {
int emptySize = 5;
if (toIndex - index + 1 <= pBuf->size - emptySize) {
SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = -1, .prevLogTerm = -1};
pBuf->entries[index % pBuf->size] = tmp;
taken = true;