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

taosdata / TDengine / #4944

30 Jan 2026 06:19AM UTC coverage: 66.849% (+0.1%) from 66.718%
#4944

push

travis-ci

web-flow
merge: from main to 3.0 #34453

1124 of 2018 new or added lines in 72 files covered. (55.7%)

13677 existing lines in 155 files now uncovered.

205211 of 306978 relevant lines covered (66.85%)

125657591.7 hits per line

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

68.92
/source/dnode/mnode/impl/src/mndStream.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 "mndStream.h"
17
#include "audit.h"
18
#include "mndDb.h"
19
#include "mndPrivilege.h"
20
#include "mndShow.h"
21
#include "mndStb.h"
22
#include "mndTrans.h"
23
#include "mndUser.h"
24
#include "osMemory.h"
25
#include "parser.h"
26
#include "taoserror.h"
27
#include "tmisce.h"
28
#include "tname.h"
29

30
#define MND_STREAM_MAX_NUM 100000
31

32
typedef struct {
33
  int8_t placeHolder;  // // to fix windows compile error, define place holder
34
} SMStreamNodeCheckMsg;
35

36
static int32_t  mndNodeCheckSentinel = 0;
37
SStmRuntime  mStreamMgmt = {0};
38

39
static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream);
40
static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream);
41
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStreamObj *pNewStream);
42
static int32_t mndProcessDropStreamReq(SRpcMsg *pReq);
43

44
static int32_t mndProcessCreateStreamReqFromMNode(SRpcMsg *pReq);
45
static int32_t mndProcessDropStreamReqFromMNode(SRpcMsg *pReq);
46

47
static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
48
static void    mndCancelGetNextStream(SMnode *pMnode, void *pIter);
49
static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
50
static void    mndCancelGetNextStreamTask(SMnode *pMnode, void *pIter);
51
static int32_t mndProcessStopStreamReq(SRpcMsg *pReq);
52
static int32_t mndProcessStartStreamReq(SRpcMsg *pReq);
53

54
static SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
55

56
SSdbRaw       *mndStreamSeqActionEncode(SStreamObj *pStream);
57
SSdbRow       *mndStreamSeqActionDecode(SSdbRaw *pRaw);
58
static int32_t mndStreamSeqActionInsert(SSdb *pSdb, SStreamSeq *pStream);
59
static int32_t mndStreamSeqActionDelete(SSdb *pSdb, SStreamSeq *pStream);
60
static int32_t mndStreamSeqActionUpdate(SSdb *pSdb, SStreamSeq *pOldStream, SStreamSeq *pNewStream);
61
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq);
62

63
void mndCleanupStream(SMnode *pMnode) {
416,177✔
64
  mDebug("try to clean up stream");
416,177✔
65
  
66
  msmHandleBecomeNotLeader(pMnode);
416,177✔
67
  
68
  mDebug("mnd stream runtime info cleanup");
416,177✔
69
}
416,177✔
70

71
SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) {
194,837✔
72
  int32_t     code = 0;
194,837✔
73
  int32_t     lino = 0;
194,837✔
74
  SSdbRow    *pRow = NULL;
194,837✔
75
  SStreamObj *pStream = NULL;
194,837✔
76
  void       *buf = NULL;
194,837✔
77
  int8_t      sver = 0;
194,837✔
78
  int32_t     tlen;
194,417✔
79
  int32_t     dataPos = 0;
194,837✔
80

81
  code = sdbGetRawSoftVer(pRaw, &sver);
194,837✔
82
  TSDB_CHECK_CODE(code, lino, _over);
194,837✔
83

84
  if (sver != MND_STREAM_VER_NUMBER && sver != MND_STREAM_COMPATIBLE_VER_NUMBER) {
194,837✔
85
    mError("stream read invalid ver, data ver: %d, curr ver: %d", sver, MND_STREAM_VER_NUMBER);
×
86
    goto _over;
×
87
  }
88

89
  pRow = sdbAllocRow(sizeof(SStreamObj));
194,837✔
90
  TSDB_CHECK_NULL(pRow, code, lino, _over, terrno);
194,837✔
91

92
  pStream = sdbGetRowObj(pRow);
194,837✔
93
  TSDB_CHECK_NULL(pStream, code, lino, _over, terrno);
194,837✔
94

95
  SDB_GET_INT32(pRaw, dataPos, &tlen, _over);
194,837✔
96

97
  buf = taosMemoryMalloc(tlen + 1);
194,837✔
98
  TSDB_CHECK_NULL(buf, code, lino, _over, terrno);
194,837✔
99

100
  SDB_GET_BINARY(pRaw, dataPos, buf, tlen, _over);
194,837✔
101

102
  SDecoder decoder;
194,417✔
103
  tDecoderInit(&decoder, buf, tlen + 1);
194,837✔
104
  code = tDecodeSStreamObj(&decoder, pStream, sver);
194,837✔
105
  tDecoderClear(&decoder);
194,837✔
106

107
  if (code < 0) {
194,837✔
108
    tFreeStreamObj(pStream);
×
109
  }
110

111
_over:
194,837✔
112
  taosMemoryFreeClear(buf);
194,837✔
113

114
  if (code != TSDB_CODE_SUCCESS) {
194,837✔
115
    char *p = (pStream == NULL || NULL == pStream->pCreate) ? "null" : pStream->pCreate->name;
×
116
    mError("stream:%s, failed to decode from raw:%p since %s at:%d", p, pRaw, tstrerror(code), lino);
×
117
    taosMemoryFreeClear(pRow);
×
118

119
    terrno = code;
×
120
    return NULL;
×
121
  } else {
122
    mTrace("stream:%s, decode from raw:%p, row:%p", pStream->pCreate->name, pRaw, pStream);
194,837✔
123

124
    terrno = 0;
194,837✔
125
    return pRow;
194,837✔
126
  }
127
}
128

129
static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream) {
166,134✔
130
  mTrace("stream:%s, perform insert action", pStream->pCreate->name);
166,134✔
131
  return 0;
166,134✔
132
}
133

134
static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream) {
194,837✔
135
  mInfo("stream:%s, perform delete action", pStream->pCreate->name);
194,837✔
136
  tFreeStreamObj(pStream);
194,837✔
137
  return 0;
194,837✔
138
}
139

140
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStreamObj *pNewStream) {
5,320✔
141
  mTrace("stream:%s, perform update action", pOldStream->pCreate->name);
5,320✔
142

143
  atomic_store_32(&pOldStream->mainSnodeId, pNewStream->mainSnodeId);
5,320✔
144
  atomic_store_8(&pOldStream->userStopped, atomic_load_8(&pNewStream->userStopped));
5,320✔
145
  pOldStream->ownerId = pNewStream->ownerId;
5,320✔
146
  pOldStream->updateTime = pNewStream->updateTime;
5,320✔
147
  
148
  return 0;
5,320✔
149
}
150

151
int32_t mndAcquireStream(SMnode *pMnode, char *streamName, SStreamObj **pStream) {
371,969✔
152
  int32_t code = 0;
371,969✔
153
  SSdb   *pSdb = pMnode->pSdb;
371,969✔
154
  (*pStream) = sdbAcquire(pSdb, SDB_STREAM, streamName);
371,969✔
155
  if ((*pStream) == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) {
371,969✔
156
    code = TSDB_CODE_MND_STREAM_NOT_EXIST;
173,811✔
157
  }
158
  return code;
371,969✔
159
}
160

161
static bool mndStreamGetNameFromId(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
×
162
  SStreamObj* pStream = pObj;
×
163

164
  if (pStream->pCreate->streamId == *(int64_t*)p1) {
×
165
    strncpy((char*)p2, pStream->name, TSDB_STREAM_NAME_LEN);
×
166
    return false;
×
167
  }
168

169
  return true;
×
170
}
171

