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

taosdata / TDengine / #4308

14 Jun 2025 02:06PM UTC coverage: 62.454% (-0.3%) from 62.777%
#4308

push

travis-ci

web-flow
fix: taosdump windows pthread_mutex_unlock crash(3.0) (#31357)

* fix: windows pthread_mutex_unlock crash

* enh: sync from main fix taosdump crash windows

* fix: restore .github action branch to main

153985 of 315105 branches covered (48.87%)

Branch coverage included in aggregate %.

238120 of 312727 relevant lines covered (76.14%)

6462519.65 hits per line

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

63.03
/source/dnode/vnode/src/tq/tqStreamTask.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 "tq.h"
17
#include "vnd.h"
18

19
#define SCAN_WAL_IDLE_DURATION    250  // idle for 500ms to do next wal scan
20
#define SCAN_WAL_WAIT_COUNT       2
21

22
typedef struct SBuildScanWalMsgParam {
23
  int64_t metaId;
24
  SMsgCb  msgCb;
25
} SBuildScanWalMsgParam;
26

27
static int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta, int32_t* pNumOfTasks);
28
static int32_t setWalReaderStartOffset(SStreamTask* pTask, int32_t vgId);
29
static bool    handleFillhistoryScanComplete(SStreamTask* pTask, int64_t ver);
30
static bool    taskReadyForDataFromWal(SStreamTask* pTask);
31
static int32_t doPutDataIntoInputQ(SStreamTask* pTask, int64_t maxVer, int32_t* numOfItems, bool* pSucc);
32

33
// extract data blocks(submit/delete) from WAL, and add them into the input queue for all the sources tasks.
34
int32_t tqScanWal(STQ* pTq) {
59,375✔
35
  SStreamMeta* pMeta = pTq->pStreamMeta;
59,375✔
36
  int32_t      vgId = pMeta->vgId;
59,375✔
37
  int64_t      st = taosGetTimestampMs();
59,395✔
38
  int32_t      numOfTasks = 0;
59,395✔
39
  int64_t      el = 0;
59,395✔
40
  int32_t      code = 0;
59,395✔
41

42
  int32_t old = atomic_val_compare_exchange_32(&pMeta->scanInfo.scanSentinel, 0, 1);
59,395✔
43
  if (old == 0) {
59,393!
44
    tqDebug("vgId:%d try to scan wal to extract data", vgId);
59,393✔
45
  } else {
46
    tqDebug("vgId:%d already in wal scan, abort", vgId);
×
47
    return code;
×
48
  }
49

50
  // the scan wal interval less than 200, not scan, actually.
51
  if ((pMeta->scanInfo.lastScanTs > 0) && (st - pMeta->scanInfo.lastScanTs < 200)) {
59,402✔
52
    tqDebug("vgId:%d scan wal less than 200ms, do nothing", vgId);
1!
53
    atomic_store_32(&pMeta->scanInfo.scanSentinel, 0);
1✔
54
    return code;
1✔
55
  }
56

57
  // check all tasks
58
  code = doScanWalForAllTasks(pMeta, &numOfTasks);
59,401✔
59

60
  pMeta->scanInfo.lastScanTs = taosGetTimestampMs();
59,388✔
61
  el = (pMeta->scanInfo.lastScanTs - st);
59,388✔
62

63
  if (code) {
59,388!
64
    tqError("vgId:%d failed to scan wal for all tasks, try next time, elapsed time:%" PRId64 "ms code:%s", vgId, el,
×
65
            tstrerror(code));
66
  } else {
67
    tqDebug("vgId:%d scan wal for stream tasks completed, elapsed time:%" PRId64 "ms", vgId, el);
59,388!
68
  }
69

70
  atomic_store_32(&pMeta->scanInfo.scanSentinel, 0);
59,394✔
71
  return code;
59,394✔
72
}
73

74
static bool waitEnoughDuration(SStreamMeta* pMeta) {
821,234✔
75
  if ((++pMeta->scanInfo.tickCounter) >= SCAN_WAL_WAIT_COUNT) {
821,234✔
76
    pMeta->scanInfo.tickCounter = 0;
407,834✔
77
    return true;
407,834✔
78
  }
79

80
  return false;
413,400✔
81
}
82

83
static void doStartScanWal(void* param, void* tmrId) {
838,269✔
84
  int32_t                vgId = 0;
838,269✔
85
  int32_t                code = 0;
838,269✔
86
  int32_t                numOfTasks = 0;
838,269✔
87
  tmr_h                  pTimer = NULL;
838,269✔
88
  int32_t                numOfItems = 0;
838,269✔
89
  STQ*                   pTq = NULL;
838,269✔
90
  SBuildScanWalMsgParam* pParam = (SBuildScanWalMsgParam*)param;
838,269✔
91

92
  tqTrace("start to do scan wal in tmr, metaRid:%" PRId64, pParam->metaId);
838,269✔
93

94
  SStreamMeta* pMeta = taosAcquireRef(streamMetaRefPool, pParam->metaId);
838,269✔
95
  if (pMeta == NULL) {
838,269!
96
    tqError("metaRid:%" PRId64 " not valid now, stream meta has been freed", pParam->metaId);
×
97
    taosMemoryFree(pParam);
×
98
    return;
424,816✔
99
  }
100

101
  pTq = pMeta->ahandle;
838,269✔
102
  vgId = pMeta->vgId;
838,269✔
103
  code = streamTimerGetInstance(&pTimer);
838,269✔
104
  if (code) {
838,269!
105
    tqFatal("vgId:%d failed to get tmr ctrl during sched scan wal, not scan wal, code:%s", vgId, tstrerror(code));
×
106
    taosMemoryFree(pParam);
×
107
    return;
×
108
  }
109

110
  if (pMeta->closeFlag) {
838,269✔
111
    code = taosReleaseRef(streamMetaRefPool, pParam->metaId);
11,362✔
112
    if (code == TSDB_CODE_SUCCESS) {
11,362!
113
      tqInfo("vgId:%d jump out of scan wal timer since closed", vgId);
11,362!
114
    } else {
115
      tqError("vgId:%d failed to release ref for streamMeta, rid:%" PRId64 " code:%s", vgId, pParam->metaId,
×
116
              tstrerror(code));
117
    }
118

119
    taosMemoryFree(pParam);
11,362!
120
    return;
11,362✔
121
  }
122

123
  if (pMeta->role != NODE_ROLE_LEADER) {
826,907✔
124
    tqDebug("vgId:%d not leader, role:%d not scan wal anymore", vgId, pMeta->role);
54!
125

126
    code = taosReleaseRef(streamMetaRefPool, pParam->metaId);
54✔
127
    if (code == TSDB_CODE_SUCCESS) {
54!
128
      tqDebug("vgId:%d jump out of scan wal timer since not leader", vgId);
54!
129
    } else {
130
      tqError("vgId:%d failed to release ref for streamMeta, rid:%" PRId64 " code:%s", vgId, pParam->metaId,
×
131
              tstrerror(code));
132
    }
133

134
    taosMemFree(pParam);
54✔
135
    return;
54✔
136
  }
137

138
  if (pMeta->startInfo.startAllTasks) {
826,853✔
139
    tqDebug("vgId:%d in restart procedure, not ready to scan wal", vgId);
5,619!
140
    goto _end;
5,619✔
141
  }
142

143
  numOfItems = tmsgGetQueueSize(&pTq->pVnode->msgCb, pMeta->vgId, STREAM_QUEUE);
821,234✔
144
  bool tooMany = (numOfItems > tsThresholdItemsInStreamQueue);
821,234✔
145

146
  if (!waitEnoughDuration(pMeta) || tooMany) {
821,234!
147
    if (tooMany) {
413,400!
148
      tqDebug("vgId:%d %d items (threshold: %d) in stream_queue, not scan wal now", vgId, numOfItems,
×
149
              tsThresholdItemsInStreamQueue);
150
    }
151

152
    streamTmrStart(doStartScanWal, SCAN_WAL_IDLE_DURATION, pParam, pTimer, &pMeta->scanInfo.scanTimer, vgId,
413,400✔
153
                   "scan-wal");
154
    code = taosReleaseRef(streamMetaRefPool, pParam->metaId);
413,400✔
155
    if (code) {
413,400!
156
      tqError("vgId:%d failed to release ref for streamMeta, rid:%" PRId64 " code:%s", vgId, pParam->metaId,
×
157
              tstrerror(code));
158
    }
159
    return;
413,400✔
160
  }
161

162
  // failed to lock, try 500ms later
163
  code = streamMetaTryRlock(pMeta);
407,834✔
164
  if (code == 0) {
407,834✔
165
    numOfTasks = taosArrayGetSize(pMeta->pTaskList);
407,593✔
166
    streamMetaRUnLock(pMeta);
407,593✔
167
  } else {
168
    numOfTasks = 0;
241✔
169
  }
170

171
  if (numOfTasks > 0) {
407,834✔
172
    tqDebug("vgId:%d create msg to start wal scan, numOfTasks:%d", vgId, numOfTasks);
59,395!
173

174
#if 0
175
  //  wait for the vnode is freed, and invalid read may occur.
176
  taosMsleep(10000);
177
#endif
178

179
    code = streamTaskSchedTask(&pParam->msgCb, vgId, 0, 0, STREAM_EXEC_T_EXTRACT_WAL_DATA, false);
59,395✔
180
    if (code) {
59,395!
181
      tqError("vgId:%d failed sched task to scan wal, code:%s", vgId, tstrerror(code));
×
182
    }
183
  }
184

185
_end:
407,834✔
186
  streamTmrStart(doStartScanWal, SCAN_WAL_IDLE_DURATION, pParam, pTimer, &pMeta->scanInfo.scanTimer, vgId, "scan-wal");
413,453✔
187
  tqTrace("vgId:%d try scan-wal will start in %dms", vgId, SCAN_WAL_IDLE_DURATION*SCAN_WAL_WAIT_COUNT);
413,453✔
188

189
  code = taosReleaseRef(streamMetaRefPool, pParam->metaId);
413,453✔
190
  if (code) {
413,453!
191
    tqError("vgId:%d failed to release ref for streamMeta, rid:%" PRId64 " code:%s", vgId, pParam->metaId,
×
192
            tstrerror(code));
193
  }
194
}
195

196
void tqScanWalAsync(STQ* pTq) {
11,413✔
197
  SStreamMeta*           pMeta = pTq->pStreamMeta;
11,413✔
198
  int32_t                code = 0;
11,413✔
199
  int32_t                vgId = TD_VID(pTq->pVnode);
11,413✔
200
  tmr_h                  pTimer = NULL;
11,413✔
201
  SBuildScanWalMsgParam* pParam = NULL;
11,413✔
202

203
  // 1. the vnode should be the leader.
204
  // 2. the stream isn't disabled
205
  if ((pMeta->role != NODE_ROLE_LEADER) || tsDisableStream) {
11,413!
206
    tqInfo("vgId:%d follower node or stream disabled, not scan wal", vgId);
×
207
    return;
×
208
  }
209

210
  pParam = taosMemoryMalloc(sizeof(SBuildScanWalMsgParam));
11,415!
211
  if (pParam == NULL) {
11,415!
212
    tqError("vgId:%d failed to start scan wal, stream not executes, code:%s", vgId, tstrerror(code));
×
213
    return;
×
214
  }
215

216
  pParam->metaId = pMeta->rid;
11,415✔
217
  pParam->msgCb = pTq->pVnode->msgCb;
11,415✔
218

219
  code = streamTimerGetInstance(&pTimer);
11,415✔
220
  if (code) {
11,415!
221
    tqFatal("vgId:%d failed to get tmr ctrl during sched scan wal", vgId);
×
222
    taosMemoryFree(pParam);
×
223
  } else {
224
    streamTmrStart(doStartScanWal, SCAN_WAL_IDLE_DURATION, pParam, pTimer, &pMeta->scanInfo.scanTimer, vgId,
11,415✔
225
                   "scan-wal");
226
  }
227
}
228

229
int32_t tqStopStreamAllTasksAsync(SStreamMeta* pMeta, SMsgCb* pMsgCb) {
6,166✔
230
  return streamTaskSchedTask(pMsgCb, pMeta->vgId, 0, 0, STREAM_EXEC_T_STOP_ALL_TASKS, false);
6,166✔
231
}
232

233
int32_t setWalReaderStartOffset(SStreamTask* pTask, int32_t vgId) {
71,246✔
234
  // seek the stored version and extract data from WAL
235
  int64_t firstVer = walReaderGetValidFirstVer(pTask->exec.pWalReader);
71,246✔
236
  if (pTask->chkInfo.nextProcessVer < firstVer) {
71,246!
237
    tqWarn("vgId:%d s-task:%s ver:%" PRId64 " earlier than the first ver of wal range %" PRId64 ", forward to %" PRId64,
×
238
           vgId, pTask->id.idStr, pTask->chkInfo.nextProcessVer, firstVer, firstVer);
239

240
    pTask->chkInfo.nextProcessVer = firstVer;
×
241

242
    // todo need retry if failed
243
    int32_t code = walReaderSeekVer(pTask->exec.pWalReader, pTask->chkInfo.nextProcessVer);
×
244
    if (code != TSDB_CODE_SUCCESS) {
×
245
      return code;
×
246
    }
247

248
    // append the data for the stream
249
    tqDebug("vgId:%d s-task:%s wal reader seek to ver:%" PRId64, vgId, pTask->id.idStr, pTask->chkInfo.nextProcessVer);
×
250
  } else {
251
    int64_t currentVer = walReaderGetCurrentVer(pTask->exec.pWalReader);
71,246✔
252
    if (currentVer == -1) {  // we only seek the read for the first time
71,246✔
253
      int32_t code = walReaderSeekVer(pTask->exec.pWalReader, pTask->chkInfo.nextProcessVer);
2,597✔
254
      if (code != TSDB_CODE_SUCCESS) {  // no data in wal, quit
2,597!
255
        return code;
×
256
      }
257

258
      // append the data for the stream
259
      tqDebug("vgId:%d s-task:%s wal reader initial seek to ver:%" PRId64, vgId, pTask->id.idStr,
2,597!
260
              pTask->chkInfo.nextProcessVer);
261
    }
262
  }
263

264
  int64_t skipToVer = walReaderGetSkipToVersion(pTask->exec.pWalReader);
71,246✔
265
  if (skipToVer != 0 && skipToVer > pTask->chkInfo.nextProcessVer) {
71,245✔
266
    int32_t code = walReaderSeekVer(pTask->exec.pWalReader, skipToVer);
1✔
267
    if (code != TSDB_CODE_SUCCESS) {  // no data in wal, quit
1!
268
      return code;
×
269
    }
270

271
    tqDebug("vgId:%d s-task:%s wal reader jump to ver:%" PRId64, vgId, pTask->id.idStr, skipToVer);
1!
272
  }
273

274
  return TSDB_CODE_SUCCESS;
71,245✔
275
}
276

