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

taosdata / TDengine / #3608

12 Feb 2025 05:57AM UTC coverage: 63.066% (+1.4%) from 61.715%
#3608

push

travis-ci

web-flow
Merge pull request #29746 from taosdata/merge/mainto3.02

merge: from main to 3.0 branch

140199 of 286257 branches covered (48.98%)

Branch coverage included in aggregate %.

89 of 161 new or added lines in 18 files covered. (55.28%)

3211 existing lines in 190 files now uncovered.

218998 of 283298 relevant lines covered (77.3%)

5949310.66 hits per line

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

74.39
/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,
13,865✔
41
                              int64_t* oldStage) {
42
  SStreamUpstreamEpInfo* pInfo = NULL;
13,865✔
43
  streamTaskGetUpstreamTaskEpInfo(pTask, upstreamTaskId, &pInfo);
13,865✔
44
  if (pInfo == NULL) {
13,865!
45
    return TSDB_CODE_STREAM_TASK_NOT_EXIST;
×
46
  }
47

48
  *oldStage = pInfo->stage;
13,865✔
49
  const char* id = pTask->id.idStr;
13,865✔
50
  if (stage == -1) {
13,865!
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) {
13,865✔
57
    pInfo->stage = stage;
12,530✔
58
    stDebug("s-task:%s receive check msg from upstream task:0x%x(vgId:%d) first time, init stage value:%" PRId64, id,
12,530✔
59
            upstreamTaskId, vgId, stage);
60
  }
61

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

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

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

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

95
  // serialize streamProcessScanHistoryFinishRsp
96
  if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
8,806✔
97
    streamTaskStartMonitorCheckRsp(pTask);
750✔
98

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

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

104
    stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " check single downstream task:0x%x(vgId:%d) ver:%" PRId64 "-%" PRId64
750✔
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,
750✔
110
                              &pTask->outputInfo.fixedDispatcher.epSet);
111

112
  } else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
8,056✔
113
    streamTaskStartMonitorCheckRsp(pTask);
3,686✔
114

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

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

121
    for (int32_t i = 0; i < numOfVgs; i++) {
15,538✔
122
      SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i);
11,852✔
123
      if (pVgInfo == NULL) {
11,852!
124
        continue;
×
125
      }
126

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

130
      stDebug("s-task:%s (vgId:%d) stage:%" PRId64
11,852✔
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);
11,852✔
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);
4,370✔
137
    streamTaskStopMonitorCheckRsp(&pTask->taskCheckInfo, idstr);
4,370✔
138
    processDownstreamReadyRsp(pTask);
4,370✔
139
  }
140

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

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

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

159
  // only the leader node handle the check request
160
  if (pMeta->role == NODE_ROLE_FOLLOWER) {
13,886✔
161
    stError(
1!
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;
1✔
165
  } else {
166
    SStreamTask* pTask = NULL;
13,885✔
167
    int32_t      code = streamMetaAcquireTask(pMeta, pReq->streamId, taskId, &pTask);
13,885✔
168
    if (pTask != NULL) {
13,885✔
169
      pRsp->status =
13,865✔
170
          streamTaskCheckStatus(pTask, pReq->upstreamTaskId, pReq->upstreamNodeId, pReq->stage, &pRsp->oldStage);
13,865✔
171

172
      SStreamTaskState pState = streamTaskGetStatus(pTask);
13,865✔
173
      stDebug("s-task:%s status:%s, stage:%" PRId64 " recv task check req(QID:0x%" PRIx64
13,865✔
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);
13,865✔
178
    } else {
179
      pRsp->status = TASK_DOWNSTREAM_NOT_READY;
20✔
180
      stDebug("tq recv task check(taskId:0x%" PRIx64 "-0x%x not built yet) req(QID:0x%" PRIx64
20!
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
}
13,886✔
186

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

194
  if (streamTaskShouldStop(pTask)) {
13,851!
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) {
13,851!
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) {
13,851✔
205
    int32_t code = streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id);
12,475✔
206
    if (code != TSDB_CODE_SUCCESS) {
12,475!
207
      return TSDB_CODE_SUCCESS;
×
208
    }
209

210
    if (left == 0) {
12,475✔
211
      processDownstreamReadyRsp(pTask);  // all downstream tasks are ready, set the complete check downstream flag
4,355✔
212
      streamTaskStopMonitorCheckRsp(pInfo, id);
4,355✔
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,
8,120✔
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);
1,376✔
219
    if (code != TSDB_CODE_SUCCESS) {
1,376✔
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) {
1,374✔
224
      if (pRsp->status == TASK_UPSTREAM_NEW_STAGE) {
13✔
225
        stError("s-task:%s vgId:%d self vnode-transfer/leader-change/restart detected, old stage:%" PRId64
12!
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);
12✔
229
      } else {
230
        stError(
1!
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);
1✔
235
      }
236

237
      streamMetaAddFailedTaskSelf(pTask, now);
13✔
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,
1,361✔
240
              pRsp->upstreamNodeId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->status, total, left);
241
    }
242
  }
243

244
  return 0;
13,849✔
245
}
246

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

