enh: dnode notify logic
This commit is contained in:
parent
dbfd282b13
commit
88fdeca5cf
|
@ -56,25 +56,23 @@ static void *dmStatusThreadFp(void *param) {
|
||||||
SDmNotifyHandle dmNotifyHdl = {.state = 0};
|
SDmNotifyHandle dmNotifyHdl = {.state = 0};
|
||||||
static void *dmNotifyThreadFp(void *param) {
|
static void *dmNotifyThreadFp(void *param) {
|
||||||
SDnodeMgmt *pMgmt = param;
|
SDnodeMgmt *pMgmt = param;
|
||||||
int64_t lastTime = taosGetTimestampMs();
|
|
||||||
setThreadName("dnode-notify");
|
setThreadName("dnode-notify");
|
||||||
|
|
||||||
if (tsem_init(&dmNotifyHdl.sem, 0, 0) != 0) {
|
if (tsem_init(&dmNotifyHdl.sem, 0, 0) != 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wait = true;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
||||||
|
if (wait) tsem_wait(&dmNotifyHdl.sem);
|
||||||
_wait:
|
|
||||||
tsem_wait(&dmNotifyHdl.sem);
|
|
||||||
_send:
|
|
||||||
atomic_store_8(&dmNotifyHdl.state, 1);
|
atomic_store_8(&dmNotifyHdl.state, 1);
|
||||||
dmSendNotifyReq(pMgmt);
|
dmSendNotifyReq(pMgmt);
|
||||||
if (1 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 0)) {
|
if (1 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 0)) {
|
||||||
goto _wait;
|
wait = true;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
goto _send;
|
wait = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -199,7 +199,7 @@ static inline void metaTimeSeriesNotifyCheck(SMeta *pMeta) {
|
||||||
int64_t nTimeSeries = metaGetTimeSeriesNum(pMeta, 0);
|
int64_t nTimeSeries = metaGetTimeSeriesNum(pMeta, 0);
|
||||||
int64_t deltaTS = nTimeSeries - pMeta->pVnode->config.vndStats.numOfReportedTimeSeries;
|
int64_t deltaTS = nTimeSeries - pMeta->pVnode->config.vndStats.numOfReportedTimeSeries;
|
||||||
if (deltaTS > tsTimeSeriesThreshold) {
|
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);
|
tsem_post(&dmNotifyHdl.sem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue