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

taosdata / TDengine / #3633

11 Mar 2025 12:59PM UTC coverage: 0.0% (-60.7%) from 60.719%
#3633

push

travis-ci

web-flow
Merge pull request #30118 from taosdata/wl30

udpate ci workflow

0 of 280412 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 275582 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/source/dnode/vnode/src/tq/tqUtil.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

18
static int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq,
19
                                 const SMqMetaRsp* pRsp, int32_t vgId);
20
static int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq,
21
                                      const SMqBatchMetaRsp* pRsp, int32_t vgId);
22

23
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset) {
×
24
  int32_t    code = TDB_CODE_SUCCESS;
×
25
  int32_t    lino = 0;
×
26
  tqDebug("%s called", __FUNCTION__ );
×
27
  TSDB_CHECK_NULL(pRsp, code, lino, END, TSDB_CODE_INVALID_PARA);
×
28

29
  pRsp->blockData = taosArrayInit(0, sizeof(void*));
×
30
  TSDB_CHECK_NULL(pRsp->blockData, code, lino, END, terrno);
×
31

32
  pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t));
×
33
  TSDB_CHECK_NULL(pRsp->blockDataLen, code, lino, END, terrno);
×
34

35
  tOffsetCopy(&pRsp->reqOffset, &pOffset);
×
36
  tOffsetCopy(&pRsp->rspOffset, &pOffset);
×
37
  pRsp->withTbName = 0;
×
38
  pRsp->withSchema = false;
×
39

40
END:
×
41
  if (code != 0){
×
42
    tqError("%s failed at:%d, code:%s", __FUNCTION__ , lino, tstrerror(code));
×
43
  }
44
  return code;
×
45
}
46

47
void tqUpdateNodeStage(STQ* pTq, bool isLeader) {
×
48
  SSyncState state = syncGetState(pTq->pVnode->sync);
×
49
  streamMetaUpdateStageRole(pTq->pStreamMeta, state.term, isLeader);
×
50

51
  if (isLeader) {
×
52
    tqScanWalAsync(pTq);
×
53
  }
54
}
×
55

56
static int32_t tqInitTaosxRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset) {
×
57
  int32_t    code = TDB_CODE_SUCCESS;
×
58
  int32_t    lino = 0;
×
59
  tqDebug("%s called", __FUNCTION__ );
×
60
  TSDB_CHECK_NULL(pRsp, code, lino, END, TSDB_CODE_INVALID_PARA);
×
61
  tOffsetCopy(&pRsp->reqOffset, &pOffset);
×
62
  tOffsetCopy(&pRsp->rspOffset, &pOffset);
×
63

64
  pRsp->withTbName = 1;
×
65
  pRsp->withSchema = 1;
×
66
  pRsp->blockData = taosArrayInit(0, sizeof(void*));
×
67
  TSDB_CHECK_NULL(pRsp->blockData, code, lino, END, terrno);\
×
68

69
  pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t));
×
70
  TSDB_CHECK_NULL(pRsp->blockDataLen, code, lino, END, terrno);
×
71

72
  pRsp->blockTbName = taosArrayInit(0, sizeof(void*));
×
73
  TSDB_CHECK_NULL(pRsp->blockTbName, code, lino, END, terrno);
×
74

75
  pRsp->blockSchema = taosArrayInit(0, sizeof(void*));
×
76
  TSDB_CHECK_NULL(pRsp->blockSchema, code, lino, END, terrno);
×
77

78

79
END:
×
80
  if (code != 0){
×
81
    tqError("%s failed at:%d, code:%s", __FUNCTION__ , lino, tstrerror(code));
×
82
    taosArrayDestroy(pRsp->blockData);
×
83
    taosArrayDestroy(pRsp->blockDataLen);
×
84
    taosArrayDestroy(pRsp->blockTbName);
×
85
    taosArrayDestroy(pRsp->blockSchema);
×
86
  }
87
  return code;
×
88
}
89

90
static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
×
91
                                     SRpcMsg* pMsg, bool* pBlockReturned) {
92
  if (pOffsetVal == NULL || pTq == NULL || pHandle == NULL || pRequest == NULL || pMsg == NULL || pBlockReturned == NULL) {
×
93
    return TSDB_CODE_INVALID_PARA;
×
94
  }
95
  uint64_t   consumerId = pRequest->consumerId;
×
96
  STqOffset* pOffset = NULL;
×
97
  int32_t    code = tqMetaGetOffset(pTq, pRequest->subKey, &pOffset);
×
98
  int32_t    vgId = TD_VID(pTq->pVnode);
×
99

100
  *pBlockReturned = false;
×
101
  // In this vnode, data has been polled by consumer for this topic, so let's continue from the last offset value.
102
  if (code == 0) {
×
103
    tOffsetCopy(pOffsetVal, &pOffset->val);
×
104

105
    char formatBuf[TSDB_OFFSET_LEN] = {0};
×
106
    tFormatOffset(formatBuf, TSDB_OFFSET_LEN, pOffsetVal);
×
107
    tqDebug("tmq poll: consumer:0x%" PRIx64
×
108
                ", subkey %s, vgId:%d, existed offset found, offset reset to %s and continue.QID:0x%" PRIx64,
109
            consumerId, pHandle->subKey, vgId, formatBuf, pRequest->reqId);
110
    return 0;
×
111
  } else {
112
    // no poll occurs in this vnode for this topic, let's seek to the right offset value.
113
    if (pRequest->reqOffset.type == TMQ_OFFSET__RESET_EARLIEST) {
×
114
      if (pRequest->useSnapshot) {
×
115
        tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey:%s, vgId:%d, (earliest) set offset to be snapshot",
×
116
                consumerId, pHandle->subKey, vgId);
117
        if (pHandle->fetchMeta) {
×
118
          tqOffsetResetToMeta(pOffsetVal, 0);
119
        } else {
120
          SValue val = {0};
×
121
          tqOffsetResetToData(pOffsetVal, 0, 0, val);
×
122
        }
123
      } else {
124
        walRefFirstVer(pTq->pVnode->pWal, pHandle->pRef);
×
125
        tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer);
×
126
      }
127
    } else if (pRequest->reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
×
128
      walRefLastVer(pTq->pVnode->pWal, pHandle->pRef);
×
129
      SMqDataRsp dataRsp = {0};
×
130
      tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
×
131

132
      code = tqInitDataRsp(&dataRsp, *pOffsetVal);
×
133
      if (code != 0) {
×
134
        return code;
×
135
      }
136
      tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId,
×
137
              pHandle->subKey, vgId, dataRsp.rspOffset.version);
