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

taosdata / TDengine / #3593

24 Jan 2025 08:57AM UTC coverage: 63.239% (-0.3%) from 63.546%
#3593

push

travis-ci

web-flow
Merge pull request #29638 from taosdata/docs/TS-5846-3.0

enh: TDengine modify taosBenchmark new query rule cases and add doc

140619 of 285630 branches covered (49.23%)

Branch coverage included in aggregate %.

218877 of 282844 relevant lines covered (77.38%)

19647377.39 hits per line

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

72.55
/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 60 * 1000  // 60 sec
22

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

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

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

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

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

70
  if (pInfo->stage != stage) {
22,335✔
71
    return TASK_UPSTREAM_NEW_STAGE;
63✔
72
  } else if (pTask->status.downstreamReady != 1) {
22,272✔
73
    stDebug("s-task:%s vgId:%d leader:%d, downstream not ready", id, vgId, (pTask->pMeta->role == NODE_ROLE_LEADER));
1,933✔
74
    return TASK_DOWNSTREAM_NOT_READY;
1,933✔
75
  } else {
76
    return TASK_DOWNSTREAM_READY;
20,339✔
77
  }
78
}
79

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

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

95
  // serialize streamProcessScanHistoryFinishRsp
96
  if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
14,387✔
97
    streamTaskStartMonitorCheckRsp(pTask);
991✔
98

99
    STaskDispatcherFixed* pDispatch = &pTask->outputInfo.fixedDispatcher;
991✔
100

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

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

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

112
  } else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
13,396✔
113
    streamTaskStartMonitorCheckRsp(pTask);
6,260✔
114

115
    SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
6,260✔
116

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

121
    for (int32_t i = 0; i < numOfVgs; i++) {
25,815✔
122
      SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i);
19,555✔
123
      if (pVgInfo == NULL) {
19,555!
124
        continue;
×
125
      }
126

127
      setCheckDownstreamReqInfo(&req, tGenIdPI64(), pVgInfo->taskId, pVgInfo->vgId);
19,555✔
128
      streamTaskAddReqInfo(&pTask->taskCheckInfo, req.reqId, pVgInfo->taskId, pVgInfo->vgId, idstr);
19,554✔
129

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

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

146
void streamTaskProcessCheckMsg(SStreamMeta* pMeta, SStreamTaskCheckReq* pReq, SStreamTaskCheckRsp* pRsp) {
22,367✔
147
  int32_t taskId = pReq->downstreamTaskId;
22,367✔
148

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

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

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

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

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

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

204
  if (pRsp->status == TASK_DOWNSTREAM_READY) {
22,572✔
205
    int32_t code = streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id);
20,330✔
206
    if (code != TSDB_CODE_SUCCESS) {
20,367!
207
      return TSDB_CODE_SUCCESS;
×
208
    }
209

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

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

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

244
  return 0;
22,606✔
245
}
246

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

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

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

266
  ((SMsgHead*)buf)->vgId = htonl(vgId);
22,378✔
267

268
  void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
22,378✔
269
  tEncoderInit(&encoder, (uint8_t*)abuf, len);
22,378✔
270
  code = tEncodeStreamTaskCheckRsp(&encoder, pRsp);
22,360✔
271
  tEncoderClear(&encoder);
22,366✔
272

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

276
  code = TMIN(code, 0);
22,382✔
277
  return code;
22,382✔
278
}
279

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

284
  streamMutexLock(&pInfo->checkInfoLock);
7,249✔
285

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

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

301
  streamTaskInitTaskCheckInfo(pInfo, &pTask->outputInfo, taosGetTimestampMs());
7,251✔
302

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

310
  streamMutexUnlock(&pInfo->checkInfoLock);
7,251✔
311
}
312

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

318
  stDebug("s-task:%s set stop check-rsp monitor flag", id);
14,438✔
319
}
14,438✔
320

321
void streamTaskCleanupCheckInfo(STaskCheckInfo* pInfo) {
62,758✔
322
  taosArrayDestroy(pInfo->pList);
62,758✔
323
  pInfo->pList = NULL;
62,763✔
324

325
  if (pInfo->checkRspTmr != NULL) {
62,763✔
326
    streamTmrStop(pInfo->checkRspTmr);
7,123✔
327
    pInfo->checkRspTmr = NULL;
7,123✔
328
  }
329

330
  streamMutexDestroy(&pInfo->checkInfoLock);
62,763✔
331
}
62,760✔
332

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

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

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

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

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

