提交 f2e1bd55 编写于 作者: S Shengliang Guan

fix: failed to read sdb while udf larger then 10M

上级 77a6cf50
......@@ -265,34 +265,48 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
if (ret < 0) {
code = TAOS_SYSTEM_ERROR(errno);
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
break;
goto _OVER;
}
if (ret != readLen) {
code = TSDB_CODE_FILE_CORRUPTED;
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
break;
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " != readLen:%d", file, tstrerror(code), ret, readLen);
goto _OVER;
}
readLen = pRaw->dataLen + sizeof(int32_t);
if (readLen >= pRaw->dataLen) {
SSdbRaw *pNewRaw = taosMemoryMalloc(pRaw->dataLen + TSDB_MAX_MSG_SIZE);
if (pNewRaw == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
mError("failed read sdb file since malloc new sdbRaw size:%d failed", pRaw->dataLen + TSDB_MAX_MSG_SIZE);
return -1;
} else {
mInfo("malloc new sdbRaw size:%d, type:%d",pRaw->dataLen + TSDB_MAX_MSG_SIZE, pRaw->type);
}
memcpy(pNewRaw, pRaw, sizeof(SSdbRaw));
sdbFreeRaw(pRaw);
pRaw = pNewRaw;
}
ret = taosReadFile(pFile, pRaw->pData, readLen);
if (ret < 0) {
code = TAOS_SYSTEM_ERROR(errno);
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
break;
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " readLen:%d", file, tstrerror(code), ret, readLen);
goto _OVER;
}
if (ret != readLen) {
code = TSDB_CODE_FILE_CORRUPTED;
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
break;
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " != readLen:%d", file, tstrerror(code), ret, readLen);
goto _OVER;
}
int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t);
if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) {
code = TSDB_CODE_CHECKSUM_ERROR;
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
break;
mError("failed to read sdb file:%s since %s, readLen:%d", file, tstrerror(code), readLen);
goto _OVER;
}
code = sdbWriteWithoutFree(pSdb, pRaw);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册