253
  tEncodeSize(tEncodeStreamTaskCheckRsp, pRsp, len, code);
13,886!
254
  if (code < 0) {
13,886!
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);
13,886✔
260
  if (buf == NULL) {
13,886!
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);
13,886✔
267

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

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

276
  code = TMIN(code, 0);
13,886✔
277
  return code;
13,886✔
278
}
279

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

284
  streamMutexLock(&pInfo->checkInfoLock);
4,436✔
285

286
  // drop procedure already started, not start check downstream now
287
  ETaskStatus s = streamTaskGetStatus(pTask).state;
4,436✔
288
  if (s == TASK_STATUS__DROPPING) {
4,436!
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);
4,436✔
296
  if (code != TSDB_CODE_SUCCESS) {
4,436!
297
    streamMutexUnlock(&pInfo->checkInfoLock);
×
298
    return;
×
299
  }
300

301
  streamTaskInitTaskCheckInfo(pInfo, &pTask->outputInfo, taosGetTimestampMs());
4,436✔
302

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

310
  streamMutexUnlock(&pInfo->checkInfoLock);
4,436✔
311
}
312

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

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

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

325
  if (pInfo->checkRspTmr != NULL) {
35,762✔
326
    streamTmrStop(pInfo->checkRspTmr);
4,361✔
327
    pInfo->checkRspTmr = NULL;
4,361✔
328
  }
329

330
  streamMutexDestroy(&pInfo->checkInfoLock);
35,762✔
331
}
35,762✔
332

333
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
334
void processDownstreamReadyRsp(SStreamTask* pTask) {
8,725✔
335
  EStreamTaskEvent event = (pTask->info.fillHistory == 0) ? TASK_EVENT_INIT : TASK_EVENT_INIT_SCANHIST;
8,725✔
336
  int32_t          code = streamTaskOnHandleEventSuccess(pTask->status.pSM, event, NULL, NULL);
8,725✔
337
  if (code) {
8,725!
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;
8,725✔
342
  int64_t readyTs = pTask->execInfo.readyTs;
8,725✔
343
  code = streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, checkTs, readyTs, true);
8,725✔
344
  if (code) {
8,725✔
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) {
8,725✔
349
    if (!HAS_RELATED_FILLHISTORY_TASK(pTask) || (pTask->info.fillHistory != 0)) {
1!
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,
1!
356
            pTask->info.taskLevel, streamTaskGetStatusStr(pTask->status.taskStatus));
357
    code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_HALT);
1✔
358
    if (code != 0) {  // todo: handle error
1!
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)) {
8,725✔
367
    stDebug("s-task:%s try to launch related fill-history task", pTask->id.idStr);
2,986✔
368
    code = streamLaunchFillHistoryTask(pTask);
2,986✔
369
    if (code) {
2,986!
370
      stError("s-task:%s failed to launch history task, code:%s", pTask->id.idStr, tstrerror(code));
×
371
    }
372
  }
373
}
8,725✔
374

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

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

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

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

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

398
    void* p = taosArrayPush(pTask->outputInfo.pNodeEpsetUpdateList, &t);
