Merge pull request #12400 from taosdata/feature/tq
fix(wal): int overflow
This commit is contained in:
commit
2cc8ff312d
|
@ -485,8 +485,10 @@ static int32_t mndProcessDropTopicReq(SNodeMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
// TODO: check ref
|
||||
|
||||
int32_t code = mndDropTopic(pMnode, pReq, pTopic);
|
||||
// TODO: iterate and drop related subscriptions and offsets
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
|
||||
if (code != 0) {
|
||||
|
|
|
@ -55,7 +55,7 @@ int32_t walRegisterRead(SWalReadHandle *pRead, int64_t ver) {
|
|||
}
|
||||
|
||||
static int32_t walReadSeekFilePos(SWalReadHandle *pRead, int64_t fileFirstVer, int64_t ver) {
|
||||
int ret = 0;
|
||||
int64_t ret = 0;
|
||||
|
||||
TdFilePtr pIdxTFile = pRead->pReadIdxTFile;
|
||||
TdFilePtr pLogTFile = pRead->pReadLogTFile;
|
||||
|
@ -68,14 +68,14 @@ static int32_t walReadSeekFilePos(SWalReadHandle *pRead, int64_t fileFirstVer, i
|
|||
wError("failed to seek idx file, ver %ld, pos: %ld, since %s", ver, offset, terrstr());
|
||||
return -1;
|
||||
}
|
||||
SWalIdxEntry entry;
|
||||
SWalIdxEntry entry = {0};
|
||||
if ((ret = taosReadFile(pIdxTFile, &entry, sizeof(SWalIdxEntry))) != sizeof(SWalIdxEntry)) {
|
||||
if (ret < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
wError("failed to read idx file, since %s", terrstr());
|
||||
} else {
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
wError("read idx file incompletely, read bytes %d, bytes should be %lu", ret, sizeof(SWalIdxEntry));
|
||||
wError("read idx file incompletely, read bytes %ld, bytes should be %lu", ret, sizeof(SWalIdxEntry));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalHead *pHead) {
|
|||
}
|
||||
|
||||
int32_t walSkipFetchBody(SWalReadHandle *pRead, const SWalHead *pHead) {
|
||||
int32_t code;
|
||||
int64_t code;
|
||||
|
||||
ASSERT(pRead->curVersion == pHead->head.version);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ int32_t walCommit(SWal *pWal, int64_t ver) {
|
|||
}
|
||||
|
||||
int32_t walRollback(SWal *pWal, int64_t ver) {
|
||||
int code;
|
||||
int64_t code;
|
||||
char fnameStr[WAL_FILE_LEN];
|
||||
if (ver > pWal->vers.lastVer || ver < pWal->vers.commitVer) {
|
||||
terrno = TSDB_CODE_WAL_INVALID_VER;
|
||||
|
|
|
@ -310,9 +310,6 @@ int64_t taosCloseFile(TdFilePtr *ppFile) {
|
|||
}
|
||||
|
||||
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||
#endif
|
||||
|
@ -359,7 +356,7 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
|
|||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
#ifdef WINDOWS
|
||||
size_t pos = lseek(pFile->fd, 0, SEEK_CUR);
|
||||
lseek(pFile->fd, (long)offset, SEEK_SET);
|
||||
lseek(pFile->fd, offset, SEEK_SET);
|
||||
int64_t ret = read(pFile->fd, buf, count);
|
||||
lseek(pFile->fd, pos, SEEK_SET);
|
||||
#else
|
||||
|
@ -372,9 +369,6 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
|
|||
}
|
||||
|
||||
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) {
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockWrlock(&(pFile->rwlock));
|
||||
#endif
|
||||
|
@ -406,14 +400,11 @@ int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) {
|
|||
}
|
||||
|
||||
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||
#endif
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
int64_t ret = lseek(pFile->fd, (long)offset, whence);
|
||||
int64_t ret = lseek(pFile->fd, offset, whence);
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||
#endif
|
||||
|
@ -424,9 +415,6 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
|||
#ifdef WINDOWS
|
||||
return 0;
|
||||
#else
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
|
||||
struct stat fileStat;
|
||||
|
@ -451,9 +439,6 @@ int32_t taosLockFile(TdFilePtr pFile) {
|
|||
#ifdef WINDOWS
|
||||
return 0;
|
||||
#else
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
|
||||
return (int32_t)flock(pFile->fd, LOCK_EX | LOCK_NB);
|
||||
|
@ -464,9 +449,6 @@ int32_t taosUnLockFile(TdFilePtr pFile) {
|
|||
#ifdef WINDOWS
|
||||
return 0;
|
||||
#else
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
|
||||
return (int32_t)flock(pFile->fd, LOCK_UN | LOCK_NB);
|
||||
|
|
Loading…
Reference in New Issue