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

taosdata / TDengine / #3549

06 Dec 2024 09:44AM UTC coverage: 59.948% (+0.1%) from 59.846%
#3549

push

travis-ci

web-flow
Merge pull request #29057 from taosdata/docs/TD-33031-3.0

docs: description of user privileges

118833 of 254191 branches covered (46.75%)

Branch coverage included in aggregate %.

199893 of 277480 relevant lines covered (72.04%)

19006119.35 hits per line

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

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

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

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

71
  if (pInfo->stage != stage) {
21,622✔
72
    return TASK_UPSTREAM_NEW_STAGE;
63✔
73
  } else if (pTask->status.downstreamReady != 1) {
21,559✔
74
    stDebug("s-task:%s vgId:%d leader:%d, downstream not ready", id, vgId, (pTask->pMeta->role == NODE_ROLE_LEADER));
2,008✔
75
    return TASK_DOWNSTREAM_NOT_READY;
2,008✔
76
  } else {
77
    return TASK_DOWNSTREAM_READY;
19,551✔
78
  }
79
}
80

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

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

96
  // serialize streamProcessScanHistoryFinishRsp
97
  if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
13,816✔
98
    streamTaskStartMonitorCheckRsp(pTask);
945✔
99

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

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

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

113
  } else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
12,871✔
114
    streamTaskStartMonitorCheckRsp(pTask);
6,054✔
115

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

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

122
    for (int32_t i = 0; i < numOfVgs; i++) {
24,908✔
123
      SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i);
18,852✔
124
      if (pVgInfo == NULL) {
18,852!
125
        continue;
×
126
      }
127

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

131
      stDebug("s-task:%s (vgId:%d) stage:%" PRId64
18,852✔
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);
18,851✔
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);
6,817✔
138
    streamTaskStopMonitorCheckRsp(&pTask->taskCheckInfo, idstr);
6,817✔
139
    processDownstreamReadyRsp(pTask);
6,818✔
140
  }
141

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

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

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

160
  // only the leader node handle the check request
161
  if (pMeta->role == NODE_ROLE_FOLLOWER) {
21,685✔
162
    stError(
3!
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;
3✔
166
  } else {
167
    SStreamTask* pTask = NULL;
21,682✔
168
    int32_t      code = streamMetaAcquireTask(pMeta, pReq->streamId, taskId, &pTask);
21,682✔
169
    if (pTask != NULL) {
21,692✔
170
      pRsp->status =
21,625✔
171
          streamTaskCheckStatus(pTask, pReq->upstreamTaskId, pReq->upstreamNodeId, pReq->stage, &pRsp->oldStage);
21,675✔
172

173
      SStreamTaskState pState = streamTaskGetStatus(pTask);
21,625✔
174
      stDebug("s-task:%s status:%s, stage:%" PRId64 " recv task check req(QID:0x%" PRIx64
21,627✔
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);
21,627✔
179
    } else {
180
      pRsp->status = TASK_DOWNSTREAM_NOT_READY;
17✔
181
      stDebug("tq recv task check(taskId:0x%" PRIx64 "-0x%x not built yet) req(QID:0x%" PRIx64
17!
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
}
21,689✔
187

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

195
  if (streamTaskShouldStop(pTask)) {
21,685!
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) {
21,688!
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) {
21,688✔
206
    int32_t code = streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id);
19,537✔
207
    if (code != TSDB_CODE_SUCCESS) {
19,606!
208
      return TSDB_CODE_SUCCESS;
×
209
    }
210

211
    if (left == 0) {
19,606✔
212
      processDownstreamReadyRsp(pTask);  // all downstream tasks are ready, set the complete check downstream flag
6,893✔
213
      streamTaskStopMonitorCheckRsp(pInfo, id);
6,892✔
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,
12,713✔
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);
2,151✔
220
    if (code != TSDB_CODE_SUCCESS) {
2,155✔
221
      return TSDB_CODE_SUCCESS;  // return success in any cases.
3✔
222
    }
223

224
    if (pRsp->status == TASK_UPSTREAM_NEW_STAGE || pRsp->status == TASK_DOWNSTREAM_NOT_LEADER) {
2,152✔
225
      if (pRsp->status == TASK_UPSTREAM_NEW_STAGE) {
75✔
226
        stError("s-task:%s vgId:%d self vnode-transfer/leader-change/restart detected, old stage:%" PRId64
72!
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);
72✔
230
      } else {
231
        stError(
3!
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);
3✔
236
      }
237

238
      streamMetaAddFailedTaskSelf(pTask, now);
75✔
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,
2,077✔
241
              pRsp->upstreamNodeId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->status, total, left);
242
    }
243
  }
244

245
  return 0;
21,758✔
246
}
247

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

