• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #3530

16 Nov 2024 07:44AM UTC coverage: 60.219% (-0.7%) from 60.888%
#3530

push

travis-ci

web-flow
Update 03-ad.md

118417 of 252124 branches covered (46.97%)

Branch coverage included in aggregate %.

198982 of 274951 relevant lines covered (72.37%)

6072359.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/source/libs/stream/src/streamCheckStatus.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#include "cos.h"
17
#include "rsync.h"
18
#include "streamBackendRocksdb.h"
19
#include "streamInt.h"
20

21
#define CHECK_NOT_RSP_DURATION 10 * 1000  // 10 sec
22

23
static void    processDownstreamReadyRsp(SStreamTask* pTask);
24
static int32_t addIntoNodeUpdateList(SStreamTask* pTask, int32_t nodeId);
25
static void    rspMonitorFn(void* param, void* tmrId);
26
static void    streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOutputInfo, int64_t startTs);
27
static int32_t streamTaskStartCheckDownstream(STaskCheckInfo* pInfo, const char* id);
28
static void    streamTaskCompleteCheckRsp(STaskCheckInfo* pInfo, bool lock, const char* id);
29
static void    streamTaskAddReqInfo(STaskCheckInfo* pInfo, int64_t reqId, int32_t taskId, int32_t vgId, const char* id);
30
static int32_t doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p);
31
static void    handleTimeoutDownstreamTasks(SStreamTask* pTask, SArray* pTimeoutList);
32
static void    handleNotReadyDownstreamTask(SStreamTask* pTask, SArray* pNotReadyList);
33
static int32_t streamTaskUpdateCheckInfo(STaskCheckInfo* pInfo, int32_t taskId, int32_t status, int64_t rspTs,
34
                                         int64_t reqId, int32_t* pNotReady, const char* id);
35
static void setCheckDownstreamReqInfo(SStreamTaskCheckReq* pReq, int64_t reqId, int32_t dstTaskId, int32_t dstNodeId);
36
static void getCheckRspStatus(STaskCheckInfo* pInfo, int64_t el, int32_t* numOfReady, int32_t* numOfFault,
37
                              int32_t* numOfNotRsp, SArray* pTimeoutList, SArray* pNotReadyList, const char* id);
38
static int32_t addDownstreamFailedStatusResultAsync(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId);
39
static void    findCheckRspStatus(STaskCheckInfo* pInfo, int32_t taskId, SDownstreamStatusInfo** pStatusInfo);
40

41
int32_t streamTaskCheckStatus(SStreamTask* pTask, int32_t upstreamTaskId, int32_t vgId, int64_t stage,
12,302✔
42
                              int64_t* oldStage) {
43
  SStreamUpstreamEpInfo* pInfo = NULL;
12,302✔
44
  streamTaskGetUpstreamTaskEpInfo(pTask, upstreamTaskId, &pInfo);
12,302✔
45
  if (pInfo == NULL) {
12,302!
46
    return TSDB_CODE_STREAM_TASK_NOT_EXIST;
×
47
  }
48

49
  *oldStage = pInfo->stage;
12,302✔
50
  const char* id = pTask->id.idStr;
12,302✔
51
  if (stage == -1) {
12,302!
52
    stDebug("s-task:%s receive check msg from upstream task:0x%x(vgId:%d), invalid stageId:%" PRId64 ", not ready", id,
×
53
            upstreamTaskId, vgId, stage);
54
    return 0;
×
55
  }
56

57
  if (pInfo->stage == -1) {
12,302✔
58
    pInfo->stage = stage;
11,578✔
59
    stDebug("s-task:%s receive check msg from upstream task:0x%x(vgId:%d) first time, init stage value:%" PRId64, id,
11,578✔
60
            upstreamTaskId, vgId, stage);
61
  }
62

63
  if (pInfo->stage < stage) {
12,302!
64
    stError("s-task:%s receive check msg from upstream task:0x%x(vgId:%d), new stage received:%" PRId64
×
65
            ", prev:%" PRId64,
66
            id, upstreamTaskId, vgId, stage, pInfo->stage);
67
    // record the checkpoint failure id and sent to mnode
68
    streamTaskSetCheckpointFailed(pTask);
×
69
  }
70

71
  if (pInfo->stage != stage) {
12,302!
72
    return TASK_UPSTREAM_NEW_STAGE;
×
73
  } else if (pTask->status.downstreamReady != 1) {
12,302✔
74
    stDebug("s-task:%s vgId:%d leader:%d, downstream not ready", id, vgId, (pTask->pMeta->role == NODE_ROLE_LEADER));
755✔
75
    return TASK_DOWNSTREAM_NOT_READY;
755✔
76
  } else {
77
    return TASK_DOWNSTREAM_READY;
11,547✔
78
  }
79
}
80

81
// check status
82
void streamTaskSendCheckMsg(SStreamTask* pTask) {
8,095✔
83
  SDataRange*  pRange = &pTask->dataRange;
8,095✔
84
  STimeWindow* pWindow = &pRange->window;
8,095✔
85
  const char*  idstr = pTask->id.idStr;
8,095✔
86
  int32_t      code = 0;
8,095✔
87

88
  SStreamTaskCheckReq req = {
8,095✔
89
      .streamId = pTask->id.streamId,
8,095✔
90
      .upstreamTaskId = pTask->id.taskId,
8,095✔
91
      .upstreamNodeId = pTask->info.nodeId,
8,095✔
92
      .childId = pTask->info.selfChildId,
8,095✔
93
      .stage = pTask->pMeta->stage,
8,095✔
94
  };
95

96
  // serialize streamProcessScanHistoryFinishRsp
97
  if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
8,095✔
98
    streamTaskStartMonitorCheckRsp(pTask);
705✔
99

100
    STaskDispatcherFixed* pDispatch = &pTask->outputInfo.fixedDispatcher;
705✔
101

102
    setCheckDownstreamReqInfo(&req, tGenIdPI64(), pDispatch->taskId, pDispatch->nodeId);
705✔
103
    streamTaskAddReqInfo(&pTask->taskCheckInfo, req.reqId, pDispatch->taskId, pDispatch->nodeId, idstr);
705✔
104

105
    stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " check single downstream task:0x%x(vgId:%d) ver:%" PRId64 "-%" PRId64
705✔
106
            " window:%" PRId64 "-%" PRId64 " QID:0x%" PRIx64,
107
            idstr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, pRange->range.minVer,
108
            pRange->range.maxVer, pWindow->skey, pWindow->ekey, req.reqId);