138
      code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, (pRequest->rawData == 1) ? TMQ_MSG_TYPE__POLL_RAW_DATA_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
×
139
      tDeleteMqDataRsp(&dataRsp);
×
140

141
      *pBlockReturned = true;
×
142
      return code;
×
143
    } else if (pRequest->reqOffset.type == TMQ_OFFSET__RESET_NONE) {
×
144
      tqError("tmq poll: subkey:%s, no offset committed for consumer:0x%" PRIx64
×
145
                  " in vg %d, subkey %s, reset none failed",
146
              pHandle->subKey, consumerId, vgId, pRequest->subKey);
147
      return TSDB_CODE_TQ_NO_COMMITTED_OFFSET;
×
148
    }
149
  }
150

151
  return 0;
×
152
}
153

154
static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
×
155
                                                   SRpcMsg* pMsg, STqOffsetVal* pOffset) {
156
  int32_t    code = TDB_CODE_SUCCESS;
×
157
  int32_t    lino = 0;
×
158
  tqDebug("%s called", __FUNCTION__ );
×
159
  uint64_t consumerId = pRequest->consumerId;
×
160
  int32_t  vgId = TD_VID(pTq->pVnode);
×
161
  terrno = 0;
×
162

163
  SMqDataRsp dataRsp = {0};
×
164
  code = tqInitDataRsp(&dataRsp, *pOffset);
×
165
  TSDB_CHECK_CODE(code, lino, end);
×
166

167
  code = qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
×
168
  TSDB_CHECK_CODE(code, lino, end);
×
169

170
  code = tqScanData(pTq, pHandle, &dataRsp, pOffset, pRequest);
×
171
  if (code != 0 && terrno != TSDB_CODE_WAL_LOG_NOT_EXIST) {
×
172
    goto end;
×
173
  }
174

175
  //   till now, all data has been transferred to consumer, new data needs to push client once arrived.
176
  if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST && dataRsp.blockNum == 0) {
×
177
    // lock
178
    taosWLockLatch(&pTq->lock);
×
179
    int64_t ver = walGetCommittedVer(pTq->pVnode->pWal);
×
180
    if (dataRsp.rspOffset.version > ver) {  // check if there are data again to avoid lost data
×
181
      code = tqRegisterPushHandle(pTq, pHandle, pMsg);
×
182
      taosWUnLockLatch(&pTq->lock);
×
183
      goto end;
×
184
    }
185
    taosWUnLockLatch(&pTq->lock);
×
186
  }
187

188
  // reqOffset represents the current date offset, may be changed if wal not exists
189
  tOffsetCopy(&dataRsp.reqOffset, pOffset);
×
190
  code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
×
191

192
end:
×
193
  {
194
    char buf[TSDB_OFFSET_LEN] = {0};
×
195
    tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.rspOffset);
×
196
    if (code != 0){
×
197
      tqError("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, QID:0x%" PRIx64 " error msg:%s, line:%d",
×
198
              consumerId, pHandle->subKey, vgId, dataRsp.blockNum, buf, pRequest->reqId, tstrerror(code), lino);
199
    } else {
200
      tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, QID:0x%" PRIx64 " success",
×
201
              consumerId, pHandle->subKey, vgId, dataRsp.blockNum, buf, pRequest->reqId);
202
    }
203

204
    tDeleteMqDataRsp(&dataRsp);
×
205
    return code;
×
206
  }
207
}
208

209
#define PROCESS_EXCLUDED_MSG(TYPE, DECODE_FUNC, DELETE_FUNC)                                               \
210
  SDecoder decoder = {0};                                                                                  \
211
  TYPE     req = {0};                                                                                      \
212
  void*    data = POINTER_SHIFT(pHead->body, sizeof(SMsgHead));                                            \
213
  int32_t  len = pHead->bodyLen - sizeof(SMsgHead);                                                        \
214
  tDecoderInit(&decoder, data, len);                                                                       \
215
  if (DECODE_FUNC(&decoder, &req) == 0 && (req.source & TD_REQ_FROM_TAOX) != 0) {                          \
216
    tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d) iter log, jump meta for, vgId:%d offset %" PRId64 \
217
            " msgType %d",                                                                                 \
218
            pRequest->consumerId, pRequest->epoch, vgId, fetchVer, pHead->msgType);                        \
219
    fetchVer++;                                                                                            \
220
    DELETE_FUNC(&req);                                                                                     \
221
    tDecoderClear(&decoder);                                                                               \
222
    continue;                                                                                              \
223
  }                                                                                                        \
224
  DELETE_FUNC(&req);                                                                                       \