277
// todo handle memory error
278
bool handleFillhistoryScanComplete(SStreamTask* pTask, int64_t ver) {
126,671✔
279
  const char* id = pTask->id.idStr;
126,671✔
280
  int64_t     maxVer = pTask->step2Range.maxVer;
126,671✔
281

282
  if ((pTask->info.fillHistory == 1) && ver > maxVer) {
126,671✔
283
    if (!pTask->status.appendTranstateBlock) {
540!
284
      qWarn("s-task:%s fill-history scan WAL, nextProcessVer:%" PRId64 " out of the maximum ver:%" PRId64
540!
285
            ", not scan wal anymore, add transfer-state block into inputQ",
286
            id, ver, maxVer);
287

288
      double el = (taosGetTimestampMs() - pTask->execInfo.step2Start) / 1000.0;
540✔
289
      qDebug("s-task:%s scan-history from WAL stage(step 2) ended, range:%" PRId64 "-%" PRId64 ", elapsed time:%.2fs",
540✔
290
             id, pTask->step2Range.minVer, maxVer, el);
291
      int32_t code = streamTaskPutTranstateIntoInputQ(pTask);
540✔
292
      if (code) {
540!
293
        qError("s-task:%s failed to put trans-state into inputQ", id);
×
294
      }
295

296
      return true;
540✔
297
    } else {
298
      qWarn("s-task:%s fill-history scan WAL, nextProcessVer:%" PRId64 " out of the ver range:%" PRId64 "-%" PRId64
×
299
            ", not scan wal",
300
            id, ver, pTask->step2Range.minVer, maxVer);
301
    }
302
  }
303

304
  return false;
126,131✔
305
}
306

307
bool taskReadyForDataFromWal(SStreamTask* pTask) {
248,349✔
308
  // non-source or fill-history tasks don't need to response the WAL scan action.
309
  SSTaskBasicInfo* pInfo = &pTask->info;
248,349✔
310
  if ((pInfo->taskLevel != TASK_LEVEL__SOURCE) || (pTask->status.downstreamReady == 0)) {
248,349✔
311
    return false;
118,187✔
312
  }
313

314
  if (pInfo->trigger == STREAM_TRIGGER_FORCE_WINDOW_CLOSE) {
130,162✔
315
    return false;
36,780✔
316
  }
317

318
  if (pInfo->fillHistory == STREAM_RECALCUL_TASK) {
93,382!
319
    return false;
×
320
  }
321

322
  // not in ready state, do not handle the data from wal
323
  SStreamTaskState pState = streamTaskGetStatus(pTask);
93,382✔
324
  if (pState.state != TASK_STATUS__READY) {
93,382✔
325
    tqTrace("s-task:%s not ready for submit block in wal, status:%s", pTask->id.idStr, pState.name);
16,063✔
326
    return false;
16,063✔
327
  }
328

329
  // fill-history task has entered into the last phase, no need to do anything
330
  if ((pInfo->fillHistory == STREAM_HISTORY_TASK) && pTask->status.appendTranstateBlock) {
77,319✔
331
    // the maximum version of data in the WAL has reached already, the step2 is done
332
    tqDebug("s-task:%s fill-history reach the maximum ver:%" PRId64 ", not scan wal anymore", pTask->id.idStr,
6,074!
333
            pTask->dataRange.range.maxVer);
334
    return false;
6,074✔
335
  }
336

337
  // check whether input queue is full or not
338
  if (streamQueueIsFull(pTask->inputq.queue)) {
71,245!
339
    tqTrace("s-task:%s input queue is full, launch task without scanning wal", pTask->id.idStr);
×
340
    int32_t code = streamTrySchedExec(pTask, false);
×
341
    if (code) {
×
342
      tqError("s-task:%s failed to start task while inputQ is full", pTask->id.idStr);
×
343
    }
344
    return false;
×
345
  }
346

347
  // the input queue of downstream task is full, so the output is blocked, stopped for a while
348
  if (pTask->inputq.status == TASK_INPUT_STATUS__BLOCKED) {
71,246!
349
    tqDebug("s-task:%s inputQ is blocked, do nothing", pTask->id.idStr);
×
350
    return false;
×
351
  }
352

353
  return true;
71,246✔
354
}
355