254
  tEncodeSize(tEncodeStreamTaskCheckRsp, pRsp, len, code);
21,665!
255
  if (code < 0) {
21,662!
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);
21,662✔
261
  if (buf == NULL) {
21,665!
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);
21,665✔
268

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

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

277
  code = TMIN(code, 0);
21,701✔
278
  return code;
21,701✔
279
}
280

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

285
  streamMutexLock(&pInfo->checkInfoLock);
6,999✔
286

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

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

302
  streamTaskInitTaskCheckInfo(pInfo, &pTask->outputInfo, taosGetTimestampMs());
6,998✔
303

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

311
  streamMutexUnlock(&pInfo->checkInfoLock);
6,999✔
312
}
313

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

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

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

326
  if (pInfo->checkRspTmr != NULL) {
59,324✔
327
    streamTmrStop(pInfo->checkRspTmr);
6,871✔
328
    pInfo->checkRspTmr = NULL;
6,871✔
329
  }
330

331
  streamMutexDestroy(&pInfo->checkInfoLock);
59,324✔
332
}
59,324✔
333

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

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

382
  streamMutexLock(&pTask->lock);
75✔
383

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

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

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

400
    void* p = taosArrayPush(pTask->outputInfo.pNodeEpsetUpdateList, &t);
49✔
401
    if (p == NULL) {
49!
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,
49!
406
             vgId, t.nodeId, (num + 1));
407
    }
408
  }
409

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

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

417
  if (pOutputInfo->type == TASK_OUTPUT__FIXED_DISPATCH) {
6,998✔
418
    pInfo->notReadyTasks = 1;
945✔
419
  } else if (pOutputInfo->type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
6,053!
420
    pInfo->notReadyTasks = taosArrayGetSize(pOutputInfo->shuffleDispatcher.dbInfo.pVgroupInfos);
6,053✔
421
  }
422

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

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

433
  *pStatusInfo = NULL;
43,637✔
434
  for (int32_t j = 0; j < taosArrayGetSize(pInfo->pList); ++j) {
139,421✔
435
    SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, j);
95,790✔
436
    if (p == NULL) {
95,784!
437
      continue;
×
438
    }
439

440
    if (p->taskId == taskId) {
95,784✔
441
      *pStatusInfo = p;
23,823✔
442
    }
443
  }
444
}
445

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

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

461
    // subtract one not-ready-task, since it is ready now
462
    if ((p->status != TASK_DOWNSTREAM_READY) && (status == TASK_DOWNSTREAM_READY)) {
21,736✔
463
      *pNotReady = atomic_sub_fetch_32(&pInfo->notReadyTasks, 1);
19,588✔
464
    } else {
465
      *pNotReady = pInfo->notReadyTasks;
2,148✔
466
    }
467

468
    p->status = status;
21,758✔
469
    p->rspTs = rspTs;
21,758✔
470

471
    streamMutexUnlock(&pInfo->checkInfoLock);
21,758✔
472
    return TSDB_CODE_SUCCESS;
21,759✔
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) {
6,998✔
482
  if (pInfo->inCheckProcess == 0) {
6,998!
483
    pInfo->inCheckProcess = 1;
6,998✔
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);
6,998✔
492
  return TSDB_CODE_SUCCESS;
6,999✔
493
}
494

495
void streamTaskCompleteCheckRsp(STaskCheckInfo* pInfo, bool lock, const char* id) {
6,674✔
496
  if (lock) {
6,674✔
497
    streamMutexLock(&pInfo->checkInfoLock);
4,320✔
498
  }
499

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

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

510
    pInfo->notReadyRetryCount = 0;
6,674✔
511
    pInfo->timeoutRetryCount = 0;
6,674✔
512

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

518
  if (lock) {
6,674✔
519
    streamMutexUnlock(&pInfo->checkInfoLock);
4,320✔
520
  }
521
}
6,674✔
522

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

528
  SDownstreamStatusInfo* p = NULL;
19,798✔
529
  findCheckRspStatus(pInfo, taskId, &p);
19,798✔
530
  if (p != NULL) {
19,797!
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);
39,592✔
537
  if (px == NULL) {
538
    // todo: retry
539
  }
540