109

110
    code = streamSendCheckMsg(pTask, &req, pTask->outputInfo.fixedDispatcher.nodeId,
705✔
111
                              &pTask->outputInfo.fixedDispatcher.epSet);
112

113
  } else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
7,390✔
114
    streamTaskStartMonitorCheckRsp(pTask);
3,422✔
115

116
    SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
3,422✔
117

118
    int32_t numOfVgs = taosArrayGetSize(vgInfo);
3,422✔
119
    stDebug("s-task:%s check %d downstream tasks, ver:%" PRId64 "-%" PRId64 " window:%" PRId64 "-%" PRId64, idstr,
3,422✔
120
            numOfVgs, pRange->range.minVer, pRange->range.maxVer, pWindow->skey, pWindow->ekey);
121

122
    for (int32_t i = 0; i < numOfVgs; i++) {
14,336✔
123
      SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i);
10,914✔
124
      if (pVgInfo == NULL) {
10,914!
125
        continue;
×
126
      }
127

128
      setCheckDownstreamReqInfo(&req, tGenIdPI64(), pVgInfo->taskId, pVgInfo->vgId);
10,914✔
129
      streamTaskAddReqInfo(&pTask->taskCheckInfo, req.reqId, pVgInfo->taskId, pVgInfo->vgId, idstr);
10,914✔
130

131
      stDebug("s-task:%s (vgId:%d) stage:%" PRId64
10,914✔
132
              " check downstream task:0x%x (vgId:%d) (shuffle), idx:%d, QID:0x%" PRIx64,
133
              idstr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, i, req.reqId);
134
      code = streamSendCheckMsg(pTask, &req, pVgInfo->vgId, &pVgInfo->epSet);
10,914✔
135
    }
136
  } else {  // for sink task, set it ready directly.
137
    stDebug("s-task:%s (vgId:%d) set downstream ready, since no downstream", idstr, pTask->info.nodeId);
3,968✔
138
    streamTaskStopMonitorCheckRsp(&pTask->taskCheckInfo, idstr);
3,968✔
139
    processDownstreamReadyRsp(pTask);
3,968✔
140
  }
141

142
  if (code) {
8,095!
143
    stError("s-task:%s failed to send check msg to downstream, code:%s", idstr, tstrerror(code));
×
144
  }
145
}
8,095✔
146

147
void streamTaskProcessCheckMsg(SStreamMeta* pMeta, SStreamTaskCheckReq* pReq, SStreamTaskCheckRsp* pRsp) {
12,319✔
148
  int32_t taskId = pReq->downstreamTaskId;
12,319✔
149

150
  *pRsp = (SStreamTaskCheckRsp){
12,319✔
151
      .reqId = pReq->reqId,
12,319✔
152
      .streamId = pReq->streamId,
12,319✔
153
      .childId = pReq->childId,
12,319✔
154
      .downstreamNodeId = pReq->downstreamNodeId,
12,319✔
155
      .downstreamTaskId = pReq->downstreamTaskId,
12,319✔
156
      .upstreamNodeId = pReq->upstreamNodeId,
12,319✔
157
      .upstreamTaskId = pReq->upstreamTaskId,
12,319✔
158
  };
159

160
  // only the leader node handle the check request
161
  if (pMeta->role == NODE_ROLE_FOLLOWER) {
12,319!
162
    stError(
×
163
        "s-task:0x%x invalid check msg from upstream:0x%x(vgId:%d), vgId:%d is follower, not handle check status msg",
164
        taskId, pReq->upstreamTaskId, pReq->upstreamNodeId, pMeta->vgId);
165
    pRsp->status = TASK_DOWNSTREAM_NOT_LEADER;
×
166
  } else {
167
    SStreamTask* pTask = NULL;
12,319✔
168
    int32_t      code = streamMetaAcquireTask(pMeta, pReq->streamId, taskId, &pTask);
12,319✔
169
    if (pTask != NULL) {
12,320✔
170
      pRsp->status =
12,302✔
171
          streamTaskCheckStatus(pTask, pReq->upstreamTaskId, pReq->upstreamNodeId, pReq->stage, &pRsp->oldStage);
12,302✔
172

173
      SStreamTaskState pState = streamTaskGetStatus(pTask);
12,302✔
174
      stDebug("s-task:%s status:%s, stage:%" PRId64 " recv task check req(QID:0x%" PRIx64
12,302✔
175
              ") task:0x%x (vgId:%d), check_status:%d",
176
              pTask->id.idStr, pState.name, pRsp->oldStage, pRsp->reqId, pRsp->upstreamTaskId, pRsp->upstreamNodeId,
177
              pRsp->status);
178
      streamMetaReleaseTask(pMeta, pTask);
12,302✔
179
    } else {
180
      pRsp->status = TASK_DOWNSTREAM_NOT_READY;
18✔
181
      stDebug("tq recv task check(taskId:0x%" PRIx64 "-0x%x not built yet) req(QID:0x%" PRIx64
18!
182
              ") from task:0x%x (vgId:%d), rsp check_status %d",
183
              pReq->streamId, taskId, pRsp->reqId, pRsp->upstreamTaskId, pRsp->upstreamNodeId, pRsp->status);
184
    }
185
  }
186
}
12,320✔
187