225
  tDecoderClear(&decoder);
226

227
static void tDeleteCommon(void* parm) {}
×
228

229
#define POLL_RSP_TYPE(pRequest,taosxRsp) \
230
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : \
231
(pRequest->rawData == 1 ? TMQ_MSG_TYPE__POLL_RAW_DATA_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP)
232

233
static int32_t buildBatchMeta(SMqBatchMetaRsp *btMetaRsp, int16_t type, int32_t bodyLen, void* body){
×
234
  int32_t         code = 0;
×
235

236
  if (!btMetaRsp->batchMetaReq) {
×
237
    btMetaRsp->batchMetaReq = taosArrayInit(4, POINTER_BYTES);
×
238
    TQ_NULL_GO_TO_END(btMetaRsp->batchMetaReq);
×
239
    btMetaRsp->batchMetaLen = taosArrayInit(4, sizeof(int32_t));
×
240
    TQ_NULL_GO_TO_END(btMetaRsp->batchMetaLen);
×
241
  }
242

243
  SMqMetaRsp tmpMetaRsp = {0};
×
244
  tmpMetaRsp.resMsgType = type;
×
245
  tmpMetaRsp.metaRspLen = bodyLen;
×
246
  tmpMetaRsp.metaRsp = body;
×
247
  uint32_t len = 0;
×
248
  tEncodeSize(tEncodeMqMetaRsp, &tmpMetaRsp, len, code);
×
249
  if (TSDB_CODE_SUCCESS != code) {
×
250
    tqError("tmq extract meta from log, tEncodeMqMetaRsp error");
×
251
    goto END;
×
252
  }
253
  int32_t tLen = sizeof(SMqRspHead) + len;
×
254
  void*   tBuf = taosMemoryCalloc(1, tLen);
×
255
  TQ_NULL_GO_TO_END(tBuf);
×
256
  void*    metaBuff = POINTER_SHIFT(tBuf, sizeof(SMqRspHead));
×
257
  SEncoder encoder = {0};
×
258
  tEncoderInit(&encoder, metaBuff, len);
×
259
  code = tEncodeMqMetaRsp(&encoder, &tmpMetaRsp);
×
260
  tEncoderClear(&encoder);
×
261

262
  if (code < 0) {
×
263
    tqError("tmq extract meta from log, tEncodeMqMetaRsp error");
×
264
    goto END;
×
265
  }
266
  TQ_NULL_GO_TO_END (taosArrayPush(btMetaRsp->batchMetaReq, &tBuf));
×
267
  TQ_NULL_GO_TO_END (taosArrayPush(btMetaRsp->batchMetaLen, &tLen));
×
268

269
END:
×
270
  return code;
×
271
}
272

273
static int32_t buildCreateTbBatchReqBinary(SMqDataRsp *taosxRsp, void** pBuf, int32_t *len){
×
274
  int32_t code = 0;
×
275
  SVCreateTbBatchReq pReq = {0};
×
276
  pReq.nReqs = taosArrayGetSize(taosxRsp->createTableReq);
×
277
  pReq.pArray = taosArrayInit(1, sizeof(struct SVCreateTbReq));
×
278
  TQ_NULL_GO_TO_END(pReq.pArray);
×
279
  for (int i = 0; i < taosArrayGetSize(taosxRsp->createTableReq); i++){
×
280
    void   *createTableReq = taosArrayGetP(taosxRsp->createTableReq, i);
×
281
    TQ_NULL_GO_TO_END(taosArrayPush(pReq.pArray, createTableReq));
×
282
  }
283
  tEncodeSize(tEncodeSVCreateTbBatchReq, &pReq, *len, code);
×
284
  if (code < 0) {
×
285
    goto END;
×
286
  }
287
  *len += sizeof(SMsgHead);
×
288
  *pBuf = taosMemoryMalloc(*len);
×
289
  TQ_NULL_GO_TO_END(pBuf);
×
290
  SEncoder coder = {0};
×
291
  tEncoderInit(&coder, POINTER_SHIFT(*pBuf, sizeof(SMsgHead)), *len);
×
292
  code = tEncodeSVCreateTbBatchReq(&coder, &pReq);
×
293
  tEncoderClear(&coder);
×
294

295
END:
×
296
  taosArrayDestroy(pReq.pArray);
×
297
  return code;
×
298
}
299

300
#define SEND_BATCH_META_RSP \
301
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);\
302
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);\
303
goto END;
304

