Skip to content

Commit b7549bd

Browse files
authored
Merge pull request #19869 from taosdata/FIX/TS-2533-main
enh: reset wal reader after walReadVer
2 parents a39f80b + 5ce5dde commit b7549bd

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

include/libs/wal/wal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ int32_t walApplyVer(SWal *, int64_t ver);
191191
// read
192192
SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond);
193193
void walCloseReader(SWalReader *pRead);
194+
void walReadReset(SWalReader *pReader);
194195
int32_t walReadVer(SWalReader *pRead, int64_t ver);
195196
int32_t walReadSeekVer(SWalReader *pRead, int64_t ver);
196197
int32_t walNextValidMsg(SWalReader *pRead);

source/libs/sync/src/syncRaftLog.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
249249

250250
int64_t ts2 = taosGetTimestampNs();
251251
code = walReadVer(pWalHandle, index);
252+
walReadReset(pWalHandle);
252253
int64_t ts3 = taosGetTimestampNs();
253254

254255
// code = walReadVerCached(pWalHandle, index);

source/libs/wal/src/walRead.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,3 +594,12 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
594594

595595
return 0;
596596
}
597+
598+
void walReadReset(SWalReader *pReader) {
599+
taosThreadMutexLock(&pReader->mutex);
600+
taosCloseFile(&pReader->pIdxFile);
601+
taosCloseFile(&pReader->pLogFile);
602+
pReader->curInvalid = 1;
603+
pReader->curFileFirstVer = -1;
604+
taosThreadMutexUnlock(&pReader->mutex);
605+
}

0 commit comments

Comments
 (0)