188
int32_t streamTaskProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp) {
12,290✔
189
  int64_t         now = taosGetTimestampMs();
12,290✔
190
  const char*     id = pTask->id.idStr;
12,290✔
191
  STaskCheckInfo* pInfo = &pTask->taskCheckInfo;
12,290✔
192
  int32_t         total = streamTaskGetNumOfDownstream(pTask);
12,290✔
193
  int32_t         left = -1;
12,289✔
194

195
  if (streamTaskShouldStop(pTask)) {
12,289!
196
    stDebug("s-task:%s should stop, do not do check downstream again", id);
×
197
    return TSDB_CODE_SUCCESS;
×
198
  }
199

200
  if (pTask->id.taskId != pRsp->upstreamTaskId) {
12,289!
201
    stError("s-task:%s invalid check downstream rsp, upstream task:0x%x discard", id, pRsp->upstreamTaskId);
×
202
    return TSDB_CODE_INVALID_MSG;
×
203
  }
204

205
  if (pRsp->status == TASK_DOWNSTREAM_READY) {
12,289✔
206
    int32_t code = streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id);
11,537✔
207
    if (code != TSDB_CODE_SUCCESS) {
11,538!
208
      return TSDB_CODE_SUCCESS;
×
209
    }
210

211
    if (left == 0) {
11,538✔
212
      processDownstreamReadyRsp(pTask);  // all downstream tasks are ready, set the complete check downstream flag
4,067✔
213
      streamTaskStopMonitorCheckRsp(pInfo, id);
4,067✔
214
    } else {
215
      stDebug("s-task:%s (vgId:%d) recv check rsp from task:0x%x (vgId:%d) status:%d, total:%d not ready:%d", id,
7,471✔
216
              pRsp->upstreamNodeId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->status, total, left);
217
    }
218
  } else {  // not ready, wait for 100ms and retry
219
    int32_t code = streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id);
752✔
220
    if (code != TSDB_CODE_SUCCESS) {
752✔
221
      return TSDB_CODE_SUCCESS;  // return success in any cases.
2✔
222
    }
223

224
    if (pRsp->status == TASK_UPSTREAM_NEW_STAGE || pRsp->status == TASK_DOWNSTREAM_NOT_LEADER) {
750!
225
      if (pRsp->status == TASK_UPSTREAM_NEW_STAGE) {
×
226
        stError("s-task:%s vgId:%d self vnode-transfer/leader-change/restart detected, old stage:%" PRId64
×
227
                ", current stage:%" PRId64 ", not check wait for downstream task nodeUpdate, and all tasks restart",
228
                id, pRsp->upstreamNodeId, pRsp->oldStage, pTask->pMeta->stage);
229
        code = addIntoNodeUpdateList(pTask, pRsp->upstreamNodeId);
×
230
      } else {
231
        stError(
×
232
            "s-task:%s downstream taskId:0x%x (vgId:%d) not leader, self dispatch epset needs to be updated, not check "
233
            "downstream again, nodeUpdate needed",
234
            id, pRsp->downstreamTaskId, pRsp->downstreamNodeId);
235
        code = addIntoNodeUpdateList(pTask, pRsp->downstreamNodeId);
×
236
      }
237

238
      streamMetaAddFailedTaskSelf(pTask, now);
×
239
    } else {  // TASK_DOWNSTREAM_NOT_READY, rsp-check monitor will retry in 300 ms
240
      stDebug("s-task:%s (vgId:%d) recv check rsp from task:0x%x (vgId:%d) status:%d, total:%d not ready:%d", id,
750✔
241
              pRsp->upstreamNodeId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->status, total, left);
242
    }
243
  }
244

245
  return 0;
12,288✔
246
}
247

248
int32_t streamTaskSendCheckRsp(const SStreamMeta* pMeta, int32_t vgId, SStreamTaskCheckRsp* pRsp,
12,320✔
249
                               SRpcHandleInfo* pRpcInfo, int32_t taskId) {
250
  SEncoder encoder;
251
  int32_t  code = 0;
12,320✔
252
  int32_t  len;
253

254
  tEncodeSize(tEncodeStreamTaskCheckRsp, pRsp, len, code);
12,320!
255
  if (code < 0) {
12,320!
256
    stError("vgId:%d failed to encode task check rsp, s-task:0x%x", pMeta->vgId, taskId);
×
257
    return TSDB_CODE_INVALID_MSG;
×
258
  }
259

260
  void* buf = rpcMallocCont(sizeof(SMsgHead) + len);
12,320✔
261
  if (buf == NULL) {
12,320!
262
    stError("s-task:0x%x vgId:%d failed prepare msg, %s at line:%d code:%s", taskId, pMeta->vgId, __func__, __LINE__,
×
263
            tstrerror(code));
264
    return terrno;
×
265
  }
266

267
  ((SMsgHead*)buf)->vgId = htonl(vgId);
12,320✔
268

269
  void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
12,320✔
270
  tEncoderInit(&encoder, (uint8_t*)abuf, len);
12,320✔
271
  code = tEncodeStreamTaskCheckRsp(&encoder, pRsp);
12,320✔
272
  tEncoderClear(&encoder);
12,320✔
273

274
  SRpcMsg rspMsg = {.code = 0, .pCont = buf, .contLen = sizeof(SMsgHead) + len, .info = *pRpcInfo};
12,320✔
275
  tmsgSendRsp(&rspMsg);
12,320✔
276

277
  code = TMIN(code, 0);
12,320✔
278
  return code;
12,320✔
279
}
280

281
void streamTaskStartMonitorCheckRsp(SStreamTask* pTask) {
4,127✔
282
  int32_t         vgId = pTask->pMeta->vgId;
4,127✔
283
  STaskCheckInfo* pInfo = &pTask->taskCheckInfo;
4,127✔
284

285
  streamMutexLock(&pInfo->checkInfoLock);
4,127✔
286

287
  // drop procedure already started, not start check downstream now
288
  ETaskStatus s = streamTaskGetStatus(pTask).state;
4,127✔
289
  if (s == TASK_STATUS__DROPPING) {
4,127!
290
    stDebug("s-task:%s task not in uninit status, status:%s not start monitor check-rsp", pTask->id.idStr,
×
291
            streamTaskGetStatusStr(s));
292
    streamMutexUnlock(&pInfo->checkInfoLock);
×
293
    return;
×
294
  }
295

296
  int32_t code = streamTaskStartCheckDownstream(pInfo, pTask->id.idStr);
4,127✔
297
  if (code != TSDB_CODE_SUCCESS) {
4,127!
298
    streamMutexUnlock(&pInfo->checkInfoLock);
×
299
    return;
×
300
  }
301

302
  streamTaskInitTaskCheckInfo(pInfo, &pTask->outputInfo, taosGetTimestampMs());
4,127✔
303

304
  int64_t* pTaskRefId = NULL;
4,127✔
305
  code = streamTaskAllocRefId(pTask, &pTaskRefId);
4,127✔
306
  if (code == 0) {
4,127!
307
    streamTmrStart(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, pTaskRefId, streamTimer, &pInfo->checkRspTmr, vgId,
4,127✔
308
                   "check-status-monitor");
309
  }
310

311
  streamMutexUnlock(&pInfo->checkInfoLock);
4,127✔
312
}
313