305
#define SEND_DATA_RSP \
306
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);\
307
code = tqSendDataRsp(pHandle, pMsg, pRequest, &taosxRsp, POLL_RSP_TYPE(pRequest, taosxRsp), vgId);\
308
goto END;
309
static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
×
310
                                                  SRpcMsg* pMsg, STqOffsetVal* offset) {
311
  int32_t         vgId = TD_VID(pTq->pVnode);
×
312
  SMqDataRsp      taosxRsp = {0};
×
313
  SMqBatchMetaRsp btMetaRsp = {0};
×
314
  int32_t         code = 0;
×
315

316
  TQ_ERR_GO_TO_END(tqInitTaosxRsp(&taosxRsp, *offset));
×
317
  if (offset->type != TMQ_OFFSET__LOG) {
×
318
    TQ_ERR_GO_TO_END(tqScanTaosx(pTq, pHandle, &taosxRsp, &btMetaRsp, offset, pRequest));
×
319

320
    if (taosArrayGetSize(btMetaRsp.batchMetaReq) > 0) {
×
321
      code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
×
322
      tqDebug("tmq poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send meta offset type:%d,uid:%" PRId64 ",ts:%" PRId64,
×
323
              pRequest->consumerId, pHandle->subKey, vgId, btMetaRsp.rspOffset.type, btMetaRsp.rspOffset.uid,btMetaRsp.rspOffset.ts);
324
      goto END;
×
325
    }
326

327
    tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64",ts:%" PRId64,
×
328
            pRequest->consumerId, pHandle->subKey, vgId, taosxRsp.blockNum, taosxRsp.rspOffset.type, taosxRsp.rspOffset.uid, taosxRsp.rspOffset.ts);
329
    if (taosxRsp.blockNum > 0) {
×
330
      code = tqSendDataRsp(pHandle, pMsg, pRequest, &taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
×
331
      goto END;
×
332
    } else {
333
      tOffsetCopy(offset, &taosxRsp.rspOffset);
×
334
    }
335
  }
336

337
  if (offset->type == TMQ_OFFSET__LOG) {
×
338
    walReaderVerifyOffset(pHandle->pWalReader, offset);
×
339
    int64_t fetchVer = offset->version;
×
340

341
    uint64_t st = taosGetTimestampMs();
×
342
    int      totalRows = 0;
×
343
    int32_t  totalMetaRows = 0;
×
344
    while (1) {
×
345
      int32_t savedEpoch = atomic_load_32(&pHandle->epoch);
×
346
      if (savedEpoch > pRequest->epoch) {
×
347
        tqError("tmq poll: consumer:0x%" PRIx64 " (epoch %d) iter log, savedEpoch error, vgId:%d offset %" PRId64,
×
348
                pRequest->consumerId, pRequest->epoch, vgId, fetchVer);
349
        code = TSDB_CODE_TQ_INTERNAL_ERROR;
×
350
        goto END;
×
351
      }
352

353
      if (tqFetchLog(pTq, pHandle, &fetchVer, pRequest->reqId) < 0) {
×
354
        if (totalMetaRows > 0) {
×
355
          SEND_BATCH_META_RSP
×
356
        }
357
        SEND_DATA_RSP
×
358
      }
359

360
      SWalCont* pHead = &pHandle->pWalReader->pHead->head;
×
361
      tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d) iter log, vgId:%d offset %" PRId64 " msgType %s",
×
362
              pRequest->consumerId, pRequest->epoch, vgId, fetchVer, TMSG_INFO(pHead->msgType));
363

364
      // process meta
365
      if (pHead->msgType != TDMT_VND_SUBMIT) {
×
366
        if (totalRows > 0) {
×
367
          SEND_DATA_RSP
×
368
        }
369

370
        if ((pRequest->sourceExcluded & TD_REQ_FROM_TAOX) != 0) {
×
371
          if (pHead->msgType == TDMT_VND_CREATE_TABLE) {
×
372
            PROCESS_EXCLUDED_MSG(SVCreateTbBatchReq, tDecodeSVCreateTbBatchReq, tDeleteSVCreateTbBatchReq)
×
373
          } else if (pHead->msgType == TDMT_VND_ALTER_TABLE) {
×
374
            PROCESS_EXCLUDED_MSG(SVAlterTbReq, tDecodeSVAlterTbReq, tDeleteCommon)
×
375
          } else if (pHead->msgType == TDMT_VND_CREATE_STB || pHead->msgType == TDMT_VND_ALTER_STB) {
×
376
            PROCESS_EXCLUDED_MSG(SVCreateStbReq, tDecodeSVCreateStbReq, tDeleteCommon)
×
377
          } else if (pHead->msgType == TDMT_VND_DELETE) {
×
378
            PROCESS_EXCLUDED_MSG(SDeleteRes, tDecodeDeleteRes, tDeleteCommon)
×
379
          }
380
        }
381

382
        tqDebug("fetch meta msg, ver:%" PRId64 ", vgId:%d, type:%s, enable batch meta:%d", pHead->version, vgId,
×
383
                TMSG_INFO(pHead->msgType), pRequest->enableBatchMeta);
384
        if (!pRequest->enableBatchMeta && !pRequest->useSnapshot) {
×
385
          SMqMetaRsp metaRsp = {0};
×
386
          tqOffsetResetToLog(&metaRsp.rspOffset, fetchVer + 1);
×
387
          metaRsp.resMsgType = pHead->msgType;
×
388
          metaRsp.metaRspLen = pHead->bodyLen;
×
389
          metaRsp.metaRsp = pHead->body;
×
390
          code = tqSendMetaPollRsp(pHandle, pMsg, pRequest, &metaRsp, vgId);
×
391
          goto END;
×
392
        }
393
        code = buildBatchMeta(&btMetaRsp, pHead->msgType, pHead->bodyLen, pHead->body);
×
394
        fetchVer++;
×
395
        if (code != 0){
×
396
          goto END;
×
397
        }
398
        totalMetaRows++;
×
399
        if ((taosArrayGetSize(btMetaRsp.batchMetaReq) >= tmqRowSize) || (taosGetTimestampMs() - st > pRequest->timeout)) {
×
400
          SEND_BATCH_META_RSP
×
401
        }
402
        continue;
×
403
      }
404

405
      if (totalMetaRows > 0 && pHandle->fetchMeta != ONLY_META) {
×
406
        SEND_BATCH_META_RSP
×
407
      }
408

409
      // process data
410
      SPackedData submit = {
×
411
          .msgStr = POINTER_SHIFT(pHead->body, sizeof(SSubmitReq2Msg)),
×
412
          .msgLen = pHead->bodyLen - sizeof(SSubmitReq2Msg),
×
413
          .ver = pHead->version,
×
414
      };
415

416
      TQ_ERR_GO_TO_END(tqTaosxScanLog(pTq, pHandle, submit, &taosxRsp, &totalRows, pRequest));
×
417

418
      if (pHandle->fetchMeta == ONLY_META && taosArrayGetSize(taosxRsp.createTableReq) > 0){
×
419
        int32_t len = 0;
×
420
        void *pBuf = NULL;
×
421
        code = buildCreateTbBatchReqBinary(&taosxRsp, &pBuf, &len);
×
422
        if (code == 0){
×
423
          code = buildBatchMeta(&btMetaRsp, TDMT_VND_CREATE_TABLE, len, pBuf);
×
424
        }
425
        taosMemoryFree(pBuf);
×
426
        taosArrayDestroyP(taosxRsp.createTableReq, NULL);
×
427
        taosxRsp.createTableReq = NULL;
×
428
        fetchVer++;
×
429
        if (code != 0){
×
430
          goto END;
×
431
        }
432
        totalMetaRows++;
×
433
        if ((taosArrayGetSize(btMetaRsp.batchMetaReq) >= tmqRowSize) ||
×
434
            (taosGetTimestampMs() - st > pRequest->timeout) ||
×
435
            (!pRequest->enableBatchMeta && !pRequest->useSnapshot)) {
×
436
          SEND_BATCH_META_RSP
×
437
        }
438
        continue;
×
439
      }
440

441
      if ((pRequest->rawData == 0 && totalRows >= pRequest->minPollRows) ||
×
442
          (taosGetTimestampMs() - st > pRequest->timeout) ||
×
443
          (pRequest->rawData != 0 && (taosArrayGetSize(taosxRsp.blockData) > pRequest->minPollRows ||
×
444
                                      terrno == TSDB_CODE_TMQ_RAW_DATA_SPLIT))) {
×
445
        if (terrno == TSDB_CODE_TMQ_RAW_DATA_SPLIT){
×
446
          terrno = 0;
×
447
        } else{
448
          fetchVer++;
×
449
        }
450
        SEND_DATA_RSP
×
451
      } else {
452
        fetchVer++;
×
453
      }
454
    }
