fix:[TS-4921] stop timer in the end
This commit is contained in:
parent
f4bf21a4c7
commit
b5b43e1e9b
|
@ -40,8 +40,14 @@ typedef struct {
|
||||||
taos_collector_registry_t* registry;
|
taos_collector_registry_t* registry;
|
||||||
taos_collector_t* colector;
|
taos_collector_t* colector;
|
||||||
SHashObj* counters;
|
SHashObj* counters;
|
||||||
|
void* timer;
|
||||||
} MonitorClient;
|
} MonitorClient;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
TdFilePtr pFile;
|
||||||
|
void* timer;
|
||||||
|
} SlowLogClient;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
char *value;
|
char *value;
|
||||||
|
|
|
@ -39,16 +39,25 @@ static int32_t getSlowLogTmpDir(char* tmpPath, int32_t size){
|
||||||
// taos_counter_destroy(conuter);
|
// taos_counter_destroy(conuter);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
static void destroyClientFile(void* data){
|
static void destroySlowLogClient(void* data){
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TdFilePtr pFile = *(TdFilePtr*)data;
|
SlowLogClient* slowLogClient = *(SlowLogClient**)data;
|
||||||
if(pFile == NULL){
|
if(slowLogClient == NULL){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
taosTmrStopA(&(*(SlowLogClient**)data)->timer);
|
||||||
|
|
||||||
|
TdFilePtr pFile = slowLogClient->pFile;
|
||||||
|
if(pFile == NULL){
|
||||||
|
taosMemoryFree(slowLogClient);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
taosUnLockFile(pFile);
|
taosUnLockFile(pFile);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
|
taosMemoryFree(slowLogClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyMonitorClient(void* data){
|
static void destroyMonitorClient(void* data){
|
||||||
|
@ -59,6 +68,7 @@ static void destroyMonitorClient(void* data){
|
||||||
if(pMonitor == NULL){
|
if(pMonitor == NULL){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
taosTmrStopA(&pMonitor->timer);
|
||||||
taosHashCleanup(pMonitor->counters);
|
taosHashCleanup(pMonitor->counters);
|
||||||
taos_collector_registry_destroy(pMonitor->registry);
|
taos_collector_registry_destroy(pMonitor->registry);
|
||||||
// taos_collector_destroy(pMonitor->colector);
|
// taos_collector_destroy(pMonitor->colector);
|
||||||
|
@ -237,7 +247,7 @@ static void sendAllSlowLog(){
|
||||||
taosRLockLatch(&monitorLock);
|
taosRLockLatch(&monitorLock);
|
||||||
void* data = taosHashIterate(monitorSlowLogHash, NULL);
|
void* data = taosHashIterate(monitorSlowLogHash, NULL);
|
||||||
while (data != NULL) {
|
while (data != NULL) {
|
||||||
TdFilePtr pFile = *(TdFilePtr*)data;
|
TdFilePtr pFile = (*(SlowLogClient**)data)->pFile;
|
||||||
if (pFile != NULL){
|
if (pFile != NULL){
|
||||||
int64_t clusterId = *(int64_t*)taosHashGetKey(data, NULL);
|
int64_t clusterId = *(int64_t*)taosHashGetKey(data, NULL);
|
||||||
SAppInstInfo* pInst = getAppInstByClusterId(clusterId);
|
SAppInstInfo* pInst = getAppInstByClusterId(clusterId);
|
||||||
|
@ -351,7 +361,7 @@ void monitorInit() {
|
||||||
if (monitorSlowLogHash == NULL) {
|
if (monitorSlowLogHash == NULL) {
|
||||||
uError("failed to create monitorSlowLogHash");
|
uError("failed to create monitorSlowLogHash");
|
||||||
}
|
}
|
||||||
taosHashSetFreeFp(monitorSlowLogHash, destroyClientFile);
|
taosHashSetFreeFp(monitorSlowLogHash, destroySlowLogClient);
|
||||||
|
|
||||||
monitorTimer = taosTmrInit(0, 0, 0, "MONITOR");
|
monitorTimer = taosTmrInit(0, 0, 0, "MONITOR");
|
||||||
if (monitorTimer == NULL) {
|
if (monitorTimer == NULL) {
|
||||||
|
@ -418,7 +428,11 @@ void monitorCreateClient(int64_t clusterId) {
|
||||||
pMonitor = NULL;
|
pMonitor = NULL;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
taosTmrStart(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, (void*)pMonitor, monitorTimer);
|
pMonitor->timer = taosTmrStart(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, (void*)pMonitor, monitorTimer);
|
||||||
|
if(pMonitor->timer == NULL){
|
||||||
|
uError("failed to start timer");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
uInfo("[monitor] monitorCreateClient for %"PRIx64 "finished %p.", clusterId, pMonitor);
|
uInfo("[monitor] monitorCreateClient for %"PRIx64 "finished %p.", clusterId, pMonitor);
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&monitorLock);
|
taosWUnLockLatch(&monitorLock);
|
||||||
|
@ -504,7 +518,7 @@ void reportSlowLog(void* param, void* tmrId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SEpSet ep = getEpSet_s(&pInst->mgmtEp);
|
SEpSet ep = getEpSet_s(&pInst->mgmtEp);
|
||||||
monitorReadSendSlowLog(*(TdFilePtr*)tmp, pInst->pTransporter, &ep);
|
monitorReadSendSlowLog((*(SlowLogClient**)tmp)->pFile, pInst->pTransporter, &ep);
|
||||||
taosRUnLockLatch(&monitorLock);
|
taosRUnLockLatch(&monitorLock);
|
||||||
|
|
||||||
taosTmrReset(reportSlowLog, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId);
|
taosTmrReset(reportSlowLog, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId);
|
||||||
|
@ -530,9 +544,17 @@ void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char *tmpPath){
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pFile, POINTER_BYTES) != 0){
|
SlowLogClient *pClient = taosMemoryCalloc(1, sizeof(SlowLogClient));
|
||||||
|
if (pClient == NULL){
|
||||||
|
uError("failed to allocate memory for slow log client");
|
||||||
|
taosCloseFile(&pFile);
|
||||||
|
goto FAILED;
|
||||||
|
}
|
||||||
|
pClient->pFile = pFile;
|
||||||
|
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0){
|
||||||
uError("failed to put clusterId:%" PRId64 " to hash table", slowLogData->clusterId);
|
uError("failed to put clusterId:%" PRId64 " to hash table", slowLogData->clusterId);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
|
taosMemoryFree(pClient);
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,9 +569,9 @@ void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char *tmpPath){
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTmrStart(reportSlowLog, pInst->monitorParas.tsMonitorInterval * 1000, (void*)slowLogData->clusterId, monitorTimer);
|
pClient->timer = taosTmrStart(reportSlowLog, pInst->monitorParas.tsMonitorInterval * 1000, (void*)slowLogData->clusterId, monitorTimer);
|
||||||
}else{
|
}else{
|
||||||
pFile = *(TdFilePtr*)tmp;
|
pFile = (*(SlowLogClient**)tmp)->pFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosWriteFile(pFile, slowLogData->value, strlen(slowLogData->value) + 1) < 0){
|
if (taosWriteFile(pFile, slowLogData->value, strlen(slowLogData->value) + 1) < 0){
|
||||||
|
|
Loading…
Reference in New Issue