314
void streamTaskStopMonitorCheckRsp(STaskCheckInfo* pInfo, const char* id) {
8,040✔
315
  streamMutexLock(&pInfo->checkInfoLock);
8,040✔
316
  pInfo->stopCheckProcess = 1;
8,040✔
317
  streamMutexUnlock(&pInfo->checkInfoLock);
8,040✔
318

319
  stDebug("s-task:%s set stop check-rsp monitor flag", id);
8,040✔
320
}
8,040✔
321

322
void streamTaskCleanupCheckInfo(STaskCheckInfo* pInfo) {
32,294✔
323
  taosArrayDestroy(pInfo->pList);
32,294✔
324
  pInfo->pList = NULL;
32,294✔
325

326
  if (pInfo->checkRspTmr != NULL) {
32,294✔
327
    streamTmrStop(pInfo->checkRspTmr);
4,064✔
328
    pInfo->checkRspTmr = NULL;
4,064✔
329
  }
330

331
  streamMutexDestroy(&pInfo->checkInfoLock);
32,294✔
332
}
32,294✔
333

334
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
335
void processDownstreamReadyRsp(SStreamTask* pTask) {
8,035✔
336
  EStreamTaskEvent event = (pTask->info.fillHistory == 0) ? TASK_EVENT_INIT : TASK_EVENT_INIT_SCANHIST;
8,035✔
337
  int32_t          code = streamTaskOnHandleEventSuccess(pTask->status.pSM, event, NULL, NULL);
8,035✔
338
  if (code) {
8,035!
339
    stError("s-task:%s failed to set event succ, code:%s", pTask->id.idStr, tstrerror(code));
×
340
  }
341

342
  int64_t checkTs = pTask->execInfo.checkTs;
8,035✔
343
  int64_t readyTs = pTask->execInfo.readyTs;
8,035✔
344
  code = streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, checkTs, readyTs, true);
8,035✔
345
  if (code) {
8,035✔
346
    stError("s-task:%s failed to record the downstream task status, code:%s", pTask->id.idStr, tstrerror(code));
2!
347
  }
348

349
  if (pTask->status.taskStatus == TASK_STATUS__HALT) {
8,035✔
350
    if (!HAS_RELATED_FILLHISTORY_TASK(pTask) || (pTask->info.fillHistory != 0)) {
1!
351
      stError("s-task:%s status:halt fillhistory:%d not handle the ready rsp", pTask->id.idStr,
×
352
              pTask->info.fillHistory);
353
    }
354

355
    // halt it self for count window stream task until the related fill history task completed.
356
    stDebug("s-task:%s level:%d initial status is %s from mnode, set it to be halt", pTask->id.idStr,
1!
357
            pTask->info.taskLevel, streamTaskGetStatusStr(pTask->status.taskStatus));
358
    code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_HALT);
1✔
359
    if (code != 0) {  // todo: handle error
1!
360
      stError("s-task:%s failed to handle halt event, code:%s", pTask->id.idStr, tstrerror(code));
×
361
    }
362
  }
363

364
  // start the related fill-history task, when current task is ready
365
  // not invoke in success callback due to the deadlock.
366
  // todo: let's retry
367
  if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
8,035✔
368
    stDebug("s-task:%s try to launch related fill-history task", pTask->id.idStr);
2,955✔
369
    code = streamLaunchFillHistoryTask(pTask);
2,955✔
370
    if (code) {
2,955!
371
      stError("s-task:%s failed to launch history task, code:%s", pTask->id.idStr, tstrerror(code));
×
372
    }
373
  }
374
}
8,035✔
375

376
int32_t addIntoNodeUpdateList(SStreamTask* pTask, int32_t nodeId) {
×
377
  int32_t vgId = pTask->pMeta->vgId;
×
378
  int32_t code = 0;
×
379
  ;
380
  bool existed = false;
×
381

382
  streamMutexLock(&pTask->lock);
×
383

384
  int32_t num = taosArrayGetSize(pTask->outputInfo.pNodeEpsetUpdateList);
×
385
  for (int i = 0; i < num; ++i) {
×
386
    SDownstreamTaskEpset* p = taosArrayGet(pTask->outputInfo.pNodeEpsetUpdateList, i);
×
387
    if (p == NULL) {
×
388
      continue;
×
389
    }
390

391
    if (p->nodeId == nodeId) {
×
392
      existed = true;
×
393
      break;
×
394
    }
395
  }
396

397
  if (!existed) {
×
398
    SDownstreamTaskEpset t = {.nodeId = nodeId};
×
399

400
    void* p = taosArrayPush(pTask->outputInfo.pNodeEpsetUpdateList, &t);
×
401
    if (p == NULL) {
×
402
      code = terrno;
×
403
      stError("s-task:%s vgId:%d failed to update epset, code:%s", pTask->id.idStr, vgId, tstrerror(code));
×
404
    } else {
405
      stInfo("s-task:%s vgId:%d downstream nodeId:%d needs to be updated, total needs updated:%d", pTask->id.idStr,
×
406
             vgId, t.nodeId, (num + 1));
407
    }
408
  }
409

410
  streamMutexUnlock(&pTask->lock);
×
411
  return code;
×
412
}
413

414
void streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOutputInfo, int64_t startTs) {
4,127✔
415
  taosArrayClear(pInfo->pList);
4,127✔
416

417
  if (pOutputInfo->type == TASK_OUTPUT__FIXED_DISPATCH) {
4,127✔
418
    pInfo->notReadyTasks = 1;
705✔
419
  } else if (pOutputInfo->type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
3,422!
420
    pInfo->notReadyTasks = taosArrayGetSize(pOutputInfo->shuffleDispatcher.dbInfo.pVgroupInfos);
3,422✔
421
  }
422

423
  pInfo->startTs = startTs;
4,127✔
424
  pInfo->timeoutStartTs = startTs;
4,127✔
425
  pInfo->stopCheckProcess = 0;
4,127✔
426
}
4,127✔
427

428
void findCheckRspStatus(STaskCheckInfo* pInfo, int32_t taskId, SDownstreamStatusInfo** pStatusInfo) {
24,658✔
429
  if (pStatusInfo == NULL) {
24,658!
430
    return;
×
431
  }
432

433
  *pStatusInfo = NULL;
24,658✔
434
  for (int32_t j = 0; j < taosArrayGetSize(pInfo->pList); ++j) {
80,815✔
435
    SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, j);
56,157✔
436
    if (p == NULL) {
56,157!
437
      continue;
×
438
    }
439

440
    if (p->taskId == taskId) {
56,157✔
441
      *pStatusInfo = p;
13,037✔
442
    }
443
  }
444
}
445

446
int32_t streamTaskUpdateCheckInfo(STaskCheckInfo* pInfo, int32_t taskId, int32_t status, int64_t rspTs, int64_t reqId,
12,290✔
447
                                  int32_t* pNotReady, const char* id) {
448
  SDownstreamStatusInfo* p = NULL;
12,290✔
449

450
  streamMutexLock(&pInfo->checkInfoLock);
12,290✔
451
  findCheckRspStatus(pInfo, taskId, &p);
12,290✔
452
  if (p != NULL) {
12,290✔
453
    if (reqId != p->reqId) {
12,288!
454
      stError("s-task:%sQID:0x%" PRIx64 " expected:0x%" PRIx64
×
455
              " expired check-rsp recv from downstream task:0x%x, discarded",
456
              id, reqId, p->reqId, taskId);
457
      streamMutexUnlock(&pInfo->checkInfoLock);
×
458
      return TSDB_CODE_FAILED;
×
459
    }
460

461
    // subtract one not-ready-task, since it is ready now
462
    if ((p->status != TASK_DOWNSTREAM_READY) && (status == TASK_DOWNSTREAM_READY)) {
12,288!
463
      *pNotReady = atomic_sub_fetch_32(&pInfo->notReadyTasks, 1);
11,538✔
464
    } else {
465
      *pNotReady = pInfo->notReadyTasks;
750✔
466
    }
467

468
    p->status = status;
12,288✔
469
    p->rspTs = rspTs;
12,288✔
470

471
    streamMutexUnlock(&pInfo->checkInfoLock);
12,288✔
472
    return TSDB_CODE_SUCCESS;
12,288✔
473
  }
474

475
  streamMutexUnlock(&pInfo->checkInfoLock);
2✔
476
  stError("s-task:%s unexpected check rsp msg, invalid downstream task:0x%x,QID:%" PRIx64 " discarded", id, taskId,
2!
477
          reqId);
478
  return TSDB_CODE_FAILED;
2✔
479
}
480

481
int32_t streamTaskStartCheckDownstream(STaskCheckInfo* pInfo, const char* id) {
4,127✔
482
  if (pInfo->inCheckProcess == 0) {
4,127!
483
    pInfo->inCheckProcess = 1;
4,127✔
484
  } else {
485
    stError("s-task:%s already in check procedure, checkTs:%" PRId64 ", start monitor check rsp failed", id,
×
486
            pInfo->startTs);
487
    pInfo->stopCheckProcess = 0;  // disable auto stop of check process
×
488
    return TSDB_CODE_FAILED;
×
489
  }
490

491
  stDebug("s-task:%s set the in check-rsp flag", id);
4,127✔
492
  return TSDB_CODE_SUCCESS;
4,127✔
493
}
494

495
void streamTaskCompleteCheckRsp(STaskCheckInfo* pInfo, bool lock, const char* id) {
3,824✔
496
  if (lock) {
3,824✔
497
    streamMutexLock(&pInfo->checkInfoLock);
2,406✔
498
  }
499

500
  if (pInfo->inCheckProcess) {
3,824!
501
    int64_t el = (pInfo->startTs != 0) ? (taosGetTimestampMs() - pInfo->startTs) : 0;
7,648!
502
    stDebug("s-task:%s clear the in check-rsp flag, set the check-rsp done, elapsed time:%" PRId64 " ms", id, el);
3,824✔
503

504
    pInfo->startTs = 0;
3,824✔
505
    pInfo->timeoutStartTs = 0;
3,824✔
506
    pInfo->notReadyTasks = 0;
3,824✔
507
    pInfo->inCheckProcess = 0;
3,824✔
508
    pInfo->stopCheckProcess = 0;
3,824✔
509

510
    pInfo->notReadyRetryCount = 0;
3,824✔
511
    pInfo->timeoutRetryCount = 0;
3,824✔
512

513
    taosArrayClear(pInfo->pList);
3,824✔
514
  } else {
515
    stDebug("s-task:%s already not in check-rsp procedure", id);
×
516
  }
517

518
  if (lock) {
3,824✔
519
    streamMutexUnlock(&pInfo->checkInfoLock);
2,406✔
520
  }
521
}
3,824✔
522

523
// todo: retry until success
524
void streamTaskAddReqInfo(STaskCheckInfo* pInfo, int64_t reqId, int32_t taskId, int32_t vgId, const char* id) {
11,619✔
525
  SDownstreamStatusInfo info = {.taskId = taskId, .status = -1, .vgId = vgId, .reqId = reqId, .rspTs = 0};
11,619✔
526
  streamMutexLock(&pInfo->checkInfoLock);
11,619✔
527

528
  SDownstreamStatusInfo* p = NULL;
11,619✔
529
  findCheckRspStatus(pInfo, taskId, &p);
11,619✔
530
  if (p != NULL) {
11,619!
531
    stDebug("s-task:%s check info to task:0x%x already sent", id, taskId);
×
532
    streamMutexUnlock(&pInfo->checkInfoLock);
×
533
    return;
×
534
  }
535

536
  void* px = taosArrayPush(pInfo->pList, &info);
23,238✔
537
  if (px == NULL) {
538
    // todo: retry
539
  }
540

541
  streamMutexUnlock(&pInfo->checkInfoLock);
11,619✔
542
}
543

