enh: reserve half a buffer size at syncLogBufferInit
This commit is contained in:
parent
c26d74355c
commit
be3ba000a1
|
@ -197,6 +197,7 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
|
||||||
SyncIndex index = toIndex;
|
SyncIndex index = toIndex;
|
||||||
SSyncRaftEntry* pEntry = NULL;
|
SSyncRaftEntry* pEntry = NULL;
|
||||||
bool takeDummy = false;
|
bool takeDummy = false;
|
||||||
|
int emptySize = (TSDB_SYNC_LOG_BUFFER_SIZE >> 1);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (index <= pBuf->commitIndex) {
|
if (index <= pBuf->commitIndex) {
|
||||||
|
@ -210,7 +211,6 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taken = false;
|
bool taken = false;
|
||||||
int emptySize = 5;
|
|
||||||
if (toIndex - index + 1 <= pBuf->size - emptySize) {
|
if (toIndex - index + 1 <= pBuf->size - emptySize) {
|
||||||
SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = -1, .prevLogTerm = -1};
|
SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = -1, .prevLogTerm = -1};
|
||||||
pBuf->entries[index % pBuf->size] = tmp;
|
pBuf->entries[index % pBuf->size] = tmp;
|
||||||
|
|
Loading…
Reference in New Issue