375
int32_t streamTaskAddIntoNodeUpdateList(SStreamTask* pTask, int32_t nodeId) {
226✔
376
  int32_t vgId = pTask->pMeta->vgId;
226✔
377
  int32_t code = 0;
226✔
378
  bool    existed = false;
226✔
379

380
  streamMutexLock(&pTask->lock);
226✔
381

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

389
    if (p->nodeId == nodeId) {
164!
390
      existed = true;
164✔
391
      break;
164✔
392
    }
393
  }
394

395
  if (!existed) {
226✔
396
    SDownstreamTaskEpset t = {.nodeId = nodeId};
62✔
397

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

408
  streamMutexUnlock(&pTask->lock);
226✔
409
  return code;
226✔
410
}
411

412
void streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOutputInfo, int64_t startTs) {
7,250✔
413
  taosArrayClear(pInfo->pList);
7,250✔
414

415
  if (pOutputInfo->type == TASK_OUTPUT__FIXED_DISPATCH) {
7,250✔
416
    pInfo->notReadyTasks = 1;
990✔
417
  } else if (pOutputInfo->type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
6,260!
418
    pInfo->notReadyTasks = taosArrayGetSize(pOutputInfo->shuffleDispatcher.dbInfo.pVgroupInfos);
6,260✔
419
  }
420

421
  pInfo->startTs = startTs;
7,249✔
422
  pInfo->timeoutStartTs = startTs;
7,249✔
423
  pInfo->stopCheckProcess = 0;
7,249✔
424
}
7,249✔
425

426
void findCheckRspStatus(STaskCheckInfo* pInfo, int32_t taskId, SDownstreamStatusInfo** pStatusInfo) {
45,315✔
427
  if (pStatusInfo == NULL) {
45,315!
428
    return;
×
429
  }
430

431
  *pStatusInfo = NULL;
45,315✔
432
  for (int32_t j = 0; j < taosArrayGetSize(pInfo->pList); ++j) {
143,407✔
433
    SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, j);
98,093✔
434
    if (p == NULL) {
98,092!
435
      continue;
×
436
    }
437

438
    if (p->taskId == taskId) {
98,092✔
439
      *pStatusInfo = p;
24,759✔
440
    }
441
  }
442
}
443

444
int32_t streamTaskUpdateCheckInfo(STaskCheckInfo* pInfo, int32_t taskId, int32_t status, int64_t rspTs, int64_t reqId,
22,568✔
445
                                  int32_t* pNotReady, const char* id) {
446
  SDownstreamStatusInfo* p = NULL;
22,568✔
447

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

459
    // subtract one not-ready-task, since it is ready now
460
    if ((p->status != TASK_DOWNSTREAM_READY) && (status == TASK_DOWNSTREAM_READY)) {
22,593!
461
      *pNotReady = atomic_sub_fetch_32(&pInfo->notReadyTasks, 1);
20,356✔
462
    } else {
463
      *pNotReady = pInfo->notReadyTasks;
2,237✔
464
    }
465

466
    p->status = status;
22,605✔
467
    p->rspTs = rspTs;
22,605✔
468

469
    streamMutexUnlock(&pInfo->checkInfoLock);
22,605✔
470
    return TSDB_CODE_SUCCESS;
22,607✔
471
  }
472

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

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

489
  stDebug("s-task:%s set the in check-rsp flag", id);
7,251✔
490
  return TSDB_CODE_SUCCESS;
7,251✔
491
}
492