455
  }
456

457
END:
×
458
  if (code != 0){
×
459
    tqError("tmq poll: tqTaosxScanLog error. consumerId:0x%" PRIx64 ", in vgId:%d, subkey %s", pRequest->consumerId, vgId,
×
460
            pRequest->subKey);
461
  }
462
  tDeleteMqBatchMetaRsp(&btMetaRsp);
×
463
  tDeleteSTaosxRsp(&taosxRsp);
×
464
  return code;
×
465
}
466

467
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg) {
×
468
  if (pTq == NULL || pHandle == NULL || pRequest == NULL || pMsg == NULL) {
×
469
    return TSDB_CODE_TMQ_INVALID_MSG;
×
470
  }
471
  int32_t      code = 0;
×
472
  STqOffsetVal reqOffset = {0};
×
473
  tOffsetCopy(&reqOffset, &pRequest->reqOffset);
×
474

475
  // reset the offset if needed
476
  if (IS_OFFSET_RESET_TYPE(pRequest->reqOffset.type)) {
×
477
    bool blockReturned = false;
×
478
    code = extractResetOffsetVal(&reqOffset, pTq, pHandle, pRequest, pMsg, &blockReturned);
×
479
    if (code != 0) {
×
480
      goto END;
×
481
    }
482

483
    // empty block returned, quit
484
    if (blockReturned) {
×
485
      goto END;
×
486
    }
487
  } else if (reqOffset.type == 0) {  // use the consumer specified offset
×
488
    uError("req offset type is 0");
×
489
    code = TSDB_CODE_TMQ_INVALID_MSG;
×
490
    goto END;
×
491
  }
492

493
  if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
×
494
    code = extractDataAndRspForNormalSubscribe(pTq, pHandle, pRequest, pMsg, &reqOffset);
×
495
  } else {
496
    code = extractDataAndRspForDbStbSubscribe(pTq, pHandle, pRequest, pMsg, &reqOffset);
×
497
  }
498

499
END:
×
500
  if (code != 0){
×
501
    uError("failed to extract data for mq, msg:%s", tstrerror(code));
×
502
  }
503
  tOffsetDestroy(&reqOffset);
×
504
  return code;
×
505
}
506

507
static void initMqRspHead(SMqRspHead* pMsgHead, int32_t type, int32_t epoch, int64_t consumerId, int64_t sver,
×
508
                          int64_t ever) {
509
  if (pMsgHead == NULL) {
×
510
    return;
×
511
  }
512
  pMsgHead->consumerId = consumerId;
×
513
  pMsgHead->epoch = epoch;
×
514
  pMsgHead->mqMsgType = type;
×
515
  pMsgHead->walsver = sver;
×
516
  pMsgHead->walever = ever;
×
517
}
518

519
int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq,
×
520
                               const SMqBatchMetaRsp* pRsp, int32_t vgId) {
521
  if (pHandle == NULL || pMsg == NULL || pReq == NULL || pRsp == NULL) {
×
522
    return TSDB_CODE_TMQ_INVALID_MSG;
×
523
  }
524
  int32_t len = 0;
×
525
  int32_t code = 0;
×
526
  tEncodeSize(tEncodeMqBatchMetaRsp, pRsp, len, code);
×
527
  if (code < 0) {
×
528
    return TAOS_GET_TERRNO(code);
×
529
  }
530
  int32_t tlen = sizeof(SMqRspHead) + len;
×
531
  void*   buf = rpcMallocCont(tlen);
×
532
  if (buf == NULL) {
×
533
    return TAOS_GET_TERRNO(terrno);
×
534
  }
535

536
  int64_t sver = 0, ever = 0;
×
537
  walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
×
538
  initMqRspHead(buf, TMQ_MSG_TYPE__POLL_BATCH_META_RSP, pReq->epoch, pReq->consumerId, sver, ever);
×
539

540
  void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead));