18✔
399
    if (p == NULL) {
18!
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,
18!
404
             vgId, t.nodeId, (num + 1));
405
    }
406
  }
407

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

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

415
  if (pOutputInfo->type == TASK_OUTPUT__FIXED_DISPATCH) {
4,436✔
416
    pInfo->notReadyTasks = 1;
750✔
417
  } else if (pOutputInfo->type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
3,686!
418
    pInfo->notReadyTasks = taosArrayGetSize(pOutputInfo->shuffleDispatcher.dbInfo.pVgroupInfos);
3,686✔
419
  }
420

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

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

431
  *pStatusInfo = NULL;
27,799✔
432
  for (int32_t j = 0; j < taosArrayGetSize(pInfo->pList); ++j) {
91,963✔
433
    SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, j);
64,164✔
434
    if (p == NULL) {
64,164!
435
      continue;
×
436
    }
437

438
    if (p->taskId == taskId) {
64,164✔
439
      *pStatusInfo = p;
15,195✔
440
    }
441
  }
442
}
443

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

448
  streamMutexLock(&pInfo->checkInfoLock);
13,851✔
449
  findCheckRspStatus(pInfo, taskId, &p);
13,851✔
450
  if (p != NULL) {
13,851✔
451
    if (reqId != p->reqId) {
13,849!
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)) {
13,849!
461
      *pNotReady = atomic_sub_fetch_32(&pInfo->notReadyTasks, 1);
12,475✔
462
    } else {
463
      *pNotReady = pInfo->notReadyTasks;
1,374✔
464
    }
465

466
    p->status = status;
13,849✔
467
    p->rspTs = rspTs;
13,849✔
468

469
    streamMutexUnlock(&pInfo->checkInfoLock);
13,849✔
470
    return TSDB_CODE_SUCCESS;
13,849✔
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) {
4,436✔
480
  if (pInfo->inCheckProcess == 0) {
4,436!
481
    pInfo->inCheckProcess = 1;
4,436✔
482
  } else {
UNCOV
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);
4,436✔
490
  return TSDB_CODE_SUCCESS;
4,436✔
491
}
492

493
void streamTaskCompleteCheckRsp(STaskCheckInfo* pInfo, bool lock, const char* id) {
4,200✔
494
  if (lock) {
4,200✔
495
    streamMutexLock(&pInfo->checkInfoLock);
2,545✔
496
  }
497

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

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

508
    pInfo->notReadyRetryCount = 0;
4,200✔
509
    pInfo->timeoutRetryCount = 0;
4,200✔
510

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

516
  if (lock) {
4,200✔
517
    streamMutexUnlock(&pInfo->checkInfoLock);
2,545✔
518
  }
519
}
4,200✔
520

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

526
  SDownstreamStatusInfo* p = NULL;
12,602✔
527
  findCheckRspStatus(pInfo, taskId, &p);
12,602✔
528
  if (p != NULL) {
12,602!
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);
25,204✔
535
  if (px == NULL) {
536
    // todo: retry
537
  }
538

539
  streamMutexUnlock(&pInfo->checkInfoLock);
12,602✔
540
}
541

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

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

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

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

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

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

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

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

579
        stDebug("s-task:%s (vgId:%d) stage:%" PRId64
712✔
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);
712✔
583
        break;
712✔
584
      }
585
    }
586
  }
587

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

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

602
    if (p->status == TASK_DOWNSTREAM_READY) {
3,324✔
603
      (*numOfReady) += 1;
739✔
604
    } else if (p->status == TASK_UPSTREAM_NEW_STAGE || p->status == TASK_DOWNSTREAM_NOT_LEADER) {
2,585✔
605
      stDebug("s-task:%s recv status:NEW_STAGE/NOT_LEADER from downstream, task:0x%x, quit from check downstream", id,
13!
606
              p->taskId);
607
      (*numOfFault) += 1;
13✔
608
    } else {                                 // TASK_DOWNSTREAM_NOT_READY
609
      if (p->rspTs == 0) {                   // not response yet
2,572✔
610
        if (el >= CHECK_NOT_RSP_DURATION) {  // not receive info for 10 sec.
1,227✔
611
          void* px = taosArrayPush(pTimeoutList, &p->taskId);
1✔
612
          if (px == NULL) {
1!
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,226✔
617
        }
618
      } else {
619
        void* px = taosArrayPush(pNotReadyList, &p->taskId);
1,345✔
620
        if (px == NULL) {
1,345!
621
          stError("s-task:%s failed to record not ready task:0x%x", id, p->taskId);
×
622
        }
623
      }
624
    }
625
  }
