other: code optimization
This commit is contained in:
parent
16b2d7932d
commit
8281176b0b
|
@ -156,6 +156,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
|
|||
|
||||
static void tdDestroyTSmaStat(STSmaStat *pStat) {
|
||||
if (pStat) {
|
||||
smaDebug("destroy tsma stat");
|
||||
tDestroyTSma(pStat->pTSma);
|
||||
taosMemoryFreeClear(pStat->pTSma);
|
||||
taosMemoryFreeClear(pStat->pTSchema);
|
||||
|
@ -170,7 +171,7 @@ static void *tdFreeTSmaStat(STSmaStat *pStat) {
|
|||
|
||||
static void tdDestroyRSmaStat(SRSmaStat *pStat) {
|
||||
if (pStat) {
|
||||
smaDebug("vgId:%d, %s:%d free rsma stat", SMA_VID(pStat->pSma), __func__, __LINE__);
|
||||
smaDebug("vgId:%d destroy rsma stat", SMA_VID(pStat->pSma));
|
||||
// step 1: set persistence task cancelled
|
||||
atomic_store_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_CANCELLED);
|
||||
|
||||
|
@ -245,16 +246,12 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) {
|
|||
int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
|
||||
if (pSmaStat) {
|
||||
if (smaType == TSDB_SMA_TYPE_TIME_RANGE) {
|
||||
smaDebug("%s:%d destroy tsma stat", __func__, __LINE__);
|
||||
tdDestroyTSmaStat(SMA_TSMA_STAT(pSmaStat));
|
||||
} else if (smaType == TSDB_SMA_TYPE_ROLLUP) {
|
||||
smaDebug("%s:%d destroy rsma stat", __func__, __LINE__);
|
||||
tdDestroyRSmaStat(SMA_RSMA_STAT(pSmaStat));
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
} else {
|
||||
smaDebug("%s:%d no need to destroy rsma stat", __func__, __LINE__);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -190,8 +190,8 @@ static int32_t rsmaRestore(SSma *pSma) {
|
|||
if (TABLE_IS_ROLLUP(mr.me.flags)) {
|
||||
SRSmaParam *param = &mr.me.stbEntry.rsmaParam;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
smaDebug("%s:%d table:%" PRIi64 " maxdelay[%d]:%" PRIi64 " watermark[%d]:%" PRIi64, __func__, __LINE__, suid, i,
|
||||
param->maxdelay[i], i, param->watermark[i]);
|
||||
smaDebug("vgId: %d table:%" PRIi64 " maxdelay[%d]:%" PRIi64 " watermark[%d]:%" PRIi64, TD_VID(pSma->pVnode),
|
||||
suid, i, param->maxdelay[i], i, param->watermark[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,10 +49,10 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId,
|
|||
// Note: free/kill may in RC
|
||||
qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle);
|
||||
if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) {
|
||||
smaDebug("vgId:%d, %s:%d free qTaskInfo_t %p of level %d", vgId, __func__, __LINE__, otaskHandle, level);
|
||||
smaDebug("vgId:%d, free qTaskInfo_t %p of level %d", vgId, otaskHandle, level);
|
||||
qDestroyTask(otaskHandle);
|
||||
} else {
|
||||
smaDebug("vgId:%d, %s:%d not free qTaskInfo_t %p of level %d", vgId, __func__, __LINE__, otaskHandle, level);
|
||||
smaDebug("vgId:%d, not free qTaskInfo_t %p of level %d", vgId, otaskHandle, level);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) {
|
||||
static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) {
|
||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||
SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv);
|
||||
SRSmaInfo *pRSmaInfo = NULL;
|
||||
|
@ -528,16 +528,16 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
|
||||
int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat));
|
||||
if (rsmaTriggerStat == TASK_TRIGGER_STAT_CANCELLED || rsmaTriggerStat == TASK_TRIGGER_STAT_FINISHED) {
|
||||
smaDebug("vgId:%d, %s:%d level %" PRIi8 " not fetch since stat is cancelled for table suid:%" PRIi64, SMA_VID(pSma),
|
||||
__func__, __LINE__, pItem->level, pItem->pRsmaInfo->suid);
|
||||
smaDebug("vgId:%d, level %" PRIi8 " not fetch since stat is cancelled for table suid:%" PRIi64, SMA_VID(pSma),
|
||||
pItem->level, pItem->pRsmaInfo->suid);
|
||||
return;
|
||||
}
|
||||
|
||||
int8_t fetchTriggerStat =
|
||||
atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE);
|
||||
if (fetchTriggerStat == TASK_TRIGGER_STAT_ACTIVE) {
|
||||
smaDebug("vgId:%d, %s:%d level %" PRIi8 " stat is active for table suid:%" PRIi64, SMA_VID(pSma), __func__,
|
||||
__LINE__, pItem->level, pItem->pRsmaInfo->suid);
|
||||
smaDebug("vgId:%d, level %" PRIi8 " stat is active for table suid:%" PRIi64, SMA_VID(pSma), pItem->level,
|
||||
pItem->pRsmaInfo->suid);
|
||||
|
||||
tdRefSmaStat(pSma, (SSmaStat *)pStat);
|
||||
|
||||
|
@ -548,13 +548,13 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
tdUnRefSmaStat(pSma, (SSmaStat *)pStat);
|
||||
|
||||
} else {
|
||||
smaDebug("vgId:%d, %s:%d level %" PRIi8 " stat is inactive for table suid:%" PRIi64, SMA_VID(pSma), __func__,
|
||||
__LINE__, pItem->level, pItem->pRsmaInfo->suid);
|
||||
smaDebug("vgId:%d, level %" PRIi8 " stat is inactive for table suid:%" PRIi64, SMA_VID(pSma), pItem->level,
|
||||
pItem->pRsmaInfo->suid);
|
||||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem,
|
||||
tb_uid_t suid, int8_t level) {
|
||||
static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem, tb_uid_t suid,
|
||||
int8_t level) {
|
||||
if (!pItem || !pItem->taskInfo) {
|
||||
smaDebug("vgId:%d, no qTaskInfo to execute rsma %" PRIi8 " task for suid:%" PRIu64, SMA_VID(pSma), level, suid);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -570,7 +570,7 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3
|
|||
|
||||
tdFetchAndSubmitRSmaResult(pItem, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
||||
atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE);
|
||||
smaDebug("vgId:%d, %s:%d process rsma insert", SMA_VID(pSma), __func__, __LINE__);
|
||||
smaDebug("vgId:%d, process rsma insert", SMA_VID(pSma));
|
||||
|
||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||
SRSmaStat *pStat = SMA_RSMA_STAT(pEnv->pStat);
|
||||
|
@ -823,7 +823,7 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) {
|
|||
if (TASK_TRIGGER_STAT_CANCELLED != atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat),
|
||||
TASK_TRIGGER_STAT_CANCELLED,
|
||||
TASK_TRIGGER_STAT_FINISHED)) {
|
||||
smaDebug("%s:%d rsma persistence start since active", __func__, __LINE__);
|
||||
smaDebug("rsma persistence start since active");
|
||||
tdRSmaPersistTask(pRSmaStat);
|
||||
taosTmrReset(tdRSmaPersistTrigger, RSMA_QTASK_PERSIST_MS, pRSmaStat, pRSmaStat->tmrHandle, &pRSmaStat->tmrId);
|
||||
} else {
|
||||
|
@ -832,16 +832,16 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) {
|
|||
} break;
|
||||
case TASK_TRIGGER_STAT_CANCELLED: {
|
||||
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_FINISHED);
|
||||
smaDebug("%s:%d rsma persistence not start since cancelled and finished", __func__, __LINE__);
|
||||
smaDebug("rsma persistence not start since cancelled and finished");
|
||||
} break;
|
||||
case TASK_TRIGGER_STAT_INACTIVE: {
|
||||
smaDebug("%s:%d rsma persistence not start since inactive", __func__, __LINE__);
|
||||
smaDebug("rsma persistence not start since inactive");
|
||||
} break;
|
||||
case TASK_TRIGGER_STAT_INIT: {
|
||||
smaDebug("%s:%d rsma persistence not start since init", __func__, __LINE__);
|
||||
smaDebug("rsma persistence not start since init");
|
||||
} break;
|
||||
default: {
|
||||
smaWarn("%s:%d rsma persistence not start since unknown stat %" PRIi8, __func__, __LINE__, tmrStat);
|
||||
smaWarn("rsma persistence not start since unknown stat %" PRIi8, tmrStat);
|
||||
ASSERT(0);
|
||||
} break;
|
||||
}
|
||||
|
|
|
@ -172,9 +172,9 @@ void vnodeClose(SVnode *pVnode) {
|
|||
vnodeSyncClose(pVnode);
|
||||
vnodeQueryClose(pVnode);
|
||||
walClose(pVnode->pWal);
|
||||
smaCloseEx(pVnode->pSma);
|
||||
tqClose(pVnode->pTq);
|
||||
if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
|
||||
smaCloseEx(pVnode->pSma);
|
||||
metaClose(pVnode->pMeta);
|
||||
vnodeCloseBufPool(pVnode);
|
||||
// destroy handle
|
||||
|
|
Loading…
Reference in New Issue