541
  streamMutexUnlock(&pInfo->checkInfoLock);
19,795✔
542
}
543

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

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

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

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

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

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

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

578
      if (p->taskId == pVgInfo->taskId) {
2,877✔
579
        setCheckDownstreamReqInfo(&req, p->reqId, pVgInfo->taskId, pVgInfo->vgId);
1,505✔
580

581
        stDebug("s-task:%s (vgId:%d) stage:%" PRId64
1,505✔
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);
1,505✔
585
        break;
1,505✔
586
      }
587
    }
588
  }
589

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

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

604
    if (p->status == TASK_DOWNSTREAM_READY) {
5,197✔
605
      (*numOfReady) += 1;
1,066✔
606
    } else if (p->status == TASK_UPSTREAM_NEW_STAGE || p->status == TASK_DOWNSTREAM_NOT_LEADER) {
4,131✔
607
      stDebug("s-task:%s recv status:NEW_STAGE/NOT_LEADER from downstream, task:0x%x, quit from check downstream", id,
75!
608
              p->taskId);
609
      (*numOfFault) += 1;
75✔
610
    } else {                                 // TASK_DOWNSTREAM_NOT_READY
611
      if (p->rspTs == 0) {                   // not response yet
4,056✔
612
        if (el >= CHECK_NOT_RSP_DURATION) {  // not receive info for 10 sec.
1,982✔
613
          void* px = taosArrayPush(pTimeoutList, &p->taskId);
4✔
614
          if (px == NULL) {
4!
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,978✔
619
        }
620
      } else {
621
        void* px = taosArrayPush(pNotReadyList, &p->taskId);
2,074✔
622
        if (px == NULL) {
2,074!
623
          stError("s-task:%s failed to record not ready task:0x%x", id, p->taskId);
×
624
        }
625
      }
626
    }
627
  }
628
}
2,153✔
629

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

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

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

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

654
    if (p != NULL) {
4!
655
      if (p->status != -1 || p->rspTs != 0) {
4!
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);
4✔
660
    }
661
  }
662

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

665
  // timeout more than 100 sec, add into node update list
666
  if (pInfo->timeoutRetryCount > 10) {
4!
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,
4!
687
            vgId, numOfTimeout, pInfo->timeoutRetryCount, pInfo->timeoutStartTs);
688
  }
689
}
4✔
690

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

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

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

713
  pInfo->notReadyRetryCount += 1;
1,218✔
714
  stDebug("s-task:%s vgId:%d %d downstream task(s) not ready, send check msg again, retry:%d start time:%" PRId64, id,
1,218✔
715
          vgId, numOfNotReady, pInfo->notReadyRetryCount, pInfo->startTs);
716
}
1,218✔
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) {
8,778✔
726
  streamMetaReleaseTask(pTask->pMeta, pTask);
8,778✔
727

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

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

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

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

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

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

771
  if (state.state == TASK_STATUS__STOP) {
8,778!
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) {
8,778!
789
    stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr", id, state.name, vgId);
4,320✔
790

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

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

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

806
  pNotReadyList = taosArrayInit(4, sizeof(int64_t));
2,153✔
807
  pTimeoutList = taosArrayInit(4, sizeof(int64_t));
2,153✔
808

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

812
    numOfNotReady = (int32_t)taosArrayGetSize(pNotReadyList);
2,153✔
813
    numOfTimeout = (int32_t)taosArrayGetSize(pTimeoutList);
2,153✔
814

815
    // fault tasks detected, not try anymore
816
    bool jumpOut = false;
2,153✔
817
    if ((numOfReady + numOfFault + numOfNotReady + numOfTimeout + numOfNotRsp) != total) {
2,153!
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) {
2,153✔
826
      stDebug(
49!
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;
49✔
831
    }
832

833
    if (jumpOut) {
2,153✔
834
      streamTaskCompleteCheckRsp(pInfo, false, id);
49✔
835
      streamMutexUnlock(&pInfo->checkInfoLock);
49✔
836
      doCleanup(pTask, pNotReadyList, pTimeoutList, param);
49✔
837
      return;
49✔
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) {
2,104!
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
2,104✔
863
    handleNotReadyDownstreamTask(pTask, pNotReadyList);
1,218✔
864
  }
865

866
  if (numOfTimeout > 0) {
2,104✔
867
    handleTimeoutDownstreamTasks(pTask, pTimeoutList);
4✔
868
  }
869

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

874
  stDebug(
2,104✔
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);
2,104✔
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