×
541

542
  SEncoder encoder = {0};
×
543
  tEncoderInit(&encoder, abuf, len);
×
544
  code = tEncodeMqBatchMetaRsp(&encoder, pRsp);
×
545
  tEncoderClear(&encoder);
×
546
  if (code < 0) {
×
547
    rpcFreeCont(buf);
×
548
    return TAOS_GET_TERRNO(code);
×
549
  }
550
  SRpcMsg resp = {.info = pMsg->info, .pCont = buf, .contLen = tlen, .code = 0};
×
551

552
  tmsgSendRsp(&resp);
×
553
  tqDebug("vgId:%d, from consumer:0x%" PRIx64 " (epoch %d) send rsp, res msg type: batch meta, size:%ld offset type:%d",
×
554
          vgId, pReq->consumerId, pReq->epoch, taosArrayGetSize(pRsp->batchMetaReq), pRsp->rspOffset.type);
555

556
  return 0;
×
557
}
558

559
int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqMetaRsp* pRsp,
×
560
                          int32_t vgId) {
561
  if (pHandle == NULL || pMsg == NULL || pReq == NULL || pRsp == NULL) {
×
562
    return TSDB_CODE_TMQ_INVALID_MSG;
×
563
  }
564
  int32_t len = 0;
×
565
  int32_t code = 0;
×
566
  tEncodeSize(tEncodeMqMetaRsp, pRsp, len, code);
×
567
  if (code < 0) {
×
568
    return TAOS_GET_TERRNO(code);
×
569
  }
570
  int32_t tlen = sizeof(SMqRspHead) + len;
×
571
  void*   buf = rpcMallocCont(tlen);
×
572
  if (buf == NULL) {
×
573
    return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
×
574
  }
575

576
  int64_t sver = 0, ever = 0;
×
577
  walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
×
578
  initMqRspHead(buf, TMQ_MSG_TYPE__POLL_META_RSP, pReq->epoch, pReq->consumerId, sver, ever);
×
579

580
  void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead));
×
581

582
  SEncoder encoder = {0};
×
583
  tEncoderInit(&encoder, abuf, len);
×
584
  code = tEncodeMqMetaRsp(&encoder, pRsp);
×
585
  tEncoderClear(&encoder);
×
586
  if (code < 0) {
×
587
    rpcFreeCont(buf);
×
588
    return TAOS_GET_TERRNO(code);
×
589
  }
590

591
  SRpcMsg resp = {.info = pMsg->info, .pCont = buf, .contLen = tlen, .code = 0};
×
592

593
  tmsgSendRsp(&resp);
×
594
  tqDebug("vgId:%d, from consumer:0x%" PRIx64 " (epoch %d) send rsp, res msg type %d, offset type:%d", vgId,
×
595
          pReq->consumerId, pReq->epoch, pRsp->resMsgType, pRsp->rspOffset.type);
596

597
  return 0;
×
598
}
599

600
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, SMqDataRsp* pRsp, int32_t epoch, int64_t consumerId,
×
601
                        int32_t type, int64_t sver, int64_t ever) {
602
  if (pRpcHandleInfo == NULL || pRsp == NULL) {
×
603
    return TSDB_CODE_TMQ_INVALID_MSG;
×
604
  }
605
  int32_t len = 0;
×
606
  int32_t code = 0;
×
607

608
  if (type == TMQ_MSG_TYPE__POLL_RAW_DATA_RSP){
×
609
    pRsp->withSchema = 0;
×
610
  }
611
  if (type == TMQ_MSG_TYPE__POLL_DATA_RSP ||
×
612
      type == TMQ_MSG_TYPE__WALINFO_RSP ||
×
613
      type == TMQ_MSG_TYPE__POLL_RAW_DATA_RSP) {
614
    tEncodeSize(tEncodeMqDataRsp, pRsp, len, code);
×
615
  } else if (type == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
×
616
    tEncodeSize(tEncodeSTaosxRsp, pRsp, len, code);
×
617
  }
618

619
  if (code < 0) {
×
620
    return TAOS_GET_TERRNO(code);
×
621
  }
622

623
  int32_t tlen = sizeof(SMqRspHead) + len;
×
624
  void*   buf = rpcMallocCont(tlen);
×
625
  if (buf == NULL) {
×
626
    return terrno;
×
627
  }
628

629
  SMqRspHead* pHead = (SMqRspHead*)buf;
×
630
  initMqRspHead(pHead, type, epoch, consumerId, sver, ever);
×
631

632
  void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead));
×
633

634
  SEncoder encoder = {0};
×
635
  tEncoderInit(&encoder, abuf, len);
×
636

637
  if (type == TMQ_MSG_TYPE__POLL_DATA_RSP ||
×
638
      type == TMQ_MSG_TYPE__WALINFO_RSP ||
×
639
      type == TMQ_MSG_TYPE__POLL_RAW_DATA_RSP) {
640
    code = tEncodeMqDataRsp(&encoder, pRsp);
×
641
  } else if (type == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
×
642
    code = tEncodeSTaosxRsp(&encoder, pRsp);
×
643
  }
644
  tEncoderClear(&encoder);
