Fix review errors.

This commit is contained in:
xiao-77 2024-12-10 11:33:03 +08:00
parent 1ced6069ee
commit 2e1b94ff87
6 changed files with 39 additions and 8 deletions

View File

@ -72,6 +72,8 @@ This document details the server error codes that may be encountered when using
| 0x80000133 | Invalid operation | Invalid or unsupported operation | 1. Modify to confirm the current operation is legal and supported, check parameter validity 2. If the problem persists, preserve the scene and logs, report issue on github |
| 0x80000134 | Invalid value | Invalid value | Preserve the scene and logs, report issue on github |
| 0x80000135 | Invalid fqdn | Invalid FQDN | Check if the configured or input FQDN value is correct |
| 0x8000013C | Invalid disk id | Invalid disk id | Check users whether the mounted disk is invalid or use the parameter diskIDCheckEnabled to skip the disk check. |
## tsc

View File

@ -75,6 +75,7 @@ description: TDengine 服务端的错误码列表和详细说明
| 0x80000133 | Invalid operation | 无效的或不支持的操作 | 1. 修改确认当前操作为合法有效支持的操作,检查参数有效性 2. 如果问题还未解决保留现场和日志github上报issue |
| 0x80000134 | Invalid value | 无效值 | 保留现场和日志github上报issue |
| 0x80000135 | Invalid fqdn | 无效FQDN | 检查配置或输入的FQDN值是否正确 |
| 0x8000013C | Invalid disk id | 不合法的disk id | 建议用户检查挂载磁盘是否失效或者使用参数 diskIDCheckEnabled 来跳过磁盘检查 |

View File

@ -159,6 +159,7 @@ int32_t taosGetErrSize();
#define TSDB_CODE_SOCKET_ERROR TAOS_DEF_ERROR_CODE(0, 0x0139)
#define TSDB_CODE_UNSUPPORT_OS TAOS_DEF_ERROR_CODE(0, 0x013A)
#define TSDB_CODE_TIME_ERROR TAOS_DEF_ERROR_CODE(0, 0x013B)
#define TSDB_CODE_INVALID_DISK_ID TAOS_DEF_ERROR_CODE(0, 0x013C)
//client
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)

View File

@ -1636,6 +1636,9 @@ int32_t tDeserializeSConfigReq(void *buf, int32_t bufLen, SConfigReq *pReq) {
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->forceReadConfig));
if (pReq->forceReadConfig) {
pReq->array = taosArrayInit(128, sizeof(SConfigItem));
if (pReq->array == NULL) {
TAOS_CHECK_EXIT(terrno);
}
TAOS_CHECK_EXIT(tDeserializeSConfigArray(&decoder, pReq->array));
}
tEndDecode(&decoder);

View File

@ -1947,6 +1947,8 @@ _exit:
}
int32_t cfgDeserialize(SArray *array, char *buf, bool isGlobal) {
int32_t code = TSDB_CODE_SUCCESS;
cJSON *pRoot = cJSON_Parse(buf);
if (pRoot == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
@ -1954,8 +1956,8 @@ int32_t cfgDeserialize(SArray *array, char *buf, bool isGlobal) {
if (isGlobal) {
cJSON *pItem = cJSON_GetObjectItem(pRoot, "version");
if (pItem == NULL) {
cJSON_Delete(pRoot);
return TSDB_CODE_OUT_OF_MEMORY;
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
tsdmConfigVersion = pItem->valueint;
}
@ -1963,9 +1965,8 @@ int32_t cfgDeserialize(SArray *array, char *buf, bool isGlobal) {
int32_t sz = taosArrayGetSize(array);
cJSON *configs = cJSON_GetObjectItem(pRoot, "configs");
if (configs == NULL) {
uError("failed to get configs from json, since %s", cJSON_GetErrorPtr());
cJSON_Delete(pRoot);
return TSDB_CODE_OUT_OF_MEMORY;
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
for (int i = 0; i < sz; i++) {
SConfigItem *pItem = (SConfigItem *)taosArrayGet(array, i);
@ -1982,15 +1983,31 @@ int32_t cfgDeserialize(SArray *array, char *buf, bool isGlobal) {
// check disk id for each dir
for (int j = 0; j < sz; j++) {
cJSON *diskCfgJson = cJSON_GetArrayItem(pJson, j);
if (diskCfgJson == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
filed = cJSON_GetObjectItem(diskCfgJson, "dir");
if (filed == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
char *dir = cJSON_GetStringValue(filed);
filed = cJSON_GetObjectItem(diskCfgJson, "disk_id");
if (filed == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
int64_t actDiskID = 0;
int64_t expDiskID = atoll(cJSON_GetStringValue(filed));
int64_t expDiskID = taosStr2Int64(cJSON_GetStringValue(filed), NULL, 10);
if (!taosCheckFileDiskID(dir, &actDiskID, expDiskID)) {
uError("failed to check disk id for dir:%s, actDiskID%" PRId64 ", expDiskID%" PRId64, dir, actDiskID,
expDiskID);
return TSDB_CODE_FAILED;
code = TSDB_CODE_INVALID_DISK_ID;
goto _exit;
}
}
continue;
@ -2020,13 +2037,19 @@ int32_t cfgDeserialize(SArray *array, char *buf, bool isGlobal) {
case CFG_DTYPE_TIMEZONE:
taosMemoryFree(pItem->str);
pItem->str = taosStrdup(pJson->valuestring);
if (pItem->str == NULL) {
code = terrno;
}
break;
}
}
}
_exit:
if (code != TSDB_CODE_SUCCESS) {
uError("failed to deserialize config since %s", tstrerror(code));
}
cJSON_Delete(pRoot);
return TSDB_CODE_SUCCESS;
return code;
}
int32_t readCfgFile(const char *path, bool isGlobal) {

View File

@ -118,6 +118,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MSG_PREPROCESSED, "Message has been proc
TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_BUFFER, "Out of buffer")
TAOS_DEFINE_ERROR(TSDB_CODE_INTERNAL_ERROR, "Internal error")
TAOS_DEFINE_ERROR(TSDB_CODE_TIME_ERROR, "Internal error in time")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_DISK_ID, "Internal error invalid disk id")
//client
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation")