From 88fdeca5cf0ddb129fb0a095307e3aa4a24b76a9 Mon Sep 17 00:00:00 2001 From: kailixu Date: Thu, 5 Oct 2023 22:31:25 +0800 Subject: [PATCH] enh: dnode notify logic --- source/dnode/mgmt/mgmt_dnode/src/dmWorker.c | 12 +++++------- source/dnode/vnode/src/meta/metaTable.c | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c index 598f449738..18da1d638c 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c @@ -56,25 +56,23 @@ static void *dmStatusThreadFp(void *param) { SDmNotifyHandle dmNotifyHdl = {.state = 0}; static void *dmNotifyThreadFp(void *param) { SDnodeMgmt *pMgmt = param; - int64_t lastTime = taosGetTimestampMs(); setThreadName("dnode-notify"); if (tsem_init(&dmNotifyHdl.sem, 0, 0) != 0) { return NULL; } + bool wait = true; while (1) { if (pMgmt->pData->dropped || pMgmt->pData->stopped) break; - - _wait: - tsem_wait(&dmNotifyHdl.sem); - _send: + if (wait) tsem_wait(&dmNotifyHdl.sem); atomic_store_8(&dmNotifyHdl.state, 1); dmSendNotifyReq(pMgmt); if (1 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 0)) { - goto _wait; + wait = true; + continue; } - goto _send; + wait = false; } return NULL; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index cbbee06e34..16bffce784 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -199,7 +199,7 @@ static inline void metaTimeSeriesNotifyCheck(SMeta *pMeta) { int64_t nTimeSeries = metaGetTimeSeriesNum(pMeta, 0); int64_t deltaTS = nTimeSeries - pMeta->pVnode->config.vndStats.numOfReportedTimeSeries; if (deltaTS > tsTimeSeriesThreshold) { - if (1 != atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 2)) { + if (0 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 2)) { tsem_post(&dmNotifyHdl.sem); } }