enh: reserve half a buffer size at syncLogBufferInit

This commit is contained in:
Benguang Zhao 2023-10-07 14:05:00 +08:00
parent c26d74355c
commit be3ba000a1
1 changed files with 1 additions and 1 deletions

View File

@ -197,6 +197,7 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
SyncIndex index = toIndex;
SSyncRaftEntry* pEntry = NULL;
bool takeDummy = false;
int emptySize = (TSDB_SYNC_LOG_BUFFER_SIZE >> 1);
while (true) {
if (index <= pBuf->commitIndex) {
@ -210,7 +211,6 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
}
bool taken = false;
int emptySize = 5;
if (toIndex - index + 1 <= pBuf->size - emptySize) {
SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = -1, .prevLogTerm = -1};
pBuf->entries[index % pBuf->size] = tmp;