adjust some code

This commit is contained in:
Hongze Cheng 2024-10-16 16:53:02 +08:00
parent 39d4357227
commit e3da1a5b1a
1 changed files with 12 additions and 7 deletions

View File

@ -355,8 +355,8 @@ static int32_t metaGenerateNewMeta(SMeta **ppMeta) {
return code; return code;
} }
if (metaBegin(pNewMeta, META_BEGIN_HEAP_NIL) != 0) { if ((code = metaBegin(pNewMeta, META_BEGIN_HEAP_NIL)) != 0) {
metaError("vgId:%d failed to begin new meta", TD_VID(pVnode)); metaError("vgId:%d failed to begin new meta, reason:%s", TD_VID(pVnode), tstrerror(code));
} }
metaClose(&pNewMeta); metaClose(&pNewMeta);
metaInfo("vgId:%d finish to generate new meta", TD_VID(pVnode)); metaInfo("vgId:%d finish to generate new meta", TD_VID(pVnode));
@ -370,11 +370,6 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
} }
if (generateNewMeta) { if (generateNewMeta) {
code = metaGenerateNewMeta(ppMeta);
if (code) {
metaError("vgId:%d failed to generate new meta, reason:%s", TD_VID(pVnode), tstrerror(code));
}
// backup the old meta // backup the old meta
char path[TSDB_FILENAME_LEN] = {0}; char path[TSDB_FILENAME_LEN] = {0};
char oldMetaPath[TSDB_FILENAME_LEN] = {0}; char oldMetaPath[TSDB_FILENAME_LEN] = {0};
@ -386,6 +381,16 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
snprintf(newMetaPath, sizeof(newMetaPath) - 1, "%s%s%s", path, TD_DIRSEP, VNODE_META_TMP_DIR); snprintf(newMetaPath, sizeof(newMetaPath) - 1, "%s%s%s", path, TD_DIRSEP, VNODE_META_TMP_DIR);
snprintf(backupMetaPath, sizeof(backupMetaPath) - 1, "%s%s%s", path, TD_DIRSEP, VNODE_META_BACKUP_DIR); snprintf(backupMetaPath, sizeof(backupMetaPath) - 1, "%s%s%s", path, TD_DIRSEP, VNODE_META_BACKUP_DIR);
if (taosCheckExistFile(backupMetaPath)) {
metaError("vgId:%d backup meta already exists, please check", TD_VID(pVnode));
return TSDB_CODE_FAILED;
}
code = metaGenerateNewMeta(ppMeta);
if (code) {
metaError("vgId:%d failed to generate new meta, reason:%s", TD_VID(pVnode), tstrerror(code));
}
metaClose(ppMeta); metaClose(ppMeta);
if (taosRenameFile(oldMetaPath, backupMetaPath) != 0) { if (taosRenameFile(oldMetaPath, backupMetaPath) != 0) {
metaError("vgId:%d failed to rename old meta to backup, reason:%s", TD_VID(pVnode), tstrerror(terrno)); metaError("vgId:%d failed to rename old meta to backup, reason:%s", TD_VID(pVnode), tstrerror(terrno));