Merge pull request #24074 from taosdata/mark/3.0

fix:core dump if tqOpen error in vnodeOpen
This commit is contained in:
Haojun Liao 2023-12-15 13:55:10 +08:00 committed by GitHub
commit 556eaa22ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -47,6 +47,7 @@ int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname) {
}
}
size = htonl(size);
void* pMemBuf = taosMemoryCalloc(1, size);
if (pMemBuf == NULL) {
tqError("vgId:%d failed to restore offset from file, since out of memory, malloc size:%d", vgId, size);
@ -119,6 +120,7 @@ STqOffsetStore* tqOffsetOpen(STQ* pTq) {
}
void tqOffsetClose(STqOffsetStore* pStore) {
if(pStore == NULL) return;
tqOffsetCommitFile(pStore);
taosHashCleanup(pStore->pHash);
taosMemoryFree(pStore);
@ -176,7 +178,7 @@ int32_t tqOffsetCommitFile(STqOffsetStore* pStore) {
void* buf = taosMemoryCalloc(1, totLen);
void* abuf = POINTER_SHIFT(buf, INT_BYTES);
*(int32_t*)buf = bodyLen;
*(int32_t*)buf = htonl(bodyLen);
SEncoder encoder;
tEncoderInit(&encoder, abuf, bodyLen);
tEncodeSTqOffset(&encoder, pOffset);