544
int32_t doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p) {
749✔
545
  const char* id = pTask->id.idStr;
749✔
546
  int32_t     code = 0;
749✔
547

548
  SStreamTaskCheckReq req = {
749✔
549
      .streamId = pTask->id.streamId,
749✔
550
      .upstreamTaskId = pTask->id.taskId,
749✔
551
      .upstreamNodeId = pTask->info.nodeId,
749✔
552
      .childId = pTask->info.selfChildId,
749✔
553
      .stage = pTask->pMeta->stage,
749✔
554
  };
555

556
  // update the reqId for the new check msg
557
  p->reqId = tGenIdPI64();
749✔
558

559
  STaskOutputInfo* pOutputInfo = &pTask->outputInfo;
749✔
560
  if (pOutputInfo->type == TASK_OUTPUT__FIXED_DISPATCH) {
749✔
561
    STaskDispatcherFixed* pDispatch = &pOutputInfo->fixedDispatcher;
464✔
562
    setCheckDownstreamReqInfo(&req, p->reqId, pDispatch->taskId, pDispatch->nodeId);
464✔
563

564
    stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " re-send check downstream task:0x%x(vgId:%d) QID:0x%" PRIx64, id,
464✔
565
            pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, req.reqId);
566

567
    code = streamSendCheckMsg(pTask, &req, pOutputInfo->fixedDispatcher.nodeId, &pOutputInfo->fixedDispatcher.epSet);
464✔
568
  } else if (pOutputInfo->type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
285!
569
    SArray* vgInfo = pOutputInfo->shuffleDispatcher.dbInfo.pVgroupInfos;
285✔
570
    int32_t numOfVgs = taosArrayGetSize(vgInfo);
285✔
571

572
    for (int32_t i = 0; i < numOfVgs; i++) {
466!
573
      SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i);
466✔
574
      if (pVgInfo == NULL) {
466!
575
        continue;
×
576
      }
577

578
      if (p->taskId == pVgInfo->taskId) {
466✔
579
        setCheckDownstreamReqInfo(&req, p->reqId, pVgInfo->taskId, pVgInfo->vgId);
285✔
580

581
        stDebug("s-task:%s (vgId:%d) stage:%" PRId64
285✔
582
                " re-send check downstream task:0x%x(vgId:%d) (shuffle), idx:%d QID:0x%" PRIx64,
583
                id, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, i, p->reqId);
584
        code = streamSendCheckMsg(pTask, &req, pVgInfo->vgId, &pVgInfo->epSet);
285✔
585
        break;
285✔
586
      }
587
    }
588
  }
589

590
  if (code) {
749!
591
    stError("s-task:%s failed to send check msg to downstream, code:%s", pTask->id.idStr, tstrerror(code));
×
592
  }
593
  return code;
749✔
594
}
595

596
void getCheckRspStatus(STaskCheckInfo* pInfo, int64_t el, int32_t* numOfReady, int32_t* numOfFault,
1,361✔
597
                       int32_t* numOfNotRsp, SArray* pTimeoutList, SArray* pNotReadyList, const char* id) {
598
  for (int32_t i = 0; i < taosArrayGetSize(pInfo->pList); ++i) {
4,308✔
599
    SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, i);
2,947✔
600
    if (p == NULL) {
2,947!
601
      continue;
×
602
    }
603

604
    if (p->status == TASK_DOWNSTREAM_READY) {
2,947✔
605
      (*numOfReady) += 1;
585✔
606
    } else if (p->status == TASK_UPSTREAM_NEW_STAGE || p->status == TASK_DOWNSTREAM_NOT_LEADER) {
2,362!
607
      stDebug("s-task:%s recv status:NEW_STAGE/NOT_LEADER from downstream, task:0x%x, quit from check downstream", id,
×
608
              p->taskId);
609
      (*numOfFault) += 1;
×
610
    } else {                                 // TASK_DOWNSTREAM_NOT_READY
611
      if (p->rspTs == 0) {                   // not response yet
2,362✔
612
        if (el >= CHECK_NOT_RSP_DURATION) {  // not receive info for 10 sec.
1,614✔
613
          void* px = taosArrayPush(pTimeoutList, &p->taskId);
1✔
614
          if (px == NULL) {
1!
615
            stError("s-task:%s failed to record time out task:0x%x", id, p->taskId);
×
616
          }
617
        } else {                // el < CHECK_NOT_RSP_DURATION
618
          (*numOfNotRsp) += 1;  // do nothing and continue waiting for their rsp
1,613✔
619
        }
620
      } else {
621
        void* px = taosArrayPush(pNotReadyList, &p->taskId);
748✔
622
        if (px == NULL) {
748!
623
          stError("s-task:%s failed to record not ready task:0x%x", id, p->taskId);
×
624
        }
625
      }
626
    }
627
  }
628
}
1,361✔
629

630
void setCheckDownstreamReqInfo(SStreamTaskCheckReq* pReq, int64_t reqId, int32_t dstTaskId, int32_t dstNodeId) {
12,368✔
631
  pReq->reqId = reqId;
12,368✔
632
  pReq->downstreamTaskId = dstTaskId;
12,368✔
633
  pReq->downstreamNodeId = dstNodeId;
12,368✔
634
}
12,368✔
635