172
int32_t mndAcquireStreamById(SMnode *pMnode, int64_t streamId, SStreamObj **pStream) {
×
173
  int32_t code = 0;
×
174
  SSdb   *pSdb = pMnode->pSdb;
×
175
  char streamName[TSDB_STREAM_NAME_LEN];
×
176
  streamName[0] = 0;
×
177
  
178
  sdbTraverse(pSdb, SDB_STREAM, mndStreamGetNameFromId, &streamId, streamName, NULL);
×
179
  if (streamName[0]) {
×
180
    (*pStream) = sdbAcquire(pSdb, SDB_STREAM, streamName);
×
181
    if ((*pStream) == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) {
×
182
      code = TSDB_CODE_MND_STREAM_NOT_EXIST;
×
183
    }
184
  }
185
  
186
  return code;
×
187
}
188

189
void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
176,438✔
190
  SSdb *pSdb = pMnode->pSdb;
176,438✔
191
  sdbRelease(pSdb, pStream);
176,438✔
192
}
176,438✔
193

194
SSdbRaw *mndStreamSeqActionEncode(SStreamObj *pStream) { return NULL; }
×
195
SSdbRow *mndStreamSeqActionDecode(SSdbRaw *pRaw) { return NULL; }
×
196
int32_t  mndStreamSeqActionInsert(SSdb *pSdb, SStreamSeq *pStream) { return 0; }
×
197
int32_t  mndStreamSeqActionDelete(SSdb *pSdb, SStreamSeq *pStream) { return 0; }
×
198
int32_t  mndStreamSeqActionUpdate(SSdb *pSdb, SStreamSeq *pOldStream, SStreamSeq *pNewStream) { return 0; }
×
199

200
static void mndStreamBuildObj(SMnode *pMnode, SStreamObj *pObj, SCMCreateStreamReq *pCreate, SUserObj *pOperUser,
165,304✔
201
                              int32_t snodeId) {
202
  int32_t code = 0;
165,304✔
203

204
  pObj->pCreate = pCreate;
165,304✔
205
  strncpy(pObj->name, pCreate->name, TSDB_STREAM_FNAME_LEN);
165,304✔
206
  (void)snprintf(pObj->createUser, sizeof(pObj->createUser), "%s", pOperUser->name);
165,304✔
207
  pObj->ownerId = pOperUser->uid;
165,304✔
208
  pObj->mainSnodeId = snodeId;
165,304✔
209

210
  pObj->userDropped = 0;
165,304✔
211
  pObj->userStopped = 0;
165,304✔
212

213
  pObj->createTime = taosGetTimestampMs();
165,304✔
214
  pObj->updateTime = pObj->createTime;
165,304✔
215

216
  mstLogSStreamObj("create stream", pObj);
165,304✔
217
}
165,304✔
218

219
static int32_t mndStreamCreateOutStb(SMnode *pMnode, STrans *pTrans, const SCMCreateStreamReq *pStream, const char *user) {
59,820✔
220
  SStbObj *pStb = NULL;
59,820✔
221
  SDbObj  *pDb = NULL;
59,820✔
222
  int32_t  code = 0;
59,820✔
223
  int32_t  lino = 0;
59,820✔
224

225
  SMCreateStbReq createReq = {0};
59,820✔
226
  TAOS_STRNCAT(createReq.name, pStream->outDB, TSDB_DB_FNAME_LEN);
59,820✔
227
  TAOS_STRNCAT(createReq.name, ".", 2);
59,820✔
228
  TAOS_STRNCAT(createReq.name,  pStream->outTblName, TSDB_TABLE_NAME_LEN);
59,820✔
229
  createReq.numOfColumns = taosArrayGetSize(pStream->outCols);
59,820✔
230
  createReq.numOfTags = pStream->outTags ? taosArrayGetSize(pStream->outTags) : 1;
59,820✔
231
  createReq.pColumns = taosArrayInit_s(sizeof(SFieldWithOptions), createReq.numOfColumns);
59,820✔
232
  TSDB_CHECK_NULL(createReq.pColumns, code, lino, _OVER, terrno);
59,820✔
233

234
  // build fields
235
  for (int32_t i = 0; i < createReq.numOfColumns; i++) {
315,451✔
236
    SFieldWithOptions *pField = taosArrayGet(createReq.pColumns, i);
255,631✔
237
    TSDB_CHECK_NULL(pField, code, lino, _OVER, terrno);
255,631✔
238
    SFieldWithOptions *pSrc = taosArrayGet(pStream->outCols, i);
255,631✔
239

240
    tstrncpy(pField->name, pSrc->name, TSDB_COL_NAME_LEN);
255,631✔
241
    pField->flags = pSrc->flags;
255,631✔
242
    pField->type = pSrc->type;
255,631✔
243
    pField->bytes = pSrc->bytes;
255,631✔
244
    pField->compress = createDefaultColCmprByType(pField->type);
255,631✔
245
    if (IS_DECIMAL_TYPE(pField->type)) {
255,631✔
246
      pField->typeMod = pSrc->typeMod;
×
247
      pField->flags |= COL_HAS_TYPE_MOD;
×
248
    }
249
  }
250

251
  if (NULL == pStream->outTags) {
59,820✔
252
    createReq.numOfTags = 1;
×
253
    createReq.pTags = taosArrayInit_s(sizeof(SField), 1);
×
254
    TSDB_CHECK_NULL(createReq.pTags, code, lino, _OVER, terrno);
×
255

256
    // build tags
257
    SField *pField = taosArrayGet(createReq.pTags, 0);
×
258
    TSDB_CHECK_NULL(pField, code, lino, _OVER, terrno);
×
259

260
    tstrncpy(pField->name, "group_id", sizeof(pField->name));
×
261
    pField->type = TSDB_DATA_TYPE_UBIGINT;
×
262
    pField->flags = 0;
×
263
    pField->bytes = 8;
×
264
  } else {
265
    createReq.numOfTags = taosArrayGetSize(pStream->outTags);
59,820✔
266
    createReq.pTags = taosArrayInit_s(sizeof(SField), createReq.numOfTags);
59,820✔
267
    TSDB_CHECK_NULL(createReq.pTags, code, lino, _OVER, terrno);
59,820✔
268

269
    for (int32_t i = 0; i < createReq.numOfTags; i++) {
153,855✔
270
      SField *pField = taosArrayGet(createReq.pTags, i);
94,035✔
271
      if (pField == NULL) {
94,035✔
272
        continue;
×
273
      }
274

275
      TAOS_FIELD_E *pSrc = taosArrayGet(pStream->outTags, i);
94,035✔
276
      pField->bytes = pSrc->bytes;
94,035✔
277
      pField->flags = 0;
94,035✔
278
      pField->type = pSrc->type;
94,035✔
279
      tstrncpy(pField->name, pSrc->name, TSDB_COL_NAME_LEN);
94,035✔
280
    }
281
  }
282

283
  if ((code = mndCheckCreateStbReq(&createReq)) != 0) {
59,820✔
284
    goto _OVER;
×
285
  }
286

287
  pStb = mndAcquireStb(pMnode, createReq.name);
59,820✔
288
  if (pStb != NULL) {
59,820✔
289
    code = TSDB_CODE_MND_STB_ALREADY_EXIST;
×
290
    goto _OVER;
×
291
  }
292

293
  pDb = mndAcquireDbByStb(pMnode, createReq.name);
59,820✔
294
  if (pDb == NULL) {
59,820✔
295
    code = TSDB_CODE_MND_DB_NOT_SELECTED;
×
296
    goto _OVER;
×
297
  }
298

299
  int32_t numOfStbs = -1;
59,820✔
300
  if (mndGetNumOfStbs(pMnode, pDb->name, &numOfStbs) != 0) {
59,820✔
301
    goto _OVER;
×
302
  }
303

304
  if (pDb->cfg.numOfStables == 1 && numOfStbs != 0) {
59,820✔
305
    code = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
×
306
    goto _OVER;
×
307
  }
308

309
  SStbObj stbObj = {0};
59,820✔
310

311
  if (mndBuildStbFromReq(pMnode, &stbObj, &createReq, pDb) != 0) {
59,820✔
312
    goto _OVER;
×
313
  }
314

315
  stbObj.uid = pStream->outStbUid;
59,820✔
316

317
  if (mndAddStbToTrans(pMnode, pTrans, pDb, &stbObj) < 0) {
59,820✔
318
    mndFreeStb(&stbObj);
×
319
    goto _OVER;
×
320
  }
321

322
  mDebug("stream:%s create dst stable:%s, cols:%d", pStream->name, pStream->outTblName, createReq.numOfColumns);
59,820✔
323

324
  tFreeSMCreateStbReq(&createReq);
59,820✔
325
  mndFreeStb(&stbObj);
59,820✔
326
  mndReleaseStb(pMnode, pStb);
59,820✔
327
  mndReleaseDb(pMnode, pDb);
59,820✔
328
  return code;
59,820✔
329

330
_OVER:
×
331
  tFreeSMCreateStbReq(&createReq);
×
332
  mndReleaseStb(pMnode, pStb);
×
333
  mndReleaseDb(pMnode, pDb);
×
334

335
  mDebug("stream:%s failed to create dst stable:%s, line:%d code:%s", pStream->name, pStream->outTblName, lino,
×
336
         tstrerror(code));
337
  return code;
×
338
}
339

340
static int32_t mndStreamValidateCreate(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq* pCreate) {
165,304✔
341
  int32_t code = 0, lino = 0;
165,304✔
342
  int64_t streamId = pCreate->streamId;
165,304✔
343
  char   *pUser = RPC_MSG_USER(pReq);
165,304✔
344

345
  if (pCreate->streamDB) {
165,304✔
346
    // code = mndCheckDbPrivilegeByName(pMnode, pUser, MND_OPER_WRITE_DB, pCreate->streamDB);
347
    code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB, pCreate->streamDB);
165,304✔
348
    if (code) {
165,304✔
UNCOV
349
      mstsError("user %s failed to create stream %s in db %s since %s", pUser, pCreate->name, pCreate->streamDB,
×
350
                tstrerror(code));
351
    }
352
    TSDB_CHECK_CODE(code, lino, _OVER);
165,304✔
353
  }
354

355
  if (pCreate->triggerDB) {
165,304✔
356
    // code = mndCheckDbPrivilegeByName(pMnode, pUser, MND_OPER_READ_DB, pCreate->triggerDB);
357
    code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB, pCreate->triggerDB);
164,345✔
358
    if (code) {
164,345✔
UNCOV
359
      mstsError("user %s failed to create stream %s using trigger db %s since %s", pUser, pCreate->name,
×
360
                pCreate->triggerDB, tstrerror(code));
361
    }
362
    TSDB_CHECK_CODE(code, lino, _OVER);
164,345✔
363
#if 0  // TODO check the owner of trigger table
364
    if (pCreate->triggerTblName) {
365
      // check trigger table privilege
366
      code = mndCheckObjPrivilegeRecF(pMnode, pUser, PRIV_TBL_SELECT, "", pCreate->triggerDB, pCreate->triggerTblName);
367
      if (code) {
368
        mstsError("user %s failed to create stream %s using trigger table %s.%s since %s", pUser, pCreate->name,
369
                  pCreate->triggerDB, pCreate->triggerTblName, tstrerror(code));
370
      }
371
      TSDB_CHECK_CODE(code, lino, _OVER);
372
    }
373
#endif
374
  }
375

376
  if (pCreate->calcDB) {
165,304✔
377
    int32_t dbNum = taosArrayGetSize(pCreate->calcDB);
162,131✔
378
    for (int32_t i = 0; i < dbNum; ++i) {
324,262✔
379
      char *calcDB = taosArrayGetP(pCreate->calcDB, i);
162,131✔
380
      // code = mndCheckDbPrivilegeByName(pMnode, pUser, MND_OPER_READ_DB, calcDB);
381
      code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB, calcDB);
162,131✔
382
      if (code) {
162,131✔
UNCOV
383
        mstsError("user %s failed to create stream %s using calcDB %s since %s", pUser, pCreate->name, calcDB,
×
384
                  tstrerror(code));
385
      }
386
      TSDB_CHECK_CODE(code, lino, _OVER);
162,131✔
387
    }
388
  }
389

390
  if (pCreate->outDB) {
165,304✔
391
    // code = mndCheckDbPrivilegeByName(pMnode, pUser, MND_OPER_WRITE_DB, pCreate->outDB);
392
    code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB, pCreate->outDB);
162,131✔
393
    if (code) {
162,131✔
UNCOV
394
      mstsError("user %s failed to create stream %s using out db %s since %s", pUser, pCreate->name, pCreate->outDB,
×
395
                tstrerror(code));
396
    }
397
    TSDB_CHECK_CODE(code, lino, _OVER);
162,131✔
398
  }
399

400
  int32_t streamNum = sdbGetSize(pMnode->pSdb, SDB_STREAM);
165,304✔
401
  if (streamNum > MND_STREAM_MAX_NUM) {
165,304✔
UNCOV
402
    code = TSDB_CODE_MND_TOO_MANY_STREAMS;
×
UNCOV
403
    mstsError("failed to create stream %s since %s, stream number:%d", pCreate->name, tstrerror(code), streamNum);
×
UNCOV
404
    return code;
×
405
  }
406

407
_OVER:
165,304✔
408

409
  return code;
165,304✔
410
}
411

412
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
629,515✔
413
  SSdb   *pSdb = pMnode->pSdb;
629,515✔
414
  void   *pIter = NULL;
629,515✔
415
  int32_t code = 0;
629,515✔
416

417
  while (1) {
43,506✔
418
    SStreamObj *pStream = NULL;
673,021✔
419
    pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
673,021✔
420
    if (pIter == NULL) break;
673,021✔
421

422
    if (0 == strcmp(pStream->pCreate->streamDB, pDb->name)) {
43,506✔
423
      mInfo("start to drop stream %s in db %s", pStream->pCreate->name, pDb->name);
17,152✔
424
      
425
      pStream->updateTime = taosGetTimestampMs();
34,304✔
426
      
427
      atomic_store_8(&pStream->userDropped, 1);
17,152✔
428
      
429
      MND_STREAM_SET_LAST_TS(STM_EVENT_DROP_STREAM, pStream->updateTime);
17,152✔
430
      
431
      msmUndeployStream(pMnode, pStream->pCreate->streamId, pStream->pCreate->name);
17,152✔
432
      
433
      // drop stream
434
      code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_DROPPED);
17,152✔
435
      if (code) {
17,152✔
436
        mError("drop db trans:%d failed to append drop stream trans since %s", pTrans->id, tstrerror(code));
×
UNCOV
437
        sdbRelease(pSdb, pStream);
×
UNCOV
438
        sdbCancelFetch(pSdb, pIter);
×
UNCOV
439
        TAOS_RETURN(code);
×
440
      }
441
    }
442

443
    sdbRelease(pSdb, pStream);
43,506✔
444
  }
445

446
  return 0;
629,515✔
447
}
448

449
static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
223,323✔
450
  SMnode     *pMnode = pReq->info.node;
223,323✔
451
  SSdb       *pSdb = pMnode->pSdb;
223,323✔
452
  int32_t     numOfRows = 0;
223,323✔
453
  SStreamObj *pStream = NULL;
223,323✔
454
  SUserObj   *pOperUser = NULL;
223,323✔
455
  int32_t     code = 0, lino = 0;
223,323✔
456
  bool        showAll = false;
223,323✔
457

458
  TAOS_CHECK_EXIT(mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser));
223,323✔
459
  showAll =
223,323✔
460
      (0 == mndCheckObjPrivilegeRec(pMnode, pOperUser, PRIV_CM_SHOW, PRIV_OBJ_STREAM, 0, pOperUser->acctId, "*", "*"));
223,323✔
461

462
  while (numOfRows < rows) {
740,846✔
463
    pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
740,846✔
464
    if (pShow->pIter == NULL) break;
740,846✔
465

466
    if (!showAll) {
517,523✔
467
      if ((mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_SHOW, PRIV_OBJ_STREAM, pStream->ownerId,
×
UNCOV
468
                                    pStream->pCreate->streamDB, pStream->pCreate->name))) {
×
UNCOV
469
        sdbRelease(pSdb, pStream);
×
UNCOV
470
        continue;
×
471
      }
472
    }
473

474
    code = mstSetStreamAttrResBlock(pMnode, pStream, pBlock, numOfRows);
517,523✔
475
    if (code == 0) {
517,523✔
476
      numOfRows++;
517,523✔
477
    }
478
    sdbRelease(pSdb, pStream);
517,523✔
479
  }
480
  code = 0;
223,323✔
481
  pShow->numOfRows += numOfRows;
223,323✔
482
_exit:
223,323✔
483
  mndReleaseUser(pMnode, pOperUser);
223,323✔
484
  if (code != 0) {
223,323✔
UNCOV
485
    mError("failed to retrieve stream list at line %d since %s", lino, tstrerror(code));
×
UNCOV
486
    TAOS_RETURN(code);
×
487
  }
488
  return numOfRows;
223,323✔
489
}
490

491
static void mndCancelGetNextStream(SMnode *pMnode, void *pIter) {
×
UNCOV
492
  SSdb *pSdb = pMnode->pSdb;
×
UNCOV
493
  sdbCancelFetchByType(pSdb, pIter, SDB_STREAM);
×
UNCOV
494
}
×
495

496
static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
307,357✔
497
  SMnode     *pMnode = pReq->info.node;
307,357✔
498
  SSdb       *pSdb = pMnode->pSdb;
307,357✔
499
  int32_t     numOfRows = 0;
307,357✔
500
  SStreamObj *pStream = NULL;
307,357✔
501
  int32_t     code = 0;
307,357✔
502

503
  while (numOfRows < rowsCapacity) {
3,207,794✔
504
    pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
3,117,280✔
505
    if (pShow->pIter == NULL) {
3,117,280✔
506
      break;
216,843✔
507
    }
508

509
    code = mstSetStreamTasksResBlock(pStream, pBlock, &numOfRows, rowsCapacity);
2,900,437✔
510

511
    sdbRelease(pSdb, pStream);
2,900,437✔
512
  }
513

514
  pShow->numOfRows += numOfRows;
307,357✔
515
  return numOfRows;
307,357✔
516
}
517

518
static void mndCancelGetNextStreamTask(SMnode *pMnode, void *pIter) {
×
UNCOV
519
  SSdb *pSdb = pMnode->pSdb;
×
UNCOV
520
  sdbCancelFetchByType(pSdb, pIter, SDB_STREAM);
×
UNCOV
521
}
×
522

523
static int32_t mndRetrieveStreamRecalculates(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
257✔
524
  SMnode     *pMnode = pReq->info.node;
257✔
525
  SSdb       *pSdb = pMnode->pSdb;
257✔
526
  int32_t     numOfRows = 0;
257✔
527
  SStreamObj *pStream = NULL;
257✔
528
  int32_t     code = 0;
257✔
529

530
  while (numOfRows < rowsCapacity) {
514✔
531
    pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
514✔
532
    if (pShow->pIter == NULL) {
514✔
533
      break;
257✔
534
    }
535

536
    code = mstSetStreamRecalculatesResBlock(pStream, pBlock, &numOfRows, rowsCapacity);
257✔
537

538
    sdbRelease(pSdb, pStream);
257✔
539
  }
540

541
  pShow->numOfRows += numOfRows;
257✔
542
  return numOfRows;
257✔
543
}
544

545
static void mndCancelGetNextStreamRecalculates(SMnode *pMnode, void *pIter) {
×
UNCOV
546
  SSdb *pSdb = pMnode->pSdb;
×
UNCOV
547
  sdbCancelFetchByType(pSdb, pIter, SDB_STREAM);
×
UNCOV
548
}
×
549

550

551
static bool mndStreamUpdateTagsFlag(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
2,113,594✔
552
  SStreamObj *pStream = pObj;
2,113,594✔
553
  if (atomic_load_8(&pStream->userDropped)) {
2,113,594✔
UNCOV
554
    return true;
×
555
  }
556

557
  if (TSDB_SUPER_TABLE != pStream->pCreate->triggerTblType && 
2,113,594✔
558
      TSDB_CHILD_TABLE != pStream->pCreate->triggerTblType && 
1,207,748✔
559
      TSDB_VIRTUAL_CHILD_TABLE != pStream->pCreate->triggerTblType) {
886,596✔
560
    return true;
120,448✔
561
  }
562

563
  if (pStream->pCreate->triggerTblSuid != *(uint64_t*)p1) {
1,993,146✔
564
    return true;
1,959,622✔
565
  }
566

567
  if (NULL == pStream->pCreate->partitionCols) {
33,524✔
568
    return true;
4,170✔
569
  }
570

571
  SNodeList* pList = NULL;
29,354✔
572
  int32_t code = nodesStringToList(pStream->pCreate->partitionCols, &pList);
29,354✔
573
  if (code) {
29,354✔
UNCOV
574
    nodesDestroyList(pList);
×
UNCOV
575
    mstError("partitionCols [%s] nodesStringToList failed with error:%s", (char*)pStream->pCreate->partitionCols, tstrerror(code));
×
UNCOV
576
    return true;
×
577
  }
578

579
  SSchema* pTags = (SSchema*)p2;
29,354✔
580
  int32_t* tagNum = (int32_t*)p3;
29,354✔
581

582
  SNode* pNode = NULL;
29,354✔
583
  FOREACH(pNode, pList) {
65,941✔
584
    SColumnNode* pCol = (SColumnNode*)pNode;
36,587✔
585
    for (int32_t i = 0; i < *tagNum; ++i) {
71,134✔
586
      if (pCol->colId == pTags[i].colId) {
63,748✔
587
        pTags[i].flags |= COL_REF_BY_STM;
29,201✔
588
        break;
29,201✔
589
      }
590
    }
591
  }
592

593
  nodesDestroyList(pList);
29,354✔
594
  
595
  return true;
29,354✔
596
}
597

598

599
void mndStreamUpdateTagsRefFlag(SMnode *pMnode, int64_t suid, SSchema* pTags, int32_t tagNum) {
14,480,772✔
600
  int32_t streamNum = sdbGetSize(pMnode->pSdb, SDB_STREAM);
14,480,772✔
601
  if (streamNum <= 0) {
14,481,275✔
602
    return;
14,360,460✔
603
  }
604

605
  sdbTraverse(pMnode->pSdb, SDB_STREAM, mndStreamUpdateTagsFlag, &suid, pTags, &tagNum);
120,815✔
606
}
607

608
static int32_t mndProcessStopStreamReq(SRpcMsg *pReq) {
2,156✔
609
  SMnode     *pMnode = pReq->info.node;
2,156✔
610
  SStreamObj *pStream = NULL;
2,156✔
611
  SUserObj   *pOperUser = NULL;
2,156✔
612
  int32_t     code = 0;
2,156✔
613

614
  SMPauseStreamReq pauseReq = {0};
2,156✔
615
  if (tDeserializeSMPauseStreamReq(pReq->pCont, pReq->contLen, &pauseReq) < 0) {
2,156✔
UNCOV
616
    TAOS_RETURN(TSDB_CODE_INVALID_MSG);
×
617
  }
618

619
  code = mndAcquireStream(pMnode, pauseReq.name, &pStream);
2,156✔
620
  if (pStream == NULL || code != 0) {
2,156✔
621
    if (pauseReq.igNotExists) {
×
UNCOV
622
      mInfo("stream:%s, not exist, not stop stream", pauseReq.name);
×
623
      taosMemoryFree(pauseReq.name);
×
624
      return 0;
×
625
    } else {
UNCOV
626
      mError("stream:%s not exist, failed to stop stream", pauseReq.name);
×
UNCOV
627
      taosMemoryFree(pauseReq.name);
×
UNCOV
628
      TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
×
629
    }
630
  }
631

632
  taosMemoryFree(pauseReq.name);
2,156✔
633

634
  int64_t streamId = pStream->pCreate->streamId;
2,156✔
635
  
636
  mstsInfo("start to stop stream %s", pStream->name);
2,156✔
637

638
  // code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), MND_OPER_WRITE_DB, pStream->pCreate->streamDB);
639
  if((code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser))) {
2,156✔
UNCOV
640
    mstsError("user %s failed to stop stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
UNCOV
641
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
642
    return code;
×
643
  }
644

645
  if ((code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB,
2,156✔
646
                                        pStream->pCreate->streamDB)) ||
4,312✔
647
      (code = mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_STOP, PRIV_OBJ_STREAM, pStream->ownerId,
2,156✔
648
                                       pStream->pCreate->streamDB, pStream->pCreate->name))) {
2,156✔
649
    mstsError("user %s failed to stop stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
UNCOV
650
    mndReleaseUser(pMnode, pOperUser);
×
UNCOV
651
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
652
    return code;
×
653
  }
654

655
  mndReleaseUser(pMnode, pOperUser); // release user after privilege check
2,156✔
656

657
  if (atomic_load_8(&pStream->userDropped)) {
2,156✔
658
    code = TSDB_CODE_MND_STREAM_DROPPING;
×
UNCOV
659
    mstsError("user %s failed to stop stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
UNCOV
660
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
661
    return code;
×
662
  }
663

664
  STrans *pTrans = NULL;
2,156✔
665
  code = mndStreamCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_STOP_NAME, &pTrans);
2,156✔
666
  if (pTrans == NULL || code) {
2,156✔
UNCOV
667
    mstsError("failed to stop stream %s since %s", pStream->name, tstrerror(code));
×
UNCOV
668
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
669
    return code;
×
670
  }
671

672
  pStream->updateTime = taosGetTimestampMs();
4,312✔
673

674
  atomic_store_8(&pStream->userStopped, 1);
2,156✔
675

676
  MND_STREAM_SET_LAST_TS(STM_EVENT_STOP_STREAM, pStream->updateTime);
2,156✔
677

678
  msmUndeployStream(pMnode, streamId, pStream->name);
2,156✔
679

680
  // stop stream
681
  code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_READY);
2,156✔
682
  if (code != TSDB_CODE_SUCCESS) {
2,156✔
UNCOV
683
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
684
    mndTransDrop(pTrans);
×
UNCOV
685
    return code;
×
686
  }
687

688
  code = mndTransPrepare(pMnode, pTrans);
2,156✔
689
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
2,156✔
690
    mError("trans:%d, failed to prepare stop stream trans since %s", pTrans->id, tstrerror(code));
×
UNCOV
691
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
692
    mndTransDrop(pTrans);
×
UNCOV
693
    return code;
×
694
  }
695

696
  sdbRelease(pMnode->pSdb, pStream);
2,156✔
697
  mndTransDrop(pTrans);
2,156✔
698

699
  return TSDB_CODE_ACTION_IN_PROGRESS;
2,156✔
700
}
701

702

703
static int32_t mndProcessStartStreamReq(SRpcMsg *pReq) {
2,156✔
704
  SMnode     *pMnode = pReq->info.node;
2,156✔
705
  SStreamObj *pStream = NULL;
2,156✔
706
  SUserObj   *pOperUser = NULL;
2,156✔
707
  int32_t     code = 0;
2,156✔
708

709
  if ((code = grantCheckExpire(TSDB_GRANT_STREAMS)) < 0) {
2,156✔
UNCOV
710
    return code;
×
711
  }
712

713
  SMResumeStreamReq resumeReq = {0};
2,156✔
714
  if (tDeserializeSMResumeStreamReq(pReq->pCont, pReq->contLen, &resumeReq) < 0) {
2,156✔
UNCOV
715
    TAOS_RETURN(TSDB_CODE_INVALID_MSG);
×
716
  }
717

718
  code = mndAcquireStream(pMnode, resumeReq.name, &pStream);
2,156✔
719
  if (pStream == NULL || code != 0) {
2,156✔
720
    if (resumeReq.igNotExists) {
×
721
      mInfo("stream:%s not exist, not start stream", resumeReq.name);
×
UNCOV
722
      taosMemoryFree(resumeReq.name);
×
723
      sdbRelease(pMnode->pSdb, pStream);
×
724
      return 0;
×
725
    } else {
UNCOV
726
      mError("stream:%s not exist, failed to start stream", resumeReq.name);
×
UNCOV
727
      taosMemoryFree(resumeReq.name);
×
UNCOV
728
      TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
×
729
    }
730
  }
731

732
  taosMemoryFree(resumeReq.name);
2,156✔
733

734
  int64_t streamId = pStream->pCreate->streamId;
2,156✔
735

736
  mstsInfo("start to start stream %s from stopped", pStream->name);
2,156✔
737

738
  // code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), MND_OPER_WRITE_DB, pStream->pCreate->streamDB);
739
  if ((code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser))) {
2,156✔
UNCOV
740
    mstsError("user %s failed to start stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
UNCOV
741
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
742
    return code;
×
743
  }
744

745
  if ((code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB,
2,156✔
746
                                        pStream->pCreate->streamDB)) ||
4,312✔
747
      (code = mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_START, PRIV_OBJ_STREAM, pStream->ownerId,
2,156✔
748
                                       pStream->pCreate->streamDB, pStream->pCreate->name))) {
2,156✔
749
    mstsError("user %s failed to start stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
UNCOV
750
    mndReleaseUser(pMnode, pOperUser);
×
UNCOV
751
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
752
    return code;
×
753
  }
754

755
  mndReleaseUser(pMnode, pOperUser); // release user after privilege check
2,156✔
756

757
  if (atomic_load_8(&pStream->userDropped)) {
2,156✔
758
    code = TSDB_CODE_MND_STREAM_DROPPING;
×
UNCOV
759
    mstsError("user %s failed to start stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
UNCOV
760
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
761
    return code;
×
762
  }
763

764
  if (0 == atomic_load_8(&pStream->userStopped)) {
2,156✔
765
    code = TSDB_CODE_MND_STREAM_NOT_STOPPED;
×
UNCOV
766
    mstsError("user %s failed to start stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
UNCOV
767
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
768
    return code;
×
769
  }
770
  
771
  atomic_store_8(&pStream->userStopped, 0);
2,156✔
772

773
  pStream->updateTime = taosGetTimestampMs();
4,312✔
774

775
  MND_STREAM_SET_LAST_TS(STM_EVENT_START_STREAM, pStream->updateTime);
2,156✔
776

777
  STrans *pTrans = NULL;
2,156✔
778
  code = mndStreamCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_START_NAME, &pTrans);
2,156✔
779
  if (pTrans == NULL || code) {
2,156✔
UNCOV
780
    mstsError("failed to start stream %s since %s", pStream->name, tstrerror(code));
×
UNCOV
781
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
782
    return code;
×
783
  }
784

785
  code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_READY);
2,156✔
786
  if (code != TSDB_CODE_SUCCESS) {
2,156✔
787
    mstsError("failed to start stream %s since %s", pStream->name, tstrerror(code));
×
UNCOV
788
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
789
    mndTransDrop(pTrans);
×
UNCOV
790
    return code;
×
791
  }
792

793
  code = mndTransPrepare(pMnode, pTrans);
2,156✔
794
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
2,156✔
795
    mstsError("trans:%d, failed to prepare start stream %s trans since %s", pTrans->id, pStream->name, tstrerror(code));
×
UNCOV
796
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
797
    mndTransDrop(pTrans);
×
UNCOV
798
    return code;
×
799
  }
800

801
  mstPostStreamAction(mStreamMgmt.actionQ, streamId, pStream->name, NULL, true, STREAM_ACT_DEPLOY);
2,156✔
802

803
  sdbRelease(pMnode->pSdb, pStream);
2,156✔
804
  mndTransDrop(pTrans);
2,156✔
805

806
  return TSDB_CODE_ACTION_IN_PROGRESS;
2,156✔
807
}
808

809
static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
6,727✔
810
  SMnode     *pMnode = pReq->info.node;
6,727✔
811
  SStreamObj *pStream = NULL;
6,727✔
812
  SUserObj   *pOperUser = NULL;
6,727✔
813
  int32_t     code = 0;
6,727✔
814
  int32_t     notExistNum = 0;
6,727✔
815

816
  SMDropStreamReq dropReq = {0};
6,727✔
817
  int64_t         tss = taosGetTimestampMs();
6,727✔
818
  if (tDeserializeSMDropStreamReq(pReq->pCont, pReq->contLen, &dropReq) < 0) {
6,727✔
UNCOV
819
    mError("invalid drop stream msg recv, discarded");
×
UNCOV
820
    code = TSDB_CODE_INVALID_MSG;
×
UNCOV
821
    TAOS_RETURN(code);
×
822
  }
823

824
  mDebug("recv drop stream msg, count:%d", dropReq.count);
6,727✔
825

826
  // Acquire user object for privilege check
827
  code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser);
6,727✔
828
  if (code != 0) {
6,727✔
UNCOV
829
    tFreeMDropStreamReq(&dropReq);
×
UNCOV
830
    TAOS_RETURN(code);
×
831
  }
832

833
  // check if all streams exist
834
  if (!dropReq.igNotExists) {
6,727✔
835
    for (int32_t i = 0; i < dropReq.count; i++) {
10,232✔
836
      if (!sdbCheckExists(pMnode->pSdb, SDB_STREAM, dropReq.name[i])) {
5,736✔
837
        mError("stream:%s not exist failed to drop it", dropReq.name[i]);
992✔
838
        mndReleaseUser(pMnode, pOperUser);
992✔
839
        tFreeMDropStreamReq(&dropReq);
992✔
840
        TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
992✔
841
      }
842
    }
843
  }
844

845
  // Create a single transaction for all stream drops
846
  STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, MND_STREAM_DROP_NAME);
5,735✔
847
  if (pTrans == NULL) {
5,735✔
848
    mError("failed to create drop stream transaction since %s", tstrerror(terrno));
×
849
    code = terrno;
×
UNCOV
850
    mndReleaseUser(pMnode, pOperUser);
×
UNCOV
851
    tFreeMDropStreamReq(&dropReq);
×
UNCOV
852
    TAOS_RETURN(code);
×
853
  }
854
  pTrans->ableToBeKilled = true;
5,735✔
855

856
  // Process all streams and add them to the transaction
857
  for (int32_t i = 0; i < dropReq.count; i++) {
12,958✔
858
    char *streamName = dropReq.name[i];
7,223✔
859
    mDebug("drop stream[%d/%d]: %s", i + 1, dropReq.count, streamName);
7,223✔
860

861
    code = mndAcquireStream(pMnode, streamName, &pStream);
7,223✔
862
    if (pStream == NULL || code != 0) {
7,223✔
863
      mWarn("stream:%s not exist, ignore not exist is set, drop stream exec done with success", streamName);
992✔
864
      sdbRelease(pMnode->pSdb, pStream);
992✔
865
      pStream = NULL;
992✔
866
      notExistNum++;
992✔
867
      continue;
992✔
868
    }
869

870
    int64_t streamId = pStream->pCreate->streamId;
6,231✔
871

872
    if ((code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB,
6,231✔
873
                                          pStream->pCreate->streamDB)) ||
12,462✔
874
        (code = mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_DROP, PRIV_OBJ_STREAM, pStream->ownerId,
6,231✔
875
                                         pStream->pCreate->streamDB, pStream->pCreate->name))) {
6,231✔
876
      mstsError("user %s failed to drop stream %s since %s", pReq->info.conn.user, streamName, tstrerror(code));
×
877
      sdbRelease(pMnode->pSdb, pStream);
×
878
      pStream = NULL;
×
UNCOV
879
      mndTransDrop(pTrans);
×
UNCOV
880
      pTrans = NULL;
×
UNCOV
881
      goto _OVER;
×
882
    }
883

884
    if (pStream->pCreate->tsmaId != 0) {
6,231✔
885
      mstsDebug("try to drop tsma related stream, tsmaId:%" PRIx64, pStream->pCreate->tsmaId);
×
886

887
      void    *pIter = NULL;
×
888
      SSmaObj *pSma = NULL;
×
889
      pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSma);
×
890
      while (pIter) {
×
891
        if (pSma && pSma->uid == pStream->pCreate->tsmaId) {
×
UNCOV
892
          sdbRelease(pMnode->pSdb, pSma);
×
893
          sdbRelease(pMnode->pSdb, pStream);
×
894
          pStream = NULL;
×
895

896
          sdbCancelFetch(pMnode->pSdb, pIter);
×
897
          code = TSDB_CODE_TSMA_MUST_BE_DROPPED;
×
898

899
          mstsError("refused to drop tsma-related stream %s since tsma still exists", streamName);
×
UNCOV
900
          mndTransDrop(pTrans);
×
UNCOV
901
          pTrans = NULL;
×
902
          goto _OVER;
×
903
        }
904

UNCOV
905
        if (pSma) {
×
906
          sdbRelease(pMnode->pSdb, pSma);
×
907
        }
908

UNCOV
909
        pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSma);
×
910
      }
911
    }
912

913
    mstsInfo("start to drop stream %s", pStream->pCreate->name);
6,231✔
914

915
    pStream->updateTime = taosGetTimestampMs();
12,462✔
916

917
    atomic_store_8(&pStream->userDropped, 1);
6,231✔
918

919
    MND_STREAM_SET_LAST_TS(STM_EVENT_DROP_STREAM, pStream->updateTime);
6,231✔
920

921
    msmUndeployStream(pMnode, streamId, pStream->pCreate->name);
6,231✔
922

923
    // Append drop stream operation to the transaction
924
    code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_DROPPED);
6,231✔
925
    if (code) {
6,231✔
UNCOV
926
      mstsError("trans:%d, failed to append drop stream %s trans since %s", pTrans->id, streamName, tstrerror(code));
×
927
      sdbRelease(pMnode->pSdb, pStream);
×
928
      pStream = NULL;
×
929
      // mndStreamTransAppend already called mndTransDrop on failure, set pTrans to NULL to avoid double free
UNCOV
930
      pTrans = NULL;
×
UNCOV
931
      goto _OVER;
×
932
    }
933

934
    sdbRelease(pMnode->pSdb, pStream);
6,231✔
935
    pStream = NULL;
6,231✔
936

937
    mstsDebug("drop stream %s added to transaction", streamName);
6,231✔
938
  }
939

940
  // Prepare and execute the transaction for all streams
941
  if (notExistNum < dropReq.count) {
5,735✔
942
    code = mndTransPrepare(pMnode, pTrans);
5,487✔
943
    if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
5,487✔
UNCOV
944
      mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, tstrerror(code));
×
UNCOV
945
      mndTransDrop(pTrans);
×
UNCOV
946
      goto _OVER;
×
947
    }
948
    mInfo("trans:%d, drop stream transaction prepared for %d streams", pTrans->id, dropReq.count - notExistNum);
5,487✔
949
  } else {
950
    // All streams don't exist, no need to prepare transaction
951
    mndTransDrop(pTrans);
248✔
952
    pTrans = NULL;
248✔
953
  }
954

955
  if (tsAuditLevel >= AUDIT_LEVEL_DATABASE && notExistNum < dropReq.count) {
5,735✔
956
    int64_t tse = taosGetTimestampMs();
5,487✔
957
    double  duration = (double)(tse - tss);
5,487✔
958
    duration = duration / 1000;
5,487✔
959
    // Use first stream's database for audit (assuming all streams are from same db in batch)
960
    if (dropReq.count > 0) {
5,487✔
961
      SStreamObj *pFirstStream = NULL;
5,487✔
962
      if (mndAcquireStream(pMnode, dropReq.name[0], &pFirstStream) == 0 && pFirstStream != NULL) {
5,487✔
UNCOV
963
        auditRecord(pReq, pMnode->clusterId, "dropStream", "", pFirstStream->pCreate->streamDB, NULL, 0, duration, 0);
×
UNCOV
964
        sdbRelease(pMnode->pSdb, pFirstStream);
×
965
      }
966
    }
967
  }
968

969
  // If any stream was successfully added to transaction, return ACTION_IN_PROGRESS
970
  // Otherwise, all streams don't exist (and igNotExists is set), return SUCCESS
971
  code = (notExistNum < dropReq.count) ? TSDB_CODE_ACTION_IN_PROGRESS : TSDB_CODE_SUCCESS;
5,735✔
972

973
_OVER:
5,735✔
974
  if (pStream) {
5,735✔
UNCOV
975
    sdbRelease(pMnode->pSdb, pStream);
×
976
  }