×
645
  if (code < 0) {
×
646
    rpcFreeCont(buf);
×
647
    return TAOS_GET_TERRNO(code);
×
648
  }
649
  SRpcMsg rsp = {.info = *pRpcHandleInfo, .pCont = buf, .contLen = tlen, .code = 0};
×
650

651
  tmsgSendRsp(&rsp);
×
652
  return 0;
×
653
}
654

655
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type, EStreamType blockType) {
×
656
  int32_t     code = 0;
×
657
  int32_t     line = 0;
×
658
  SDecoder*   pCoder = &(SDecoder){0};
×
659
  SDeleteRes* pRes = &(SDeleteRes){0};
×
660

661
  *pRefBlock = NULL;
×
662

663
  pRes->uidList = taosArrayInit(0, sizeof(tb_uid_t));
×
664
  TSDB_CHECK_NULL(pRes->uidList, code, line, END, terrno)
×
665

666
  tDecoderInit(pCoder, (uint8_t*)pData, len);
×
667
  code = tDecodeDeleteRes(pCoder, pRes);
×
668
  TSDB_CHECK_CODE(code, line, END);
×
669

670
  int32_t numOfTables = taosArrayGetSize(pRes->uidList);
×
671
  if (numOfTables == 0 || pRes->affectedRows == 0) {
×
672
    goto END;
×
673
  }
674

675
  SSDataBlock* pDelBlock = NULL;
×
676
  code = createSpecialDataBlock(blockType, &pDelBlock);
×
677
  TSDB_CHECK_CODE(code, line, END);
×
678

679
  code = blockDataEnsureCapacity(pDelBlock, numOfTables);
×
680
  TSDB_CHECK_CODE(code, line, END);
×
681

682
  pDelBlock->info.rows = numOfTables;
×
683
  pDelBlock->info.version = ver;
×
684

685
  for (int32_t i = 0; i < numOfTables; i++) {
×
686
    // start key column
687
    SColumnInfoData* pStartCol = taosArrayGet(pDelBlock->pDataBlock, START_TS_COLUMN_INDEX);
×
688
    TSDB_CHECK_NULL(pStartCol, code, line, END, terrno)
×
689
    code = colDataSetVal(pStartCol, i, (const char*)&pRes->skey, false);  // end key column
×
690
    TSDB_CHECK_CODE(code, line, END);
×
691
    SColumnInfoData* pEndCol = taosArrayGet(pDelBlock->pDataBlock, END_TS_COLUMN_INDEX);
×
692
    TSDB_CHECK_NULL(pEndCol, code, line, END, terrno)
×
693
    code = colDataSetVal(pEndCol, i, (const char*)&pRes->ekey, false);
×
694
    TSDB_CHECK_CODE(code, line, END);
×
695
    // uid column
696
    SColumnInfoData* pUidCol = taosArrayGet(pDelBlock->pDataBlock, UID_COLUMN_INDEX);
×
697
    TSDB_CHECK_NULL(pUidCol, code, line, END, terrno)
×
698

699
    int64_t* pUid = taosArrayGet(pRes->uidList, i);
×
700
    code = colDataSetVal(pUidCol, i, (const char*)pUid, false);
×
701
    TSDB_CHECK_CODE(code, line, END);
×
702
    void* tmp = taosArrayGet(pDelBlock->pDataBlock, GROUPID_COLUMN_INDEX);
×
703
    TSDB_CHECK_NULL(tmp, code, line, END, terrno)
×
704
    colDataSetNULL(tmp, i);
×
705
    tmp = taosArrayGet(pDelBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
×
706
    TSDB_CHECK_NULL(tmp, code, line, END, terrno)
×
707
    colDataSetNULL(tmp, i);
×
708
    tmp = taosArrayGet(pDelBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
×
709
    TSDB_CHECK_NULL(tmp, code, line, END, terrno)
×
710
    colDataSetNULL(tmp, i);
×
711
    tmp = taosArrayGet(pDelBlock->pDataBlock, TABLE_NAME_COLUMN_INDEX);
×
712
    TSDB_CHECK_NULL(tmp, code, line, END, terrno)
×
713
    colDataSetNULL(tmp, i);
×
714
  }
715

716
  if (type == 0) {
×
717
    code = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM, 0, pRefBlock);
×
718
    if (code) {
×
719
      blockDataCleanup(pDelBlock);
×
720
      taosMemoryFree(pDelBlock);
×
721
      return code;
×
722
    }
723

724
    ((SStreamRefDataBlock*)(*pRefBlock))->type = STREAM_INPUT__REF_DATA_BLOCK;
×
725
    ((SStreamRefDataBlock*)(*pRefBlock))->pBlock = pDelBlock;
×
726
  } else if (type == 1) {
×
727
    *pRefBlock = pDelBlock;
×
728
  } else {
729
    tqError("unknown type:%d", type);
×
730
    code = TSDB_CODE_TMQ_CONSUMER_ERROR;
×
731
  }
732

733
END:
×
734
  if (code != 0) {
×
735
    tqError("failed to extract delete data block, line:%d code:%d", line, code);
×
736
  }
737
  tDecoderClear(pCoder);
×
738
  taosArrayDestroy(pRes->uidList);
×
739
  return code;
×
740
}
741

742
int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, bool* fhFinished) {
×
743
  SStreamMeta* pMeta = pVnode->pTq->pStreamMeta;
×
744
  int32_t      numOfTasks = taosArrayGetSize(pMeta->pTaskList);
×
745
  int32_t      code = TSDB_CODE_SUCCESS;
×
746

747
  if (pDelay != NULL) {
×
748
    *pDelay = 0;
×
749
  }
750

751
  *fhFinished = false;
×
752

753
  if (numOfTasks <= 0) {
×
754
    return code;
×
755
  }
756

757
  // extract the required source task for a given stream, identified by streamId
758
  streamMetaRLock(pMeta);
×
759

760
  numOfTasks = taosArrayGetSize(pMeta->pTaskList);
×
761

762
  for (int32_t i = 0; i < numOfTasks; ++i) {
×
763
    SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i);
×
764
    if (pId == NULL) {
×
765
      continue;
×
766
    }
767
    if (pId->streamId != streamId) {
×
768
      continue;
×
769
    }
770

771
    STaskId      id = {.streamId = pId->streamId, .taskId = pId->taskId};
×
772
    SStreamTask* pTask = NULL;
×
773

774
    code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask);