636
void handleTimeoutDownstreamTasks(SStreamTask* pTask, SArray* pTimeoutList) {
1✔
637
  STaskCheckInfo* pInfo = &pTask->taskCheckInfo;
1✔
638
  const char*     id = pTask->id.idStr;
1✔
639
  int32_t         vgId = pTask->pMeta->vgId;
1✔
640
  int32_t         numOfTimeout = taosArrayGetSize(pTimeoutList);
1✔
641
  int32_t         code = 0;
1✔
642

643
  pInfo->timeoutStartTs = taosGetTimestampMs();
1✔
644
  for (int32_t i = 0; i < numOfTimeout; ++i) {
2✔
645
    int32_t* px = taosArrayGet(pTimeoutList, i);
1✔
646
    if (px == NULL) {
1!
647
      continue;
×
648
    }
649

650
    int32_t                taskId = *px;
1✔
651
    SDownstreamStatusInfo* p = NULL;
1✔
652
    findCheckRspStatus(pInfo, taskId, &p);
1✔
653

654
    if (p != NULL) {
1!
655
      if (p->status != -1 || p->rspTs != 0) {
1!
656
        stError("s-task:%s invalid rsp record entry, index:%d, status:%d, rspTs:%" PRId64, id, i, p->status, p->rspTs);
×
657
        continue;
×
658
      }
659
      code = doSendCheckMsg(pTask, p);
1✔
660
    }
661
  }
662

663
  pInfo->timeoutRetryCount += 1;
1✔
664

665
  // timeout more than 100 sec, add into node update list
666
  if (pInfo->timeoutRetryCount > 10) {
1!
667
    pInfo->timeoutRetryCount = 0;
×
668

669
    for (int32_t i = 0; i < numOfTimeout; ++i) {
×
670
      int32_t* pTaskId = taosArrayGet(pTimeoutList, i);
×
671
      if (pTaskId == NULL) {
×
672
        continue;
×
673
      }
674

675
      SDownstreamStatusInfo* p = NULL;
×
676
      findCheckRspStatus(pInfo, *pTaskId, &p);
×
677
      if (p != NULL) {
×
678
        code = addIntoNodeUpdateList(pTask, p->vgId);
×
679
        stDebug("s-task:%s vgId:%d downstream task:0x%x (vgId:%d) timeout more than 100sec, add into nodeUpate list",
×
680
                id, vgId, p->taskId, p->vgId);
681
      }
682
    }
683

684
    stDebug("s-task:%s vgId:%d %d downstream task(s) all add into nodeUpate list", id, vgId, numOfTimeout);
×
685
  } else {
686
    stDebug("s-task:%s vgId:%d %d downstream task(s) timeout, send check msg again, retry:%d start time:%" PRId64, id,
1!
687
            vgId, numOfTimeout, pInfo->timeoutRetryCount, pInfo->timeoutStartTs);
688
  }
689
}
1✔
690

691
void handleNotReadyDownstreamTask(SStreamTask* pTask, SArray* pNotReadyList) {
638✔
692
  STaskCheckInfo* pInfo = &pTask->taskCheckInfo;
638✔
693
  const char*     id = pTask->id.idStr;
638✔
694
  int32_t         vgId = pTask->pMeta->vgId;
638✔
695
  int32_t         numOfNotReady = taosArrayGetSize(pNotReadyList);
638✔
696

697
  // reset the info, and send the check msg to failure downstream again
698
  for (int32_t i = 0; i < numOfNotReady; ++i) {
1,386✔
699
    int32_t* pTaskId = taosArrayGet(pNotReadyList, i);
748✔
700
    if (pTaskId == NULL) {
748!
701
      continue;
×
702
    }
703

704
    SDownstreamStatusInfo* p = NULL;
748✔
705
    findCheckRspStatus(pInfo, *pTaskId, &p);
748✔
706
    if (p != NULL) {
748!
707
      p->rspTs = 0;
748✔
708
      p->status = -1;
748✔
709
      int32_t code = doSendCheckMsg(pTask, p);
748✔
710
    }
711
  }
712

713
  pInfo->notReadyRetryCount += 1;
638✔
714
  stDebug("s-task:%s vgId:%d %d downstream task(s) not ready, send check msg again, retry:%d start time:%" PRId64, id,
638✔
715
          vgId, numOfNotReady, pInfo->notReadyRetryCount, pInfo->startTs);
716
}
638✔
717

718
// the action of add status may incur the restart procedure, which should NEVER be executed in the timer thread.
719
// The restart of all tasks requires that all tasks should not have active timer for now. Therefore, the execution
720
// of restart in timer thread will result in a dead lock.
721
int32_t addDownstreamFailedStatusResultAsync(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId) {
×
722
  return streamTaskSchedTask(pMsgCb, vgId, streamId, taskId, STREAM_EXEC_T_ADD_FAILED_TASK);
×
723
}
724

725
static void doCleanup(SStreamTask* pTask, SArray* pNotReadyList, SArray* pTimeoutList, void* param) {
5,185✔
726
  streamMetaReleaseTask(pTask->pMeta, pTask);
5,185✔
727

728
  taosArrayDestroy(pNotReadyList);
5,185✔
729
  taosArrayDestroy(pTimeoutList);
5,185✔
730
  streamTaskFreeRefId(param);
5,185✔
731
}
5,185✔
732