977
  if (pTrans) {
5,735✔
978
    mndTransDrop(pTrans);
5,487✔
979
  }
980
  mndReleaseUser(pMnode, pOperUser);
5,735✔
981
  tFreeMDropStreamReq(&dropReq);
5,735✔
982
  TAOS_RETURN(code);
5,735✔
983
}
984

985
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
172,754✔
986
  SMnode     *pMnode = pReq->info.node;
172,754✔
987
  SStreamObj *pStream = NULL;
172,754✔
988
  SStreamObj  streamObj = {0};
172,754✔
989
  SUserObj    *pOperUser = NULL;
172,754✔
990
  int32_t     code = TSDB_CODE_SUCCESS;
172,754✔
991
  int32_t     lino = 0;
172,754✔
992
  STrans     *pTrans = NULL;
172,754✔
993
  uint64_t    streamId = 0;
172,754✔
994
  SCMCreateStreamReq* pCreate = NULL;
172,754✔
995
  int64_t             tss = taosGetTimestampMs();
172,754✔
996

997
  if ((code = grantCheck(TSDB_GRANT_STREAMS)) < 0) {
172,754✔
UNCOV
998
    goto _OVER;
×
999
  }
1000
  
1001
#ifdef WINDOWS
1002
  code = TSDB_CODE_MND_INVALID_PLATFORM;
1003
  goto _OVER;
1004
#endif
1005

1006
  pCreate = taosMemoryCalloc(1, sizeof(SCMCreateStreamReq));
172,754✔
1007
  TSDB_CHECK_NULL(pCreate, code, lino, _OVER, terrno);
172,754✔
1008
  
1009
  code = tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, pCreate);
172,754✔
1010
  TSDB_CHECK_CODE(code, lino, _OVER);
172,754✔
1011

1012
  streamId = pCreate->streamId;
172,754✔
1013

1014
  mstsInfo("start to create stream %s, sql:%s", pCreate->name, pCreate->sql);
172,754✔
1015

1016
  int32_t snodeId = msmAssignRandomSnodeId(pMnode, streamId);
172,754✔
1017
  if (!GOT_SNODE(snodeId)) {
172,754✔
1018
    code = terrno;
2,490✔
1019
    TSDB_CHECK_CODE(code, lino, _OVER);
2,490✔
1020
  }
1021
  
1022
  code = mndAcquireStream(pMnode, pCreate->name, &pStream);
170,264✔
1023
  if (pStream != NULL && code == 0) {
170,264✔
1024
    if (pCreate->igExists) {
4,960✔
UNCOV
1025
      mstsInfo("stream %s already exist, ignore exist is set", pCreate->name);
×
1026
    } else {
1027
      code = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
4,960✔
1028
    }
1029

1030
    mndReleaseStream(pMnode, pStream);
4,960✔
1031
    goto _OVER;
4,960✔
1032
  } else if (code != TSDB_CODE_MND_STREAM_NOT_EXIST) {
165,304✔
UNCOV
1033
    goto _OVER;
×
1034
  }
1035

1036
  code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser);
165,304✔
1037
  if (pOperUser == NULL) {
165,304✔
UNCOV
1038
    TSDB_CHECK_CODE(TSDB_CODE_MND_NO_USER_FROM_CONN, lino, _OVER);
×
1039
  }
1040

1041
  code = mndStreamValidateCreate(pMnode, pReq, pCreate);
165,304✔
1042
  TSDB_CHECK_CODE(code, lino, _OVER);
165,304✔
1043

1044
  mndStreamBuildObj(pMnode, &streamObj, pCreate, pOperUser, snodeId);
165,304✔
1045
  pCreate = NULL;
165,304✔
1046

1047
  pStream = &streamObj;
165,304✔
1048

1049
  code = mndStreamCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_DB, MND_STREAM_CREATE_NAME, &pTrans);
165,304✔
1050
  if (pTrans == NULL || code) {
165,304✔
UNCOV
1051
    goto _OVER;
×
1052
  }
1053

1054
  // create stb for stream
1055
  if (TSDB_SUPER_TABLE == pStream->pCreate->outTblType && !pStream->pCreate->outStbExists) {
165,304✔
1056
    pStream->pCreate->outStbUid = mndGenerateUid(pStream->pCreate->outTblName, strlen(pStream->pCreate->outTblName));
59,820✔
1057
    code = mndStreamCreateOutStb(pMnode, pTrans, pStream->pCreate, RPC_MSG_USER(pReq));
59,820✔
1058
    TSDB_CHECK_CODE(code, lino, _OVER);
59,820✔
1059
  }
1060

1061
  // add stream to trans
1062
  code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_READY);
165,304✔
1063
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
165,304✔
UNCOV
1064
    mstsError("failed to persist stream %s since %s", pStream->pCreate->name, tstrerror(code));
×
UNCOV
1065
    goto _OVER;
×
1066
  }
1067

1068
  // execute creation
1069
  code = mndTransPrepare(pMnode, pTrans);
165,304✔
1070
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
165,304✔
UNCOV
1071
    mstsError("trans:%d, failed to prepare since %s", pTrans->id, tstrerror(code));
×
UNCOV
1072
    goto _OVER;
×
1073
  }
1074
  code = TSDB_CODE_ACTION_IN_PROGRESS;
165,304✔
1075

1076
  if (tsAuditLevel >= AUDIT_LEVEL_DATABASE) {
165,304✔
1077
    int64_t tse = taosGetTimestampMs();
165,304✔
1078
    double  duration = (double)(tse - tss);
165,304✔
1079
    duration = duration / 1000;
165,304✔
1080
    auditRecord(pReq, pMnode->clusterId, "createStream", pStream->pCreate->streamDB, pStream->pCreate->name,
165,304✔
1081
                pStream->pCreate->sql, strlen(pStream->pCreate->sql), duration, 0);
165,304✔
1082
  }
1083

1084
  MND_STREAM_SET_LAST_TS(STM_EVENT_CREATE_STREAM, taosGetTimestampMs());
304,622✔
1085

1086
  mstPostStreamAction(mStreamMgmt.actionQ, streamId, pStream->pCreate->name, NULL, true, STREAM_ACT_DEPLOY);
165,304✔
1087

1088
_OVER:
172,754✔
1089

1090
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
172,754✔
1091
    if (pStream && pStream->pCreate) {
7,450✔
1092
      mstsError("failed to create stream %s at line:%d since %s", pStream->pCreate->name, lino, tstrerror(code));
4,960✔
1093
    } else {
1094
      mstsError("failed to create stream at line:%d since %s", lino, tstrerror(code));
2,490✔
1095
    }
1096
  } else {
1097
    mstsDebug("create stream %s half completed", pStream->pCreate ? pStream->pCreate->name : "unknown");
165,304✔
1098
  }
1099

1100
  tFreeSCMCreateStreamReq(pCreate);
172,754✔
1101
  taosMemoryFreeClear(pCreate);
172,754✔
1102

1103
  mndTransDrop(pTrans);
172,754✔
1104
  tFreeStreamObj(&streamObj);
172,754✔
1105
  mndReleaseUser(pMnode, pOperUser);
172,754✔
1106

1107
  return code;
172,754✔
1108
}
1109

