Merge pull request #25246 from taosdata/fix/3_liaohj
fix(stream): add lock for when set checkpoint dispatch msg.
This commit is contained in:
commit
a3bcd9e9c9
|
@ -355,6 +355,8 @@ typedef struct SMetaHbInfo SMetaHbInfo;
|
|||
typedef struct SDispatchMsgInfo {
|
||||
SStreamDispatchReq* pData; // current dispatch data
|
||||
int8_t dispatchMsgType;
|
||||
int64_t checkpointId;// checkpoint id msg
|
||||
int32_t transId; // transId for current checkpoint
|
||||
int16_t msgType; // dispatch msg type
|
||||
int32_t retryCount; // retry send data count
|
||||
int64_t startTs; // dispatch start time, record total elapsed time for dispatch
|
||||
|
|
|
@ -850,12 +850,18 @@ int32_t tqStreamTaskProcessTaskResetReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
|||
|
||||
tqDebug("s-task:%s receive task-reset msg from mnode, reset status and ready for data processing", pTask->id.idStr);
|
||||
|
||||
taosThreadMutexLock(&pTask->lock);
|
||||
|
||||
// clear flag set during do checkpoint, and open inputQ for all upstream tasks
|
||||
if (streamTaskGetStatus(pTask)->state == TASK_STATUS__CK) {
|
||||
tqDebug("s-task:%s reset task status from checkpoint, current checkpointingId:%" PRId64 ", transId:%d",
|
||||
pTask->id.idStr, pTask->chkInfo.checkpointingId, pTask->chkInfo.transId);
|
||||
streamTaskClearCheckInfo(pTask, true);
|
||||
streamTaskSetStatusReady(pTask);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pTask->lock);
|
||||
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -321,6 +321,8 @@ void clearBufferedDispatchMsg(SStreamTask* pTask) {
|
|||
destroyDispatchMsg(pMsgInfo->pData, getNumOfDispatchBranch(pTask));
|
||||
}
|
||||
|
||||
pMsgInfo->checkpointId = -1;
|
||||
pMsgInfo->transId = -1;
|
||||
pMsgInfo->pData = NULL;
|
||||
pMsgInfo->dispatchMsgType = 0;
|
||||
}
|
||||
|
@ -332,6 +334,12 @@ static int32_t doBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* pD
|
|||
|
||||
pTask->msgInfo.dispatchMsgType = pData->type;
|
||||
|
||||
if (pData->type == STREAM_INPUT__CHECKPOINT_TRIGGER) {
|
||||
SSDataBlock* p = taosArrayGet(pData->blocks, 0);
|
||||
pTask->msgInfo.checkpointId = p->info.version;
|
||||
pTask->msgInfo.transId = p->info.window.ekey;
|
||||
}
|
||||
|
||||
if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
|
||||
SStreamDispatchReq* pReq = taosMemoryCalloc(1, sizeof(SStreamDispatchReq));
|
||||
|
||||
|
@ -950,9 +958,21 @@ void streamClearChkptReadyMsg(SStreamTask* pTask) {
|
|||
// this message has been sent successfully, let's try next one.
|
||||
static int32_t handleDispatchSuccessRsp(SStreamTask* pTask, int32_t downstreamId) {
|
||||
stDebug("s-task:%s destroy dispatch msg:%p", pTask->id.idStr, pTask->msgInfo.pData);
|
||||
|
||||
bool delayDispatch = (pTask->msgInfo.dispatchMsgType == STREAM_INPUT__CHECKPOINT_TRIGGER);
|
||||
if (delayDispatch) {
|
||||
pTask->chkInfo.dispatchCheckpointTrigger = true;
|
||||
taosThreadMutexLock(&pTask->lock);
|
||||
// we only set the dispatch msg info for current checkpoint trans
|
||||
if (streamTaskGetStatus(pTask)->state == TASK_STATUS__CK && pTask->chkInfo.checkpointingId == pTask->msgInfo.checkpointId) {
|
||||
ASSERT(pTask->chkInfo.transId == pTask->msgInfo.transId);
|
||||
pTask->chkInfo.dispatchCheckpointTrigger = true;
|
||||
stDebug("s-task:%s checkpoint-trigger msg rsp for checkpointId:%" PRId64 " transId:%d confirmed",
|
||||
pTask->id.idStr, pTask->msgInfo.checkpointId, pTask->msgInfo.transId);
|
||||
} else {
|
||||
stWarn("s-task:%s checkpoint-trigger msg rsp for checkpointId:%" PRId64 " transId:%d discard, since expired",
|
||||
pTask->id.idStr, pTask->msgInfo.checkpointId, pTask->msgInfo.transId);
|
||||
}
|
||||
taosThreadMutexUnlock(&pTask->lock);
|
||||
}
|
||||
|
||||
clearBufferedDispatchMsg(pTask);
|
||||
|
|
|
@ -543,8 +543,6 @@ void streamTaskSetStatusReady(SStreamTask* pTask) {
|
|||
return;
|
||||
}
|
||||
|
||||
taosThreadMutexLock(&pTask->lock);
|
||||
|
||||
pSM->prev.state = pSM->current;
|
||||
pSM->prev.evt = 0;
|
||||
|
||||
|
@ -552,8 +550,6 @@ void streamTaskSetStatusReady(SStreamTask* pTask) {
|
|||
pSM->startTs = taosGetTimestampMs();
|
||||
pSM->pActiveTrans = NULL;
|
||||
taosArrayClear(pSM->pWaitingEventList);
|
||||
|
||||
taosThreadMutexUnlock(&pTask->lock);
|
||||
}
|
||||
|
||||
STaskStateTrans createStateTransform(ETaskStatus current, ETaskStatus next, EStreamTaskEvent event, __state_trans_fn fn,
|
||||
|
|
Loading…
Reference in New Issue