356
int32_t doPutDataIntoInputQ(SStreamTask* pTask, int64_t maxVer, int32_t* numOfItems, bool* pSucc) {
71,244✔
357
  const char* id = pTask->id.idStr;
71,244✔
358
  int32_t     numOfNewItems = 0;
71,244✔
359
  int32_t     code = 0;
71,244✔
360
  *pSucc = false;
71,244✔
361

362
  while (1) {
55,427✔
363
    if ((pTask->info.fillHistory == 1) && pTask->status.appendTranstateBlock) {
126,671!
364
      *numOfItems += numOfNewItems;
×
365
      return numOfNewItems > 0;
×
366
    }
367

368
    SStreamQueueItem* pItem = NULL;
126,671✔
369
    code = extractMsgFromWal(pTask->exec.pWalReader, (void**)&pItem, maxVer, id);
126,671✔
370
    if (code != TSDB_CODE_SUCCESS || pItem == NULL) {  // failed, continue
126,670✔
371
      int64_t currentVer = walReaderGetCurrentVer(pTask->exec.pWalReader);
71,046✔
372
      bool    itemInFillhistory = handleFillhistoryScanComplete(pTask, currentVer);
71,047✔
373
      if (itemInFillhistory) {
71,046✔
374
        numOfNewItems += 1;
342✔
375
      }
376
      break;
71,046✔
377
    }
378

379
    if (pItem != NULL) {
55,624!
380
      code = streamTaskPutDataIntoInputQ(pTask, pItem);
55,624✔
381
      if (code == TSDB_CODE_SUCCESS) {
55,625!
382
        numOfNewItems += 1;
55,625✔
383
        int64_t ver = walReaderGetCurrentVer(pTask->exec.pWalReader);
55,625✔
384
        pTask->chkInfo.nextProcessVer = ver;
55,625✔
385
        tqDebug("s-task:%s set ver:%" PRId64 " for reader after extract data from WAL", id, ver);
55,625!
386

387
        bool itemInFillhistory = handleFillhistoryScanComplete(pTask, ver);
55,625✔
388
        if (itemInFillhistory) {
55,625✔
389
          break;
198✔
390
        }
391
      } else {
392
        if (code == TSDB_CODE_OUT_OF_MEMORY) {
×
393
          tqError("s-task:%s failed to put data into inputQ, since out of memory", id);
×
394
        } else {
395
          tqTrace("s-task:%s append input queue failed, code:inputQ is full, ver:%" PRId64, id,
×
396
                  pTask->chkInfo.nextProcessVer);
397
          code = walReaderSeekVer(pTask->exec.pWalReader, pTask->chkInfo.nextProcessVer);
×
398
          if (code) {
×
399
            tqError("s-task:%s failed to seek ver to:%" PRId64 " in wal", id, pTask->chkInfo.nextProcessVer);
×
400
          }
401

402
          code = 0;  // reset the error code
×
403
        }
404

405
        break;
×
406
      }
407
    }
408
  }
409

410
  *numOfItems += numOfNewItems;
71,244✔
411
  *pSucc = (numOfNewItems > 0);
71,244✔
412
  return code;
71,244✔
413
}
414

415
int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta, int32_t* pNumOfTasks) {
59,394✔
416
  int32_t vgId = pStreamMeta->vgId;
59,394✔
417
  SArray* pTaskList = NULL;
59,394✔
418
  int32_t numOfTasks = 0;
59,394✔
419

420
  // clone the task list, to avoid the task update during scan wal files
421
  streamMetaWLock(pStreamMeta);
59,394✔
422
  pTaskList = taosArrayDup(pStreamMeta->pTaskList, NULL);
59,393✔
423
  streamMetaWUnLock(pStreamMeta);
59,394✔
424
  if (pTaskList == NULL) {
59,394!
425
    tqError("vgId:%d failed to create task list dup, code:%s", vgId, tstrerror(terrno));
×
426
    return terrno;
×
427
  }
428

429
  // update the new task number
430
  numOfTasks = taosArrayGetSize(pTaskList);
59,394✔
431
  if (pNumOfTasks != NULL) {
59,394!
432
    *pNumOfTasks = numOfTasks;
59,394✔
433
  }
434

435
  tqDebug("vgId:%d start to check wal to extract new submit block for %d tasks", vgId, numOfTasks);
59,394!
436

437
  for (int32_t i = 0; i < numOfTasks; ++i) {
312,907✔
438
    STaskId* pTaskId = taosArrayGet(pTaskList, i);
253,509✔
439
    if (pTaskId == NULL) {
253,509!
440
      continue;
182,268✔
441
    }
442

443
    SStreamTask* pTask = NULL;
253,509✔
444
    int32_t      code = streamMetaAcquireTask(pStreamMeta, pTaskId->streamId, pTaskId->taskId, &pTask);
253,509✔
445
    if (pTask == NULL || code != 0) {
253,505!
446
      continue;
5,156✔
447
    }
448

449
    if (!taskReadyForDataFromWal(pTask)) {
248,349✔
450
      streamMetaReleaseTask(pStreamMeta, pTask);
177,108✔
451
      continue;
177,112✔
452
    }
453

454
    // seek the stored version and extract data from WAL
455
    code = setWalReaderStartOffset(pTask, vgId);
71,242✔
456
    if (code != TSDB_CODE_SUCCESS) {
71,245!
457
      streamMetaReleaseTask(pStreamMeta, pTask);
×
458
      continue;
×
459
    }
460

461
    int32_t numOfItems = streamQueueGetNumOfItems(pTask->inputq.queue);
71,245✔
462
    int64_t maxVer = (pTask->info.fillHistory == 1) ? pTask->step2Range.maxVer : INT64_MAX;
71,245✔
463

464
    streamMutexLock(&pTask->lock);
71,245✔
465

466
    SStreamTaskState state = streamTaskGetStatus(pTask);
71,244✔
467
    if (state.state != TASK_STATUS__READY) {
71,244!
468
      tqDebug("s-task:%s not ready for submit block from wal, status:%s", pTask->id.idStr, state.name);
×
469
      streamMutexUnlock(&pTask->lock);
×
470
      streamMetaReleaseTask(pStreamMeta, pTask);
×
471
      continue;
×
472
    }
473

474
    bool hasNewData = false;
71,244✔
475
    code = doPutDataIntoInputQ(pTask, maxVer, &numOfItems, &hasNewData);
71,244✔
476
    streamMutexUnlock(&pTask->lock);
71,245✔
477

478
    TAOS_UNUSED(code);
479

480
    if ((numOfItems > 0) || hasNewData) {
71,243!
481
      code = streamTrySchedExec(pTask, false);
7,368✔
482
      if (code != TSDB_CODE_SUCCESS) {
7,367!
483
        streamMetaReleaseTask(pStreamMeta, pTask);
×
484
        taosArrayDestroy(pTaskList);
×
485
        return code;
×
486
      }
487
    }
488

489
    streamMetaReleaseTask(pStreamMeta, pTask);
71,242✔
490
  }
491

492
  taosArrayDestroy(pTaskList);
59,398✔
493
  return TSDB_CODE_SUCCESS;
59,389✔
494
}
495

496
void streamMetaFreeTQDuringScanWalError(STQ* pTq) {
×
497
  SBuildScanWalMsgParam* p = taosMemoryCalloc(1, sizeof(SBuildScanWalMsgParam));
×
498
  p->metaId = pTq->pStreamMeta->rid;
×
499

500
  doStartScanWal(p, 0);
×
501
}
×
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