626
}
1,783✔
627

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

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

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

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

652
    if (p != NULL) {
1!
653
      if (p->status != -1 || p->rspTs != 0) {
1!
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);
1✔
658
    }
659
  }
660

661
  pInfo->timeoutRetryCount += 1;
1✔
662

663
  // timeout more than 600 sec, add into node update list
664
  if (pInfo->timeoutRetryCount > 10) {
1!
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,
1!
685
            vgId, numOfTimeout, pInfo->timeoutRetryCount, pInfo->timeoutStartTs);
686
  }
687
}
1✔
688

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

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

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

711
  pInfo->notReadyRetryCount += 1;
999✔
712
  stDebug("s-task:%s vgId:%d %d downstream task(s) not ready, send check msg again, retry:%d start time:%" PRId64, id,
999✔
713
          vgId, numOfNotReady, pInfo->notReadyRetryCount, pInfo->startTs);
714
}
999✔
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.
UNCOV
719
int32_t addDownstreamFailedStatusResultAsync(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId) {
×
UNCOV
720
  return streamTaskSchedTask(pMsgCb, vgId, streamId, taskId, STREAM_EXEC_T_ADD_FAILED_TASK);
×
721
}
722

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

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

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

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

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

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

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

769
  if (state.state == TASK_STATUS__STOP) {
5,970!
UNCOV
770
    stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr", id, state.name, vgId);
×
UNCOV
771
    streamTaskCompleteCheckRsp(pInfo, true, id);
×
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.
UNCOV
775
    if (!pMeta->closeFlag) {
×
UNCOV
776
      int32_t code = addDownstreamFailedStatusResultAsync(pTask->pMsgCb, vgId, pTask->id.streamId, pTask->id.taskId);
×
UNCOV
777
      if (code) {
×
778
        stError("s-task:%s failed to create async record start failed task, code:%s", id, tstrerror(code));
×
779
      }
780
    }
781

UNCOV
782
    doCleanup(pTask, pNotReadyList, pTimeoutList, param);
×
UNCOV
783
    return;
×
784
  }
785

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

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

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

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

804
  pNotReadyList = taosArrayInit(4, sizeof(int64_t));
1,783✔
805
  pTimeoutList = taosArrayInit(4, sizeof(int64_t));
1,783✔
806

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

810
    numOfNotReady = (int32_t)taosArrayGetSize(pNotReadyList);
1,783✔
811
    numOfTimeout = (int32_t)taosArrayGetSize(pTimeoutList);
1,783✔
812

813
    // fault tasks detected, not try anymore
814
    bool jumpOut = false;
1,783✔
815
    if ((numOfReady + numOfFault + numOfNotReady + numOfTimeout + numOfNotRsp) != total) {
1,783!
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) {
1,783✔
824
      stDebug(
13!
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;
13✔
829
    }
830

831
    if (jumpOut) {
1,783✔
832
      streamTaskCompleteCheckRsp(pInfo, false, id);
13✔
833
      streamMutexUnlock(&pInfo->checkInfoLock);
13✔
834
      doCleanup(pTask, pNotReadyList, pTimeoutList, param);
13✔
835
      return;
13✔
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) {
1,770!
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
1,770✔
861
    handleNotReadyDownstreamTask(pTask, pNotReadyList);
999✔
862
  }
863

864
  if (numOfTimeout > 0) {
1,770✔
865
    handleTimeoutDownstreamTasks(pTask, pTimeoutList);
1✔
866
  }
867

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

872
  stDebug(
1,770✔
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);
1,770✔
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