493
void streamTaskCompleteCheckRsp(STaskCheckInfo* pInfo, bool lock, const char* id) {
6,844✔
494
  if (lock) {
6,844✔
495
    streamMutexLock(&pInfo->checkInfoLock);
3,867✔
496
  }
497

498
  if (pInfo->inCheckProcess) {
6,844!
499
    int64_t el = (pInfo->startTs != 0) ? (taosGetTimestampMs() - pInfo->startTs) : 0;
13,688!
500
    stDebug("s-task:%s clear the in check-rsp flag, set the check-rsp done, elapsed time:%" PRId64 " ms", id, el);
6,844✔
501

502
    pInfo->startTs = 0;
6,844✔
503
    pInfo->timeoutStartTs = 0;
6,844✔
504
    pInfo->notReadyTasks = 0;
6,844✔
505
    pInfo->inCheckProcess = 0;
6,844✔
506
    pInfo->stopCheckProcess = 0;
6,844✔
507

508
    pInfo->notReadyRetryCount = 0;
6,844✔
509
    pInfo->timeoutRetryCount = 0;
6,844✔
510

511
    taosArrayClear(pInfo->pList);
6,844✔
512
  } else {
513
    stDebug("s-task:%s already not in check-rsp procedure", id);
×
514
  }
515

516
  if (lock) {
6,844✔
517
    streamMutexUnlock(&pInfo->checkInfoLock);
3,867✔
518
  }
519
}
6,844✔
520

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

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

534
  void* px = taosArrayPush(pInfo->pList, &info);
41,090✔
535
  if (px == NULL) {
536
    // todo: retry
537
  }
538

539
  streamMutexUnlock(&pInfo->checkInfoLock);
20,545✔
540
}
541

542
int32_t doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p) {
2,162✔
543
  const char* id = pTask->id.idStr;
2,162✔
544
  int32_t     code = 0;
2,162✔
545

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

554
  // update the reqId for the new check msg
555
  p->reqId = tGenIdPI64();
2,162✔
556

557
  STaskOutputInfo* pOutputInfo = &pTask->outputInfo;
2,162✔
558
  if (pOutputInfo->type == TASK_OUTPUT__FIXED_DISPATCH) {
2,162✔
559
    STaskDispatcherFixed* pDispatch = &pOutputInfo->fixedDispatcher;
1,012✔
560
    setCheckDownstreamReqInfo(&req, p->reqId, pDispatch->taskId, pDispatch->nodeId);
1,012✔
561

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

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

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

576
      if (p->taskId == pVgInfo->taskId) {
2,138✔
577
        setCheckDownstreamReqInfo(&req, p->reqId, pVgInfo->taskId, pVgInfo->vgId);
1,150✔
578

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

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

594
void getCheckRspStatus(STaskCheckInfo* pInfo, int64_t el, int32_t* numOfReady, int32_t* numOfFault,
2,722✔
595
                       int32_t* numOfNotRsp, SArray* pTimeoutList, SArray* pNotReadyList, const char* id) {
596
  for (int32_t i = 0; i < taosArrayGetSize(pInfo->pList); ++i) {
8,498✔
597
    SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, i);
5,776✔
598
    if (p == NULL) {
5,776!
599
      continue;
×
600
    }
601

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

628
void setCheckDownstreamReqInfo(SStreamTaskCheckReq* pReq, int64_t reqId, int32_t dstTaskId, int32_t dstNodeId) {
22,708✔
629
  pReq->reqId = reqId;
22,708✔
630
  pReq->downstreamTaskId = dstTaskId;
22,708✔
631
  pReq->downstreamNodeId = dstNodeId;
22,708✔
632
}
22,708✔
633

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

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

648
    int32_t                taskId = *px;
×
649
    SDownstreamStatusInfo* p = NULL;
×
650
    findCheckRspStatus(pInfo, taskId, &p);
×
651

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

661
  pInfo->timeoutRetryCount += 1;
×
662

663
  // timeout more than 600 sec, add into node update list
664
  if (pInfo->timeoutRetryCount > 10) {
×
665
    pInfo->timeoutRetryCount = 0;
×
666

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

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

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

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

695
  // reset the info, and send the check msg to failure downstream again
696
  for (int32_t i = 0; i < numOfNotReady; ++i) {
3,711✔
697
    int32_t* pTaskId = taosArrayGet(pNotReadyList, i);
2,162✔
698
    if (pTaskId == NULL) {
2,162!
699
      continue;
×
700
    }
701

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

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

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

723
static void doCleanup(SStreamTask* pTask, SArray* pNotReadyList, SArray* pTimeoutList, void* param) {
9,520✔
724
  streamMetaReleaseTask(pTask->pMeta, pTask);
9,520✔
725

726
  taosArrayDestroy(pNotReadyList);
9,520✔
727
  taosArrayDestroy(pTimeoutList);
9,520✔
728
  streamTaskFreeRefId(param);
9,520✔
729
}
9,520✔
730

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

749
  SStreamTask* pTask = taosAcquireRef(streamTaskRefPool, taskRefId);
9,522✔
750
  if (pTask == NULL) {
9,522✔
751
    stError("invalid task rid:%" PRId64 " failed to acquired stream-task at %s", taskRefId, __func__);
2!
752
    streamTaskFreeRefId(param);
2✔
753
    return;
6,846✔
754
  }
755

756
  pMeta = pTask->pMeta;
9,520✔
757
  pInfo = &pTask->taskCheckInfo;
9,520✔
758
  vgId = pTask->pMeta->vgId;
9,520✔
759
  timeoutDuration = now - pInfo->timeoutStartTs;
9,520✔
760
  id = pTask->id.idStr;
9,520✔
761
  total = (int32_t) taosArrayGetSize(pInfo->pList);
9,520✔
762

763
  stDebug("s-task:%s start to do check-downstream-rsp check in tmr", id);
9,520✔
764

765
  streamMutexLock(&pTask->lock);
9,520✔
766
  SStreamTaskState state = streamTaskGetStatus(pTask);
9,520✔
767
  streamMutexUnlock(&pTask->lock);
9,520✔
768

769
  if (state.state == TASK_STATUS__STOP) {
9,520✔
770
    stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr", id, state.name, vgId);
3✔
771
    streamTaskCompleteCheckRsp(pInfo, true, id);
3✔
772

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

782
    doCleanup(pTask, pNotReadyList, pTimeoutList, param);
3✔
783
    return;
3✔
784
  }
785

786
  if (state.state == TASK_STATUS__DROPPING || state.state == TASK_STATUS__READY) {
9,517!
787
    stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr", id, state.name, vgId);
3,864✔
788

789
    streamTaskCompleteCheckRsp(pInfo, true, id);
3,864✔
790
    doCleanup(pTask, pNotReadyList, pTimeoutList, param);
3,864✔
791
    return;
3,864✔
792
  }
793

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

798
    streamTaskCompleteCheckRsp(pInfo, false, id);
2,931✔
799
    streamMutexUnlock(&pInfo->checkInfoLock);
2,931✔
800
    doCleanup(pTask, pNotReadyList, pTimeoutList, param);
2,931✔
801
    return;
2,931✔
802
  }
803

804
  pNotReadyList = taosArrayInit(4, sizeof(int64_t));
2,722✔
805
  pTimeoutList = taosArrayInit(4, sizeof(int64_t));
2,722✔
806

807
  if (state.state == TASK_STATUS__UNINIT) {
2,722!
808
    getCheckRspStatus(pInfo, timeoutDuration, &numOfReady, &numOfFault, &numOfNotRsp, pTimeoutList, pNotReadyList, id);
2,722✔
809

810
    numOfNotReady = (int32_t)taosArrayGetSize(pNotReadyList);
2,722✔
811
    numOfTimeout = (int32_t)taosArrayGetSize(pTimeoutList);
2,722✔
812

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

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

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

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

848
    streamTaskCompleteCheckRsp(pInfo, false, id);
×
849
    streamMutexUnlock(&pInfo->checkInfoLock);
×
850

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

856
    doCleanup(pTask, pNotReadyList, pTimeoutList, param);
×
857
    return;
×
858
  }
859

860
  if (numOfNotReady > 0) {  // check to make sure not in recheck timer
2,676✔
861
    handleNotReadyDownstreamTask(pTask, pNotReadyList);
1,549✔
862
  }
863

864
  if (numOfTimeout > 0) {
2,676!
865
    handleTimeoutDownstreamTasks(pTask, pTimeoutList);
×
866
  }
867

868
  streamTmrStart(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, param, streamTimer, &pInfo->checkRspTmr, vgId,
2,676✔
869
                 "check-status-monitor");
870
  streamMutexUnlock(&pInfo->checkInfoLock);
2,676✔
871

872
  stDebug(
2,676✔
873
      "s-task:%s vgId:%d continue checking rsp in 300ms, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, "
874
      "ready:%d",
875
      id, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady);
876
  doCleanup(pTask, pNotReadyList, pTimeoutList, NULL);
2,676✔
877
}
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