×
775
    if (code != 0) {
×
776
      tqError("vgId:%d failed to acquire task:0x%x in retrieving progress", pMeta->vgId, pId->taskId);
×
777
      continue;
×
778
    }
779

780
    if (pTask->info.taskLevel != TASK_LEVEL__SOURCE) {
×
781
      streamMetaReleaseTask(pMeta, pTask);
×
782
      continue;
×
783
    }
784

785
    // here we get the required stream source task
786
    *fhFinished = !HAS_RELATED_FILLHISTORY_TASK(pTask);
×
787

788
    int64_t ver = walReaderGetCurrentVer(pTask->exec.pWalReader);
×
789
    if (ver == -1) {
×
790
      ver = pTask->chkInfo.processedVer;
×
791
    } else {
792
      ver--;
×
793
    }
794

795
    SVersionRange verRange = {0};
×
796
    walReaderValidVersionRange(pTask->exec.pWalReader, &verRange.minVer, &verRange.maxVer);
×
797

798
    SWalReader* pReader = walOpenReader(pTask->exec.pWalReader->pWal, NULL, 0);
×
799
    if (pReader == NULL) {
×
800
      tqError("failed to open wal reader to extract exec progress, vgId:%d", pMeta->vgId);
×
801
      streamMetaReleaseTask(pMeta, pTask);
×
802
      continue;
×
803
    }
804

805
    int64_t cur = 0;
×
806
    int64_t latest = 0;
×
807

808
    code = walFetchHead(pReader, ver);
×
809
    if (code == TSDB_CODE_SUCCESS) {
×
810
      cur = pReader->pHead->head.ingestTs;
×
811
    }
812

813
    if (ver == verRange.maxVer) {
×
814
      latest = cur;
×
815
    } else {
816
      code = walFetchHead(pReader, verRange.maxVer);
×
817
      if (code == TSDB_CODE_SUCCESS) {
×
818
        latest = pReader->pHead->head.ingestTs;
×
819
      }
820
    }
821

822
    if (pDelay != NULL) {  // delay in ms
×
823
      *pDelay = (latest - cur) / 1000;
×
824
    }
825

826
    walCloseReader(pReader);
×
827
    streamMetaReleaseTask(pMeta, pTask);
×
828
  }
829

830
  streamMetaRUnLock(pMeta);
×
831

832
  return TSDB_CODE_SUCCESS;
×
833
}
834

835
int32_t tqExtractDropCtbDataBlock(const void* data, int32_t len, int64_t ver, void** pRefBlock, int32_t type) {
×
836
  int32_t          code = 0;
×
837
  int32_t          lino = 0;
×
838
  SDecoder         dc = {0};
×
839
  SVDropTbBatchReq batchReq = {0};
×
840
  tDecoderInit(&dc, (uint8_t*)data, len);
×
841
  code = tDecodeSVDropTbBatchReq(&dc, &batchReq);
×
842
  TSDB_CHECK_CODE(code, lino, _exit);
×
843
  if (batchReq.nReqs <= 0) goto _exit;
×
844

845
  SSDataBlock* pBlock = NULL;
×
846
  code = createSpecialDataBlock(STREAM_DROP_CHILD_TABLE, &pBlock);
×
847
  TSDB_CHECK_CODE(code, lino, _exit);
×
848

849
  code = blockDataEnsureCapacity(pBlock, batchReq.nReqs);
×
850
  TSDB_CHECK_CODE(code, lino, _exit);
×
851

852
  pBlock->info.rows = batchReq.nReqs;
×
853
  pBlock->info.version = ver;
×
854
  for (int32_t i = 0; i < batchReq.nReqs; ++i) {
×
855
    SVDropTbReq* pReq = batchReq.pReqs + i;
×
856
    SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX);
×
857
    TSDB_CHECK_NULL(pCol, code, lino, _exit, terrno);
×
858
    code = colDataSetVal(pCol, i, (const char* )&pReq->uid, false);
×
859
    TSDB_CHECK_CODE(code, lino, _exit);
×
860
  }
861

862
  code = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM, 0, pRefBlock);
×
863
  TSDB_CHECK_CODE(code, lino, _exit);
×
864
  ((SStreamRefDataBlock*)(*pRefBlock))->type = STREAM_INPUT__REF_DATA_BLOCK;
×
865
  ((SStreamRefDataBlock*)(*pRefBlock))->pBlock = pBlock;
×
866

867
_exit:
×
868
  tDecoderClear(&dc);
×
869
  if (TSDB_CODE_SUCCESS != code) {
×
870
    tqError("faled to extract drop ctb data block, line:%d code:%s", lino, tstrerror(code));
×
871
    blockDataCleanup(pBlock);
×
872
    taosMemoryFree(pBlock);
×
873
  }
874
  return code;
×
875
}
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