733
// this function is executed in timer thread
734
void rspMonitorFn(void* param, void* tmrId) {
5,186✔
735
  int32_t         numOfReady = 0;
5,186✔
736
  int32_t         numOfFault = 0;
5,186✔
737
  int32_t         numOfNotRsp = 0;
5,186✔
738
  int32_t         numOfNotReady = 0;
5,186✔
739
  int32_t         numOfTimeout = 0;
5,186✔
740
  int64_t         taskRefId = *(int64_t*)param;
5,186✔
741
  int64_t         now = taosGetTimestampMs();
5,186✔
742
  SArray*         pNotReadyList = NULL;
5,186✔
743
  SArray*         pTimeoutList = NULL;
5,186✔
744
  SStreamMeta*    pMeta = NULL;
5,186✔
745
  STaskCheckInfo* pInfo = NULL;
5,186✔
746
  int32_t         vgId = -1;
5,186✔
747
  int64_t         timeoutDuration = 0;
5,186✔
748
  const char*     id = NULL;
5,186✔
749
  int32_t         total = 0;
5,186✔
750

751
  SStreamTask* pTask = taosAcquireRef(streamTaskRefPool, taskRefId);
5,186✔
752
  if (pTask == NULL) {
5,186✔
753
    stError("invalid task rid:%" PRId64 " failed to acquired stream-task at %s", taskRefId, __func__);
1!
754
    streamTaskFreeRefId(param);
1✔
755
    return;
3,825✔
756
  }
757

758
  pMeta = pTask->pMeta;
5,185✔
759
  pInfo = &pTask->taskCheckInfo;
5,185✔
760
  vgId = pTask->pMeta->vgId;
5,185✔
761
  timeoutDuration = now - pInfo->timeoutStartTs;
5,185✔
762
  id = pTask->id.idStr;
5,185✔
763
  total = (int32_t) taosArrayGetSize(pInfo->pList);
5,185✔
764

765
  stDebug("s-task:%s start to do check-downstream-rsp check in tmr", id);
5,185✔
766

767
  streamMutexLock(&pTask->lock);
5,185✔
768
  SStreamTaskState state = streamTaskGetStatus(pTask);
5,185✔
769
  streamMutexUnlock(&pTask->lock);
5,185✔
770

771
  if (state.state == TASK_STATUS__STOP) {
5,185!
772
    stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr", id, state.name, vgId);
×
773
    streamTaskCompleteCheckRsp(pInfo, true, id);
×
774

775
    // not record the failure of the current task if try to close current vnode
776
    // otherwise, the put of message operation may incur invalid read of message queue.
777
    if (!pMeta->closeFlag) {
×
778
      int32_t code = addDownstreamFailedStatusResultAsync(pTask->pMsgCb, vgId, pTask->id.streamId, pTask->id.taskId);
×
779
      if (code) {
×
780
        stError("s-task:%s failed to create async record start failed task, code:%s", id, tstrerror(code));
×
781
      }
782
    }
783

784
    doCleanup(pTask, pNotReadyList, pTimeoutList, param);
×
785
    return;
×
786
  }
787

788
  if (state.state == TASK_STATUS__DROPPING || state.state == TASK_STATUS__READY) {
5,185!
789
    stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr", id, state.name, vgId);
2,406✔
790

791
    streamTaskCompleteCheckRsp(pInfo, true, id);
2,406✔
792
    doCleanup(pTask, pNotReadyList, pTimeoutList, param);
2,406✔
793
    return;
2,406✔
794
  }
795

796
  streamMutexLock(&pInfo->checkInfoLock);
2,779✔
797
  if (pInfo->notReadyTasks == 0) {
2,779✔
798
    stDebug("s-task:%s status:%s vgId:%d all downstream ready, quit from monitor rsp tmr", id, state.name, vgId);
1,418✔
799

800
    streamTaskCompleteCheckRsp(pInfo, false, id);
1,418✔
801
    streamMutexUnlock(&pInfo->checkInfoLock);
1,418✔
802
    doCleanup(pTask, pNotReadyList, pTimeoutList, param);
1,418✔
803
    return;
1,418✔
804
  }
805

806
  pNotReadyList = taosArrayInit(4, sizeof(int64_t));
1,361✔
807
  pTimeoutList = taosArrayInit(4, sizeof(int64_t));
1,361✔
808

809
  if (state.state == TASK_STATUS__UNINIT) {
1,361!
810
    getCheckRspStatus(pInfo, timeoutDuration, &numOfReady, &numOfFault, &numOfNotRsp, pTimeoutList, pNotReadyList, id);
1,361✔
811

812
    numOfNotReady = (int32_t)taosArrayGetSize(pNotReadyList);
1,361✔
813
    numOfTimeout = (int32_t)taosArrayGetSize(pTimeoutList);
1,361✔
814

815
    // fault tasks detected, not try anymore
816
    bool jumpOut = false;
1,361✔
817
    if ((numOfReady + numOfFault + numOfNotReady + numOfTimeout + numOfNotRsp) != total) {
1,361!
818
      stError(
×
819
          "s-task:%s vgId:%d internal error in handling the check downstream procedure, rsp number is inconsistent, "
820
          "stop rspMonitor tmr, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d",
821
          id, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady);
822
      jumpOut = true;
×
823
    }
824

825
    if (numOfFault > 0) {
1,361!
826
      stDebug(
×
827
          "s-task:%s status:%s vgId:%d all rsp. quit from monitor rsp tmr, since vnode-transfer/leader-change/restart "
828
          "detected, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d",
829
          id, state.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady);
830
      jumpOut = true;
×
831
    }
832

833
    if (jumpOut) {
1,361!
834
      streamTaskCompleteCheckRsp(pInfo, false, id);
×
835
      streamMutexUnlock(&pInfo->checkInfoLock);
×
836
      doCleanup(pTask, pNotReadyList, pTimeoutList, param);
×
837
      return;
×
838
    }
839
  } else {  // unexpected status
840
    stError("s-task:%s unexpected task status:%s during waiting for check rsp", id, state.name);
×
841
  }
842

843
  // checking of downstream tasks has been stopped by other threads
844
  if (pInfo->stopCheckProcess == 1) {
1,361!
845
    stDebug(
×
846
        "s-task:%s status:%s vgId:%d stopped by other threads to check downstream process, total:%d, notRsp:%d, "
847
        "notReady:%d, fault:%d, timeout:%d, ready:%d",
848
        id, state.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady);
849

850
    streamTaskCompleteCheckRsp(pInfo, false, id);
×
851
    streamMutexUnlock(&pInfo->checkInfoLock);
×
852

853
    int32_t code = addDownstreamFailedStatusResultAsync(pTask->pMsgCb, vgId, pTask->id.streamId, pTask->id.taskId);
×
854
    if (code) {
×
855
      stError("s-task:%s failed to create async record start failed task, code:%s", id, tstrerror(code));
×
856
    }
857

858
    doCleanup(pTask, pNotReadyList, pTimeoutList, param);
×
859
    return;
×
860
  }
861

862
  if (numOfNotReady > 0) {  // check to make sure not in recheck timer
1,361✔
863
    handleNotReadyDownstreamTask(pTask, pNotReadyList);
638✔
864
  }
865

866
  if (numOfTimeout > 0) {
1,361✔
867
    handleTimeoutDownstreamTasks(pTask, pTimeoutList);
1✔
868
  }
869

870
  streamTmrStart(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, param, streamTimer, &pInfo->checkRspTmr, vgId,
1,361✔
871
                 "check-status-monitor");
872
  streamMutexUnlock(&pInfo->checkInfoLock);
1,361✔
873

874
  stDebug(
1,361✔
875
      "s-task:%s vgId:%d continue checking rsp in 300ms, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, "
876
      "ready:%d",
877
      id, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady);
878
  doCleanup(pTask, pNotReadyList, pTimeoutList, NULL);
1,361✔
879
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc