diff --git a/src/system/src/vnodeImport.c b/src/system/src/vnodeImport.c index ea5f382f578eda8cdff4752f37ece3ffab0352f9..1f25141e48fec9f75aba2da86cf30500a1d4ccef 100644 --- a/src/system/src/vnodeImport.c +++ b/src/system/src/vnodeImport.c @@ -915,9 +915,6 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi if (((commitInProcess = pPool->commitInProcess) == 1) || num > 0) { pthread_mutex_unlock(&pPool->vmutex); - //restore meter state - vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING); - pNew = (SImportInfo *)malloc(sizeof(SImportInfo)); memcpy(pNew, &import, sizeof(SImportInfo)); pNew->signature = pNew; @@ -939,8 +936,6 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi pShell->numOfTotalPoints += import.importedRows; } } - - vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING); } pVnode->version++; diff --git a/src/system/src/vnodeShell.c b/src/system/src/vnodeShell.c index bb159706fb124024e6f397cafc766743e996cdcd..de3cca4fdf3cf7a50a7463607b383332cdd9bc48 100644 --- a/src/system/src/vnodeShell.c +++ b/src/system/src/vnodeShell.c @@ -160,7 +160,7 @@ int vnodeOpenShellVnode(int vnode) { return 0; } -void vnodeDelayedFreeResource(void *param, void *tmrId) { +static void vnodeDelayedFreeResource(void *param, void *tmrId) { int32_t vnode = *(int32_t*) param; taosCloseRpcChann(pShellServer, vnode); // close connection tfree (shellList[vnode]); //free SShellObj @@ -179,8 +179,9 @@ void vnodeCloseShellVnode(int vnode) { *v = vnode; /* - * free the connection related resource after 5sec, since the msg may be in - * the task queue, free it immediate will cause crash + * free the connection related resource after 5sec. + * 1. The msg, as well as SRpcConn may be in the task queue, free it immediate will cause crash + * 2. Free connection may cause *(SRpcConn*)pObj->thandle to be invalid to access. */ dTrace("vid:%d, delay 5sec to free resources", vnode); taosTmrStart(vnodeDelayedFreeResource, 5000, v, vnodeTmrCtrl); @@ -517,6 +518,7 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) { if (pSubmit->import) { code = vnodeImportPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, pObj, sversion, &numOfPoints); + vnodeClearMeterState(pMeterObj, TSDB_METER_STATE_IMPORTING); } else { code = vnodeInsertPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, NULL, sversion, &numOfPoints);