1110
static int32_t mndProcessRecalcStreamReq(SRpcMsg *pReq) {
11,177✔
1111
  SMnode     *pMnode = pReq->info.node;
11,177✔
1112
  SStreamObj *pStream = NULL;
11,177✔
1113
  SUserObj   *pOperUser = NULL;
11,177✔
1114
  int32_t     code = 0;
11,177✔
1115
  int64_t     tss = taosGetTimestampMs();
11,177✔
1116

1117
  if ((code = grantCheckExpire(TSDB_GRANT_STREAMS)) < 0) {
11,177✔
UNCOV
1118
    return code;
×
1119
  }
1120

1121
  SMRecalcStreamReq recalcReq = {0};
11,177✔
1122
  if (tDeserializeSMRecalcStreamReq(pReq->pCont, pReq->contLen, &recalcReq) < 0) {
11,177✔
UNCOV
1123
    tFreeMRecalcStreamReq(&recalcReq);
×
UNCOV
1124
    TAOS_RETURN(TSDB_CODE_INVALID_MSG);
×
1125
  }
1126

1127
  code = mndAcquireStream(pMnode, recalcReq.name, &pStream);
11,177✔
1128
  if (pStream == NULL || code != 0) {
11,177✔
UNCOV
1129
    mError("stream:%s not exist, failed to recalc stream", recalcReq.name);
×
UNCOV
1130
    tFreeMRecalcStreamReq(&recalcReq);
×
UNCOV
1131
    TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
×
1132
  }
1133

1134
  int64_t streamId = pStream->pCreate->streamId;
11,177✔
1135
  
1136
  mstsInfo("start to recalc stream %s", recalcReq.name);
11,177✔
1137

1138
  // code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), MND_OPER_WRITE_DB, pStream->pCreate->streamDB);
1139
  // if (code != TSDB_CODE_SUCCESS) {
1140
  //   mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), recalcReq.name, tstrerror(code));
1141
  //   sdbRelease(pMnode->pSdb, pStream);
1142
  //   tFreeMRecalcStreamReq(&recalcReq);
1143
  //   return code;
1144
  // }
1145

1146
  if ((code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser))) {
11,177✔
1147
    mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
UNCOV
1148
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
1149
    tFreeMRecalcStreamReq(&recalcReq);
×
UNCOV
1150
    TAOS_RETURN(code);
×
1151
  }
1152

1153
  if ((code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB,
11,177✔
1154
                                        pStream->pCreate->streamDB)) ||
14,764✔
1155
      (code = mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_RECALC, PRIV_OBJ_STREAM, pStream->ownerId,
3,587✔
1156
                                       pStream->pCreate->streamDB, pStream->pCreate->name))) {
3,587✔
1157
    mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
7,590✔
1158
    mndReleaseUser(pMnode, pOperUser);
7,590✔
1159
    sdbRelease(pMnode->pSdb, pStream);
7,590✔
1160
    tFreeMRecalcStreamReq(&recalcReq);
7,590✔
1161
    return code;
7,590✔
1162
  }
1163

1164
  mndReleaseUser(pMnode, pOperUser); // release user after privilege check
3,587✔
1165

1166
  if (atomic_load_8(&pStream->userDropped)) {
3,587✔
1167
    code = TSDB_CODE_MND_STREAM_DROPPING;
×
1168
    mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), recalcReq.name, tstrerror(code));
×
UNCOV
1169
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
1170
    tFreeMRecalcStreamReq(&recalcReq);
×
UNCOV
1171
    return code;
×
1172
  }
1173

1174
  if (atomic_load_8(&pStream->userStopped)) {
3,587✔
1175
    code = TSDB_CODE_MND_STREAM_STOPPED;
×
1176
    mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), recalcReq.name, tstrerror(code));
×
UNCOV
1177
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
1178
    tFreeMRecalcStreamReq(&recalcReq);
×
UNCOV
1179
    return code;
×
1180
  }
1181

1182
  if (WINDOW_TYPE_PERIOD == pStream->pCreate->triggerType) {
3,587✔
1183
    code = TSDB_CODE_OPS_NOT_SUPPORT;
203✔
1184
    mstsError("failed to recalc stream %s since %s", recalcReq.name, tstrerror(code));
203✔
1185
    sdbRelease(pMnode->pSdb, pStream);
203✔
1186
    tFreeMRecalcStreamReq(&recalcReq);
203✔
1187
    return code;
203✔
1188
  }
1189

1190
  /*
1191
  pStream->updateTime = taosGetTimestampMs();
1192

1193
  STrans *pTrans = NULL;
1194
  code = mndStreamCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_RECALC_NAME, &pTrans);
1195
  if (pTrans == NULL || code) {
1196
    mstsError("failed to recalc stream %s since %s", recalcReq.name, tstrerror(code));
1197
    sdbRelease(pMnode->pSdb, pStream);
1198
    return code;
1199
  }
1200

1201
  // stop stream
1202
  code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_READY);
1203
  if (code != TSDB_CODE_SUCCESS) {
1204
    sdbRelease(pMnode->pSdb, pStream);
1205
    mndTransDrop(pTrans);
1206
    return code;
1207
  }
1208

1209
  code = mndTransPrepare(pMnode, pTrans);
1210
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
1211
    mError("trans:%d, failed to prepare stop stream trans since %s", pTrans->id, tstrerror(code));
1212
    sdbRelease(pMnode->pSdb, pStream);
1213
    mndTransDrop(pTrans);
1214
    return code;
1215
  }
1216
*/
1217

1218
  code = msmRecalcStream(pMnode, pStream->pCreate->streamId, &recalcReq.timeRange);
3,384✔
1219
  if (code != TSDB_CODE_SUCCESS) {
3,384✔
UNCOV
1220
    sdbRelease(pMnode->pSdb, pStream);
×
UNCOV
1221
    tFreeMRecalcStreamReq(&recalcReq);
×
UNCOV
1222
    return code;
×
1223
  }
1224

1225
  if (tsAuditLevel >= AUDIT_LEVEL_DATABASE){
3,384✔
1226
    char buf[128];
3,384✔
1227
    snprintf(buf, sizeof(buf), "start:%" PRId64 ", end:%" PRId64, recalcReq.timeRange.skey, recalcReq.timeRange.ekey);
3,384✔
1228
    int64_t tse = taosGetTimestampMs();
3,384✔
1229
    double  duration = (double)(tse - tss);
3,384✔
1230
    duration = duration / 1000;
3,384✔
1231
    auditRecord(pReq, pMnode->clusterId, "recalcStream", pStream->name, recalcReq.name, buf, strlen(buf), duration, 0);
3,384✔
1232
  }  
1233

1234
  sdbRelease(pMnode->pSdb, pStream);
3,384✔
1235
  tFreeMRecalcStreamReq(&recalcReq);
3,384✔
1236
//  mndTransDrop(pTrans);
1237

1238
  return TSDB_CODE_SUCCESS;
3,384✔
1239
}
1240

1241

1242
int32_t mndInitStream(SMnode *pMnode) {
416,237✔
1243
  SSdbTable table = {
416,237✔
1244
      .sdbType = SDB_STREAM,
1245
      .keyType = SDB_KEY_BINARY,
1246
      .encodeFp = (SdbEncodeFp)mndStreamActionEncode,
1247
      .decodeFp = (SdbDecodeFp)mndStreamActionDecode,
1248
      .insertFp = (SdbInsertFp)mndStreamActionInsert,
1249
      .updateFp = (SdbUpdateFp)mndStreamActionUpdate,
1250
      .deleteFp = (SdbDeleteFp)mndStreamActionDelete,
1251
  };
1252

1253
  if (!tsDisableStream) {
416,237✔
1254
    mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq);
416,237✔
1255
    mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);
416,237✔
1256
    mndSetMsgHandle(pMnode, TDMT_MND_START_STREAM, mndProcessStartStreamReq);
416,237✔
1257
    mndSetMsgHandle(pMnode, TDMT_MND_STOP_STREAM, mndProcessStopStreamReq);
416,237✔
1258
    mndSetMsgHandle(pMnode, TDMT_MND_STREAM_HEARTBEAT, mndProcessStreamHb);  
416,237✔
1259
    mndSetMsgHandle(pMnode, TDMT_MND_RECALC_STREAM, mndProcessRecalcStreamReq);
416,237✔
1260
  }
1261
  
1262
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream);
416,237✔
1263
  mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream);
416,237✔
1264
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndRetrieveStreamTask);
416,237✔
1265
  mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndCancelGetNextStreamTask);
416,237✔
1266
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAM_RECALCULATES, mndRetrieveStreamRecalculates);
416,237✔
1267
  mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAM_RECALCULATES, mndCancelGetNextStreamRecalculates);
416,237✔
1268

1269
  int32_t code = sdbSetTable(pMnode->pSdb, table);
416,237✔
1270
  if (code) {
416,237✔
UNCOV
1271
    return code;
×
1272
  }
1273

1274
  //code = sdbSetTable(pMnode->pSdb, tableSeq);
1275
  return code;
416,237✔
1276
}
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