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

taosdata / TDengine / #4971

28 Feb 2026 08:05AM UTC coverage: 67.671% (-0.04%) from 67.707%
#4971

push

travis-ci

web-flow
fix(planner): disable project block merge in non-top-level subplans (#34617)

208281 of 307783 relevant lines covered (67.67%)

130135765.28 hits per line

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

68.96
/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) {
427,465✔
64
  mDebug("try to clean up stream");
427,465✔
65
  
66
  msmHandleBecomeNotLeader(pMnode);
427,465✔
67
  
68
  mDebug("mnd stream runtime info cleanup");
427,465✔
69
}
427,465✔
70

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

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

84
  if (sver != MND_STREAM_VER_NUMBER && sver != MND_STREAM_COMPATIBLE_VER_NUMBER) {
209,701✔
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));
209,701✔
90
  TSDB_CHECK_NULL(pRow, code, lino, _over, terrno);
209,701✔
91

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

95
  SDB_GET_INT32(pRaw, dataPos, &tlen, _over);
209,701✔
96

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

100
  SDB_GET_BINARY(pRaw, dataPos, buf, tlen, _over);
209,701✔
101

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

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

111
_over:
209,701✔
112
  taosMemoryFreeClear(buf);
209,701✔
113

114
  if (code != TSDB_CODE_SUCCESS) {
209,701✔
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);
209,701✔
123

124
    terrno = 0;
209,701✔
125
    return pRow;
209,701✔
126
  }
127
}
128

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

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

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

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

151
int32_t mndAcquireStream(SMnode *pMnode, char *streamName, SStreamObj **pStream) {
413,366✔
152
  int32_t code = 0;
413,366✔
153
  SSdb   *pSdb = pMnode->pSdb;
413,366✔
154
  (*pStream) = sdbAcquire(pSdb, SDB_STREAM, streamName);
413,366✔
155
  if ((*pStream) == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) {
413,366✔
156
    code = TSDB_CODE_MND_STREAM_NOT_EXIST;
189,092✔
157
  }
158
  return code;
413,366✔
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) {
210,358✔
190
  SSdb *pSdb = pMnode->pSdb;
210,358✔
191
  sdbRelease(pSdb, pStream);
210,358✔
192
}
210,358✔
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,
176,477✔
201
                              int32_t snodeId) {
202
  int32_t code = 0;
176,477✔
203

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

210
  pObj->userDropped = 0;
176,477✔
211
  pObj->userStopped = 0;
176,477✔
212

213
  pObj->createTime = taosGetTimestampMs();
176,477✔
214
  pObj->updateTime = pObj->createTime;
176,477✔
215

216
  mstLogSStreamObj("create stream", pObj);
176,477✔
217
}
176,477✔
218

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

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

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

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

251
  if (NULL == pStream->outTags) {
64,550✔
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);
64,550✔
266
    createReq.pTags = taosArrayInit_s(sizeof(SField), createReq.numOfTags);
64,550✔
267
    TSDB_CHECK_NULL(createReq.pTags, code, lino, _OVER, terrno);
64,550✔
268

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

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

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

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

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

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

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

309
  SStbObj stbObj = {0};
64,550✔
310

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

315
  stbObj.uid = pStream->outStbUid;
64,550✔
316

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

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

324
  tFreeSMCreateStbReq(&createReq);
64,550✔
325
  mndFreeStb(&stbObj);
64,550✔
326
  mndReleaseStb(pMnode, pStb);
64,550✔
327
  mndReleaseDb(pMnode, pDb);
64,550✔
328
  return code;
64,550✔
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) {
176,477✔
341
  int32_t code = 0, lino = 0;
176,477✔
342
  int64_t streamId = pCreate->streamId;
176,477✔
343
  char   *pUser = RPC_MSG_USER(pReq);
176,477✔
344

345
  if (pCreate->streamDB) {
176,477✔
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,
176,477✔
348
                                     pCreate->streamDB, false);
176,477✔
349
    if (code) {
176,477✔
350
      if (code == TSDB_CODE_MND_NO_RIGHTS) code = TSDB_CODE_PAR_DB_USE_PERMISSION_DENIED;
×
351
      mstsError("user %s failed to create stream %s in db %s since %s", pUser, pCreate->name, pCreate->streamDB,
×
352
                tstrerror(code));
353
    }
354
    TSDB_CHECK_CODE(code, lino, _OVER);
176,477✔
355
  }
356

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

380
  if (pCreate->calcDB) {
176,477✔
381
    int32_t dbNum = taosArrayGetSize(pCreate->calcDB);
173,249✔
382
    for (int32_t i = 0; i < dbNum; ++i) {
346,498✔
383
      char *calcDB = taosArrayGetP(pCreate->calcDB, i);
173,249✔
384
      // code = mndCheckDbPrivilegeByName(pMnode, pUser, MND_OPER_READ_DB, calcDB);
385
      code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB, calcDB, false);
173,249✔
386
      if (code) {
173,249✔
387
        if (code == TSDB_CODE_MND_NO_RIGHTS) code = TSDB_CODE_PAR_DB_USE_PERMISSION_DENIED;
×
388
        mstsError("user %s failed to create stream %s using calcDB %s since %s", pUser, pCreate->name, calcDB,
×
389
                  tstrerror(code));
390
      }
391
      TSDB_CHECK_CODE(code, lino, _OVER);
173,249✔
392
    }
393
  }
394

395
  if (pCreate->outDB) {
176,477✔
396
    // code = mndCheckDbPrivilegeByName(pMnode, pUser, MND_OPER_WRITE_DB, pCreate->outDB);
397
    code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB, pCreate->outDB,
173,249✔
398
                                     false);
399
    if (code) {
173,249✔
400
      if (code == TSDB_CODE_MND_NO_RIGHTS) code = TSDB_CODE_PAR_DB_USE_PERMISSION_DENIED;
×
401
      mstsError("user %s failed to create stream %s using out db %s since %s", pUser, pCreate->name, pCreate->outDB,
×
402
                tstrerror(code));
403
    }
404
    TSDB_CHECK_CODE(code, lino, _OVER);
173,249✔
405
  }
406

407
  int32_t streamNum = sdbGetSize(pMnode->pSdb, SDB_STREAM);
176,477✔
408
  if (streamNum > MND_STREAM_MAX_NUM) {
176,477✔
409
    code = TSDB_CODE_MND_TOO_MANY_STREAMS;
×
410
    mstsError("failed to create stream %s since %s, stream number:%d", pCreate->name, tstrerror(code), streamNum);
×
411
    return code;
×
412
  }
413

414
_OVER:
176,477✔
415

416
  return code;
176,477✔
417
}
418

419
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
648,556✔
420
  SSdb   *pSdb = pMnode->pSdb;
648,556✔
421
  void   *pIter = NULL;
648,556✔
422
  int32_t code = 0;
648,556✔
423

424
  while (1) {
45,477✔
425
    SStreamObj *pStream = NULL;
694,033✔
426
    pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
694,033✔
427
    if (pIter == NULL) break;
694,033✔
428

429
    if (0 == strcmp(pStream->pCreate->streamDB, pDb->name)) {
45,477✔
430
      mInfo("start to drop stream %s in db %s", pStream->pCreate->name, pDb->name);
17,950✔
431
      
432
      pStream->updateTime = taosGetTimestampMs();
35,900✔
433
      
434
      atomic_store_8(&pStream->userDropped, 1);
17,950✔
435
      
436
      MND_STREAM_SET_LAST_TS(STM_EVENT_DROP_STREAM, pStream->updateTime);
17,950✔
437
      
438
      msmUndeployStream(pMnode, pStream->pCreate->streamId, pStream->pCreate->name);
17,950✔
439
      
440
      // drop stream
441
      code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_DROPPED);
17,950✔
442
      if (code) {
17,950✔
443
        mError("drop db trans:%d failed to append drop stream trans since %s", pTrans->id, tstrerror(code));
×
444
        sdbRelease(pSdb, pStream);
×
445
        sdbCancelFetch(pSdb, pIter);
×
446
        TAOS_RETURN(code);
×
447
      }
448
    }
449

450
    sdbRelease(pSdb, pStream);
45,477✔
451
  }
452

453
  return 0;
648,556✔
454
}
455

456
static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
226,327✔
457
  SMnode     *pMnode = pReq->info.node;
226,327✔
458
  SSdb       *pSdb = pMnode->pSdb;
226,327✔
459
  int32_t     numOfRows = 0;
226,327✔
460
  SStreamObj *pStream = NULL;
226,327✔
461
  SUserObj   *pOperUser = NULL;
226,327✔
462
  int32_t     code = 0, lino = 0;
226,327✔
463
  bool        showAll = false;
226,327✔
464

465
  TAOS_CHECK_EXIT(mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser));
226,327✔
466
  showAll =
226,327✔
467
      (0 == mndCheckObjPrivilegeRec(pMnode, pOperUser, PRIV_CM_SHOW, PRIV_OBJ_STREAM, 0, pOperUser->acctId, "*", "*"));
226,327✔
468

469
  while (numOfRows < rows) {
739,702✔
470
    pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
739,702✔
471
    if (pShow->pIter == NULL) break;
739,702✔
472

473
    if (!showAll) {
513,375✔
474
      if ((mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_SHOW, PRIV_OBJ_STREAM, pStream->ownerId,
×
475
                                    pStream->pCreate->streamDB, mndGetStableStr(pStream->pCreate->name)))) {
×
476
        sdbRelease(pSdb, pStream);
×
477
        continue;
×
478
      }
479
    }
480

481
    code = mstSetStreamAttrResBlock(pMnode, pStream, pBlock, numOfRows);
513,375✔
482
    if (code == 0) {
513,375✔
483
      numOfRows++;
513,375✔
484
    }
485
    sdbRelease(pSdb, pStream);
513,375✔
486
  }
487
  code = 0;
226,327✔
488
  pShow->numOfRows += numOfRows;
226,327✔
489
_exit:
226,327✔
490
  mndReleaseUser(pMnode, pOperUser);
226,327✔
491
  if (code != 0) {
226,327✔
492
    mError("failed to retrieve stream list at line %d since %s", lino, tstrerror(code));
×
493
    TAOS_RETURN(code);
×
494
  }
495
  return numOfRows;
226,327✔
496
}
497

498
static void mndCancelGetNextStream(SMnode *pMnode, void *pIter) {
×
499
  SSdb *pSdb = pMnode->pSdb;
×
500
  sdbCancelFetchByType(pSdb, pIter, SDB_STREAM);
×
501
}
×
502

503
static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
307,407✔
504
  SMnode     *pMnode = pReq->info.node;
307,407✔
505
  SSdb       *pSdb = pMnode->pSdb;
307,407✔
506
  int32_t     numOfRows = 0;
307,407✔
507
  SStreamObj *pStream = NULL;
307,407✔
508
  int32_t     code = 0;
307,407✔
509

510
  while (numOfRows < rowsCapacity) {
2,943,045✔
511
    pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
2,847,860✔
512
    if (pShow->pIter == NULL) {
2,847,860✔
513
      break;
212,222✔
514
    }
515

516
    code = mstSetStreamTasksResBlock(pStream, pBlock, &numOfRows, rowsCapacity);
2,635,638✔
517

518
    sdbRelease(pSdb, pStream);
2,635,638✔
519
  }
520

521
  pShow->numOfRows += numOfRows;
307,407✔
522
  return numOfRows;
307,407✔
523
}
524

525
static void mndCancelGetNextStreamTask(SMnode *pMnode, void *pIter) {
×
526
  SSdb *pSdb = pMnode->pSdb;
×
527
  sdbCancelFetchByType(pSdb, pIter, SDB_STREAM);
×
528
}
×
529

530
static int32_t mndRetrieveStreamRecalculates(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
263✔
531
  SMnode     *pMnode = pReq->info.node;
263✔
532
  SSdb       *pSdb = pMnode->pSdb;
263✔
533
  int32_t     numOfRows = 0;
263✔
534
  SStreamObj *pStream = NULL;
263✔
535
  int32_t     code = 0;
263✔
536

537
  while (numOfRows < rowsCapacity) {
526✔
538
    pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
526✔
539
    if (pShow->pIter == NULL) {
526✔
540
      break;
263✔
541
    }
542

543
    code = mstSetStreamRecalculatesResBlock(pStream, pBlock, &numOfRows, rowsCapacity);
263✔
544

545
    sdbRelease(pSdb, pStream);
263✔
546
  }
547

548
  pShow->numOfRows += numOfRows;
263✔
549
  return numOfRows;
263✔
550
}
551

552
static void mndCancelGetNextStreamRecalculates(SMnode *pMnode, void *pIter) {
×
553
  SSdb *pSdb = pMnode->pSdb;
×
554
  sdbCancelFetchByType(pSdb, pIter, SDB_STREAM);
×
555
}
×
556

557

558
static bool mndStreamUpdateTagsFlag(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
2,190,596✔
559
  SStreamObj *pStream = pObj;
2,190,596✔
560
  if (atomic_load_8(&pStream->userDropped)) {
2,190,596✔
561
    return true;
×
562
  }
563

564
  if (TSDB_SUPER_TABLE != pStream->pCreate->triggerTblType && 
2,190,596✔
565
      TSDB_CHILD_TABLE != pStream->pCreate->triggerTblType && 
1,238,704✔
566
      TSDB_VIRTUAL_CHILD_TABLE != pStream->pCreate->triggerTblType) {
905,924✔
567
    return true;
126,122✔
568
  }
569

570
  if (pStream->pCreate->triggerTblSuid != *(uint64_t*)p1) {
2,064,474✔
571
    return true;
2,021,555✔
572
  }
573

574
  if (NULL == pStream->pCreate->partitionCols) {
42,919✔
575
    return true;
4,254✔
576
  }
577

578
  SNodeList* pList = NULL;
38,665✔
579
  int32_t code = nodesStringToList(pStream->pCreate->partitionCols, &pList);
38,665✔
580
  if (code) {
38,665✔
581
    nodesDestroyList(pList);
×
582
    mstError("partitionCols [%s] nodesStringToList failed with error:%s", (char*)pStream->pCreate->partitionCols, tstrerror(code));
×
583
    return true;
×
584
  }
585

586
  SSchema* pTags = (SSchema*)p2;
38,665✔
587
  int32_t* tagNum = (int32_t*)p3;
38,665✔
588

589
  SNode* pNode = NULL;
38,665✔
590
  FOREACH(pNode, pList) {
129,167✔
591
    SColumnNode* pCol = (SColumnNode*)pNode;
90,502✔
592
    for (int32_t i = 0; i < *tagNum; ++i) {
277,633✔
593
      if (pCol->colId == pTags[i].colId) {
261,972✔
594
        pTags[i].flags |= COL_REF_BY_STM;
74,841✔
595
        break;
74,841✔
596
      }
597
    }
598
  }
599

600
  nodesDestroyList(pList);
38,665✔
601
  
602
  return true;
38,665✔
603
}
604

605

606
void mndStreamUpdateTagsRefFlag(SMnode *pMnode, int64_t suid, SSchema* pTags, int32_t tagNum) {
14,759,207✔
607
  int32_t streamNum = sdbGetSize(pMnode->pSdb, SDB_STREAM);
14,759,207✔
608
  if (streamNum <= 0) {
14,759,210✔
609
    return;
14,623,811✔
610
  }
611

612
  sdbTraverse(pMnode->pSdb, SDB_STREAM, mndStreamUpdateTagsFlag, &suid, pTags, &tagNum);
135,399✔
613
}
614

615
static int32_t mndProcessStopStreamReq(SRpcMsg *pReq) {
2,240✔
616
  SMnode     *pMnode = pReq->info.node;
2,240✔
617
  SStreamObj *pStream = NULL;
2,240✔
618
  SUserObj   *pOperUser = NULL;
2,240✔
619
  int32_t     code = 0;
2,240✔
620

621
  SMPauseStreamReq pauseReq = {0};
2,240✔
622
  if (tDeserializeSMPauseStreamReq(pReq->pCont, pReq->contLen, &pauseReq) < 0) {
2,240✔
623
    TAOS_RETURN(TSDB_CODE_INVALID_MSG);
×
624
  }
625

626
  code = mndAcquireStream(pMnode, pauseReq.name, &pStream);
2,240✔
627
  if (pStream == NULL || code != 0) {
2,240✔
628
    if (pauseReq.igNotExists) {
×
629
      mInfo("stream:%s, not exist, not stop stream", pauseReq.name);
×
630
      taosMemoryFree(pauseReq.name);
×
631
      return 0;
×
632
    } else {
633
      mError("stream:%s not exist, failed to stop stream", pauseReq.name);
×
634
      taosMemoryFree(pauseReq.name);
×
635
      TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
×
636
    }
637
  }
638

639
  taosMemoryFree(pauseReq.name);
2,240✔
640

641
  int64_t streamId = pStream->pCreate->streamId;
2,240✔
642
  
643
  mstsInfo("start to stop stream %s", pStream->name);
2,240✔
644

645
  // code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), MND_OPER_WRITE_DB, pStream->pCreate->streamDB);
646
  if((code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser))) {
2,240✔
647
    mstsError("user %s failed to stop stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
648
    sdbRelease(pMnode->pSdb, pStream);
×
649
    return code;
×
650
  }
651
  if ((code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB,
2,240✔
652
                                        pStream->pCreate->streamDB, false))) {
2,240✔
653
    if (code == TSDB_CODE_MND_NO_RIGHTS) code = TSDB_CODE_PAR_DB_USE_PERMISSION_DENIED;
×
654
  }
655
  if ((code != TSDB_CODE_SUCCESS) ||
4,480✔
656
      (code = mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_STOP, PRIV_OBJ_STREAM, pStream->ownerId,
2,240✔
657
                                       pStream->pCreate->streamDB, mndGetStableStr(pStream->pCreate->name)))) {
2,240✔
658
    mstsError("user %s failed to stop stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
659
    mndReleaseUser(pMnode, pOperUser);
×
660
    sdbRelease(pMnode->pSdb, pStream);
×
661
    return code;
×
662
  }
663

664
  mndReleaseUser(pMnode, pOperUser); // release user after privilege check
2,240✔
665

666
  if (atomic_load_8(&pStream->userDropped)) {
2,240✔
667
    code = TSDB_CODE_MND_STREAM_DROPPING;
×
668
    mstsError("user %s failed to stop stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
669
    sdbRelease(pMnode->pSdb, pStream);
×
670
    return code;
×
671
  }
672

673
  STrans *pTrans = NULL;
2,240✔
674
  code = mndStreamCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_STOP_NAME, &pTrans);
2,240✔
675
  if (pTrans == NULL || code) {
2,240✔
676
    mstsError("failed to stop stream %s since %s", pStream->name, tstrerror(code));
×
677
    sdbRelease(pMnode->pSdb, pStream);
×
678
    return code;
×
679
  }
680

681
  pStream->updateTime = taosGetTimestampMs();
4,480✔
682

683
  atomic_store_8(&pStream->userStopped, 1);
2,240✔
684

685
  MND_STREAM_SET_LAST_TS(STM_EVENT_STOP_STREAM, pStream->updateTime);
2,240✔
686

687
  msmUndeployStream(pMnode, streamId, pStream->name);
2,240✔
688

689
  // stop stream
690
  code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_READY);
2,240✔
691
  if (code != TSDB_CODE_SUCCESS) {
2,240✔
692
    sdbRelease(pMnode->pSdb, pStream);
×
693
    mndTransDrop(pTrans);
×
694
    return code;
×
695
  }
696

697
  code = mndTransPrepare(pMnode, pTrans);
2,240✔
698
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
2,240✔
699
    mError("trans:%d, failed to prepare stop stream trans since %s", pTrans->id, tstrerror(code));
×
700
    sdbRelease(pMnode->pSdb, pStream);
×
701
    mndTransDrop(pTrans);
×
702
    return code;
×
703
  }
704

705
  sdbRelease(pMnode->pSdb, pStream);
2,240✔
706
  mndTransDrop(pTrans);
2,240✔
707

708
  return TSDB_CODE_ACTION_IN_PROGRESS;
2,240✔
709
}
710

711

712
static int32_t mndProcessStartStreamReq(SRpcMsg *pReq) {
2,240✔
713
  SMnode     *pMnode = pReq->info.node;
2,240✔
714
  SStreamObj *pStream = NULL;
2,240✔
715
  SUserObj   *pOperUser = NULL;
2,240✔
716
  int32_t     code = 0;
2,240✔
717

718
  if ((code = grantCheckExpire(TSDB_GRANT_STREAMS)) < 0) {
2,240✔
719
    return code;
×
720
  }
721

722
  SMResumeStreamReq resumeReq = {0};
2,240✔
723
  if (tDeserializeSMResumeStreamReq(pReq->pCont, pReq->contLen, &resumeReq) < 0) {
2,240✔
724
    TAOS_RETURN(TSDB_CODE_INVALID_MSG);
×
725
  }
726

727
  code = mndAcquireStream(pMnode, resumeReq.name, &pStream);
2,240✔
728
  if (pStream == NULL || code != 0) {
2,240✔
729
    if (resumeReq.igNotExists) {
×
730
      mInfo("stream:%s not exist, not start stream", resumeReq.name);
×
731
      taosMemoryFree(resumeReq.name);
×
732
      sdbRelease(pMnode->pSdb, pStream);
×
733
      return 0;
×
734
    } else {
735
      mError("stream:%s not exist, failed to start stream", resumeReq.name);
×
736
      taosMemoryFree(resumeReq.name);
×
737
      TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
×
738
    }
739
  }
740

741
  taosMemoryFree(resumeReq.name);
2,240✔
742

743
  int64_t streamId = pStream->pCreate->streamId;
2,240✔
744

745
  mstsInfo("start to start stream %s from stopped", pStream->name);
2,240✔
746

747
  // code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), MND_OPER_WRITE_DB, pStream->pCreate->streamDB);
748
  if ((code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser))) {
2,240✔
749
    mstsError("user %s failed to start stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
750
    sdbRelease(pMnode->pSdb, pStream);
×
751
    return code;
×
752
  }
753
  if ((code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB,
2,240✔
754
                                        pStream->pCreate->streamDB, false))) {
2,240✔
755
    if (code == TSDB_CODE_MND_NO_RIGHTS) code = TSDB_CODE_PAR_DB_USE_PERMISSION_DENIED;
×
756
  }
757
  if ((code != TSDB_CODE_SUCCESS) ||
4,480✔
758
      (code = mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_START, PRIV_OBJ_STREAM, pStream->ownerId,
2,240✔
759
                                       pStream->pCreate->streamDB, mndGetStableStr(pStream->pCreate->name)))) {
2,240✔
760
    mstsError("user %s failed to start stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
761
    mndReleaseUser(pMnode, pOperUser);
×
762
    sdbRelease(pMnode->pSdb, pStream);
×
763
    return code;
×
764
  }
765

766
  mndReleaseUser(pMnode, pOperUser); // release user after privilege check
2,240✔
767

768
  if (atomic_load_8(&pStream->userDropped)) {
2,240✔
769
    code = TSDB_CODE_MND_STREAM_DROPPING;
×
770
    mstsError("user %s failed to start stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
771
    sdbRelease(pMnode->pSdb, pStream);
×
772
    return code;
×
773
  }
774

775
  if (0 == atomic_load_8(&pStream->userStopped)) {
2,240✔
776
    code = TSDB_CODE_MND_STREAM_NOT_STOPPED;
×
777
    mstsError("user %s failed to start stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
778
    sdbRelease(pMnode->pSdb, pStream);
×
779
    return code;
×
780
  }
781
  
782
  atomic_store_8(&pStream->userStopped, 0);
2,240✔
783

784
  pStream->updateTime = taosGetTimestampMs();
4,480✔
785

786
  MND_STREAM_SET_LAST_TS(STM_EVENT_START_STREAM, pStream->updateTime);
2,240✔
787

788
  STrans *pTrans = NULL;
2,240✔
789
  code = mndStreamCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_START_NAME, &pTrans);
2,240✔
790
  if (pTrans == NULL || code) {
2,240✔
791
    mstsError("failed to start stream %s since %s", pStream->name, tstrerror(code));
×
792
    sdbRelease(pMnode->pSdb, pStream);
×
793
    return code;
×
794
  }
795

796
  code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_READY);
2,240✔
797
  if (code != TSDB_CODE_SUCCESS) {
2,240✔
798
    mstsError("failed to start stream %s since %s", pStream->name, tstrerror(code));
×
799
    sdbRelease(pMnode->pSdb, pStream);
×
800
    mndTransDrop(pTrans);
×
801
    return code;
×
802
  }
803

804
  code = mndTransPrepare(pMnode, pTrans);
2,240✔
805
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
2,240✔
806
    mstsError("trans:%d, failed to prepare start stream %s trans since %s", pTrans->id, pStream->name, tstrerror(code));
×
807
    sdbRelease(pMnode->pSdb, pStream);
×
808
    mndTransDrop(pTrans);
×
809
    return code;
×
810
  }
811

812
  mstPostStreamAction(mStreamMgmt.actionQ, streamId, pStream->name, NULL, true, STREAM_ACT_DEPLOY);
2,240✔
813

814
  sdbRelease(pMnode->pSdb, pStream);
2,240✔
815
  mndTransDrop(pTrans);
2,240✔
816

817
  return TSDB_CODE_ACTION_IN_PROGRESS;
2,240✔
818
}
819

820
static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
9,217✔
821
  SMnode     *pMnode = pReq->info.node;
9,217✔
822
  SStreamObj *pStream = NULL;
9,217✔
823
  SUserObj   *pOperUser = NULL;
9,217✔
824
  int32_t     code = 0;
9,217✔
825
  int32_t     notExistNum = 0;
9,217✔
826

827
  SMDropStreamReq dropReq = {0};
9,217✔
828
  int64_t         tss = taosGetTimestampMs();
9,217✔
829
  if (tDeserializeSMDropStreamReq(pReq->pCont, pReq->contLen, &dropReq) < 0) {
9,217✔
830
    mError("invalid drop stream msg recv, discarded");
×
831
    code = TSDB_CODE_INVALID_MSG;
×
832
    TAOS_RETURN(code);
×
833
  }
834

835
  mDebug("recv drop stream msg, count:%d", dropReq.count);
9,217✔
836

837
  // Acquire user object for privilege check
838
  code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser);
9,217✔
839
  if (code != 0) {
9,217✔
840
    tFreeMDropStreamReq(&dropReq);
×
841
    TAOS_RETURN(code);
×
842
  }
843

844
  // check if all streams exist
845
  if (!dropReq.igNotExists) {
9,217✔
846
    for (int32_t i = 0; i < dropReq.count; i++) {
15,081✔
847
      if (!sdbCheckExists(pMnode->pSdb, SDB_STREAM, dropReq.name[i])) {
8,188✔
848
        mError("stream:%s not exist failed to drop it", dropReq.name[i]);
1,036✔
849
        mndReleaseUser(pMnode, pOperUser);
1,036✔
850
        tFreeMDropStreamReq(&dropReq);
1,036✔
851
        TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
1,036✔
852
      }
853
    }
854
  }
855

856
  // Create a single transaction for all stream drops
857
  STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, MND_STREAM_DROP_NAME);
8,181✔
858
  if (pTrans == NULL) {
8,181✔
859
    mError("failed to create drop stream transaction since %s", tstrerror(terrno));
×
860
    code = terrno;
×
861
    mndReleaseUser(pMnode, pOperUser);
×
862
    tFreeMDropStreamReq(&dropReq);
×
863
    TAOS_RETURN(code);
×
864
  }
865
  pTrans->ableToBeKilled = true;
8,181✔
866

867
  // Process all streams and add them to the transaction
868
  for (int32_t i = 0; i < dropReq.count; i++) {
17,916✔
869
    char *streamName = dropReq.name[i];
9,735✔
870
    mDebug("drop stream[%d/%d]: %s", i + 1, dropReq.count, streamName);
9,735✔
871

872
    code = mndAcquireStream(pMnode, streamName, &pStream);
9,735✔
873
    if (pStream == NULL || code != 0) {
9,735✔
874
      mWarn("stream:%s not exist, ignore not exist is set, drop stream exec done with success", streamName);
1,036✔
875
      sdbRelease(pMnode->pSdb, pStream);
1,036✔
876
      pStream = NULL;
1,036✔
877
      notExistNum++;
1,036✔
878
      continue;
1,036✔
879
    }
880

881
    int64_t streamId = pStream->pCreate->streamId;
8,699✔
882

883
    if ((code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB,
8,699✔
884
                                          pStream->pCreate->streamDB, true))) {
8,699✔
885
      if (code == TSDB_CODE_MND_NO_RIGHTS) code = TSDB_CODE_PAR_DB_USE_PERMISSION_DENIED;
×
886
    }
887
    if ((code != TSDB_CODE_SUCCESS) ||
17,398✔
888
        (code = mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_DROP, PRIV_OBJ_STREAM, pStream->ownerId,
8,699✔
889
                                         pStream->pCreate->streamDB, mndGetStableStr(pStream->pCreate->name)))) {
8,699✔
890
      mstsError("user %s failed to drop stream %s since %s", pReq->info.conn.user, streamName, tstrerror(code));
×
891
      sdbRelease(pMnode->pSdb, pStream);
×
892
      pStream = NULL;
×
893
      mndTransDrop(pTrans);
×
894
      pTrans = NULL;
×
895
      goto _OVER;
×
896
    }
897

898
    if (pStream->pCreate->tsmaId != 0) {
8,699✔
899
      mstsDebug("try to drop tsma related stream, tsmaId:%" PRIx64, pStream->pCreate->tsmaId);
2,232✔
900

901
      void    *pIter = NULL;
2,232✔
902
      SSmaObj *pSma = NULL;
2,232✔
903
      pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSma);
2,232✔
904
      while (pIter) {
4,340✔
905
        if (pSma && pSma->uid == pStream->pCreate->tsmaId) {
2,108✔
906
          sdbRelease(pMnode->pSdb, pSma);
×
907
          sdbRelease(pMnode->pSdb, pStream);
×
908
          pStream = NULL;
×
909

910
          sdbCancelFetch(pMnode->pSdb, pIter);
×
911
          code = TSDB_CODE_TSMA_MUST_BE_DROPPED;
×
912

913
          mstsError("refused to drop tsma-related stream %s since tsma still exists", streamName);
×
914
          mndTransDrop(pTrans);
×
915
          pTrans = NULL;
×
916
          goto _OVER;
×
917
        }
918

919
        if (pSma) {
2,108✔
920
          sdbRelease(pMnode->pSdb, pSma);
2,108✔
921
        }
922

923
        pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSma);
2,108✔
924
      }
925
    }
926

927
    mstsInfo("start to drop stream %s", pStream->pCreate->name);
8,699✔
928

929
    pStream->updateTime = taosGetTimestampMs();
17,398✔
930

931
    atomic_store_8(&pStream->userDropped, 1);
8,699✔
932

933
    MND_STREAM_SET_LAST_TS(STM_EVENT_DROP_STREAM, pStream->updateTime);
8,699✔
934

935
    msmUndeployStream(pMnode, streamId, pStream->pCreate->name);
8,699✔
936

937
    // Append drop stream operation to the transaction
938
    code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_DROPPED);
8,699✔
939
    if (code) {
8,699✔
940
      mstsError("trans:%d, failed to append drop stream %s trans since %s", pTrans->id, streamName, tstrerror(code));
×
941
      sdbRelease(pMnode->pSdb, pStream);
×
942
      pStream = NULL;
×
943
      // mndStreamTransAppend already called mndTransDrop on failure, set pTrans to NULL to avoid double free
944
      pTrans = NULL;
×
945
      goto _OVER;
×
946
    }
947

948
    sdbRelease(pMnode->pSdb, pStream);
8,699✔
949
    pStream = NULL;
8,699✔
950

951
    mstsDebug("drop stream %s added to transaction", streamName);
8,699✔
952
  }
953

954
  // Prepare and execute the transaction for all streams
955
  if (notExistNum < dropReq.count) {
8,181✔
956
    code = mndTransPrepare(pMnode, pTrans);
7,922✔
957
    if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
7,922✔
958
      mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, tstrerror(code));
×
959
      mndTransDrop(pTrans);
×
960
      goto _OVER;
×
961
    }
962
    mInfo("trans:%d, drop stream transaction prepared for %d streams", pTrans->id, dropReq.count - notExistNum);
7,922✔
963
  } else {
964
    // All streams don't exist, no need to prepare transaction
965
    mndTransDrop(pTrans);
259✔
966
    pTrans = NULL;
259✔
967
  }
968

969
  if (tsAuditLevel >= AUDIT_LEVEL_DATABASE && notExistNum < dropReq.count) {
8,181✔
970
    int64_t tse = taosGetTimestampMs();
7,922✔
971
    double  duration = (double)(tse - tss);
7,922✔
972
    duration = duration / 1000;
7,922✔
973
    // Use first stream's database for audit (assuming all streams are from same db in batch)
974
    if (dropReq.count > 0) {
7,922✔
975
      SStreamObj *pFirstStream = NULL;
7,922✔
976
      if (mndAcquireStream(pMnode, dropReq.name[0], &pFirstStream) == 0 && pFirstStream != NULL) {
7,922✔
977
        auditRecord(pReq, pMnode->clusterId, "dropStream", "", pFirstStream->pCreate->streamDB, NULL, 0, duration, 0);
×
978
        sdbRelease(pMnode->pSdb, pFirstStream);
×
979
      }
980
    }
981
  }
982

983
  // If any stream was successfully added to transaction, return ACTION_IN_PROGRESS
984
  // Otherwise, all streams don't exist (and igNotExists is set), return SUCCESS
985
  code = (notExistNum < dropReq.count) ? TSDB_CODE_ACTION_IN_PROGRESS : TSDB_CODE_SUCCESS;
8,181✔
986

987
_OVER:
8,181✔
988
  if (pStream) {
8,181✔
989
    sdbRelease(pMnode->pSdb, pStream);
×
990
  }
991
  if (pTrans) {
8,181✔
992
    mndTransDrop(pTrans);
7,922✔
993
  }
994
  mndReleaseUser(pMnode, pOperUser);
8,181✔
995
  tFreeMDropStreamReq(&dropReq);
8,181✔
996
  TAOS_RETURN(code);
8,181✔
997
}
998

999
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
184,267✔
1000
  SMnode     *pMnode = pReq->info.node;
184,267✔
1001
  SStreamObj *pStream = NULL;
184,267✔
1002
  SStreamObj  streamObj = {0};
184,267✔
1003
  SUserObj    *pOperUser = NULL;
184,267✔
1004
  int32_t     code = TSDB_CODE_SUCCESS;
184,267✔
1005
  int32_t     lino = 0;
184,267✔
1006
  STrans     *pTrans = NULL;
184,267✔
1007
  uint64_t    streamId = 0;
184,267✔
1008
  SCMCreateStreamReq* pCreate = NULL;
184,267✔
1009
  int64_t             tss = taosGetTimestampMs();
184,267✔
1010

1011
  if ((code = grantCheck(TSDB_GRANT_STREAMS)) < 0) {
184,267✔
1012
    goto _OVER;
×
1013
  }
1014
  
1015
#ifdef WINDOWS
1016
  code = TSDB_CODE_MND_INVALID_PLATFORM;
1017
  goto _OVER;
1018
#endif
1019

1020
  pCreate = taosMemoryCalloc(1, sizeof(SCMCreateStreamReq));
184,267✔
1021
  TSDB_CHECK_NULL(pCreate, code, lino, _OVER, terrno);
184,267✔
1022
  
1023
  code = tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, pCreate);
184,267✔
1024
  TSDB_CHECK_CODE(code, lino, _OVER);
184,267✔
1025

1026
  streamId = pCreate->streamId;
184,267✔
1027

1028
  mstsInfo("start to create stream %s, sql:%s", pCreate->name, pCreate->sql);
184,267✔
1029

1030
  int32_t snodeId = msmAssignRandomSnodeId(pMnode, streamId);
184,267✔
1031
  if (!GOT_SNODE(snodeId)) {
184,267✔
1032
    code = terrno;
2,610✔
1033
    TSDB_CHECK_CODE(code, lino, _OVER);
2,610✔
1034
  }
1035
  
1036
  code = mndAcquireStream(pMnode, pCreate->name, &pStream);
181,657✔
1037
  if (pStream != NULL && code == 0) {
181,657✔
1038
    if (pCreate->igExists) {
5,180✔
1039
      mstsInfo("stream %s already exist, ignore exist is set", pCreate->name);
×
1040
    } else {
1041
      code = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
5,180✔
1042
    }
1043

1044
    mndReleaseStream(pMnode, pStream);
5,180✔
1045
    goto _OVER;
5,180✔
1046
  } else if (code != TSDB_CODE_MND_STREAM_NOT_EXIST) {
176,477✔
1047
    goto _OVER;
×
1048
  }
1049

1050
  code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser);
176,477✔
1051
  if (pOperUser == NULL) {
176,477✔
1052
    TSDB_CHECK_CODE(TSDB_CODE_MND_NO_USER_FROM_CONN, lino, _OVER);
×
1053
  }
1054

1055
  code = mndStreamValidateCreate(pMnode, pReq, pCreate);
176,477✔
1056
  TSDB_CHECK_CODE(code, lino, _OVER);
176,477✔
1057

1058
  mndStreamBuildObj(pMnode, &streamObj, pCreate, pOperUser, snodeId);
176,477✔
1059
  pCreate = NULL;
176,477✔
1060

1061
  pStream = &streamObj;
176,477✔
1062

1063
  code = mndStreamCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_DB, MND_STREAM_CREATE_NAME, &pTrans);
176,477✔
1064
  if (pTrans == NULL || code) {
176,477✔
1065
    goto _OVER;
×
1066
  }
1067

1068
  // create stb for stream
1069
  if (TSDB_SUPER_TABLE == pStream->pCreate->outTblType && !pStream->pCreate->outStbExists) {
176,477✔
1070
    pStream->pCreate->outStbUid = mndGenerateUid(pStream->pCreate->outTblName, strlen(pStream->pCreate->outTblName));
64,550✔
1071
    code = mndStreamCreateOutStb(pMnode, pTrans, pStream->pCreate, RPC_MSG_USER(pReq));
64,550✔
1072
    TSDB_CHECK_CODE(code, lino, _OVER);
64,550✔
1073
  }
1074

1075
  // add stream to trans
1076
  code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_READY);
176,477✔
1077
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
176,477✔
1078
    mstsError("failed to persist stream %s since %s", pStream->pCreate->name, tstrerror(code));
×
1079
    goto _OVER;
×
1080
  }
1081

1082
  // execute creation
1083
  code = mndTransPrepare(pMnode, pTrans);
176,477✔
1084
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
176,477✔
1085
    mstsError("trans:%d, failed to prepare since %s", pTrans->id, tstrerror(code));
×
1086
    goto _OVER;
×
1087
  }
1088
  code = TSDB_CODE_ACTION_IN_PROGRESS;
176,477✔
1089

1090
  if (tsAuditLevel >= AUDIT_LEVEL_DATABASE) {
176,477✔
1091
    int64_t tse = taosGetTimestampMs();
176,477✔
1092
    double  duration = (double)(tse - tss);
176,477✔
1093
    duration = duration / 1000;
176,477✔
1094
    auditRecord(pReq, pMnode->clusterId, "createStream", pStream->pCreate->streamDB, pStream->pCreate->name,
176,477✔
1095
                pStream->pCreate->sql, strlen(pStream->pCreate->sql), duration, 0);
176,477✔
1096
  }
1097

1098
  MND_STREAM_SET_LAST_TS(STM_EVENT_CREATE_STREAM, taosGetTimestampMs());
325,894✔
1099

1100
  mstPostStreamAction(mStreamMgmt.actionQ, streamId, pStream->pCreate->name, NULL, true, STREAM_ACT_DEPLOY);
176,477✔
1101

1102
_OVER:
184,267✔
1103

1104
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
184,267✔
1105
    if (pStream && pStream->pCreate) {
7,790✔
1106
      mstsError("failed to create stream %s at line:%d since %s", pStream->pCreate->name, lino, tstrerror(code));
5,180✔
1107
    } else {
1108
      mstsError("failed to create stream at line:%d since %s", lino, tstrerror(code));
2,610✔
1109
    }
1110
  } else {
1111
    mstsDebug("create stream %s half completed", pStream->pCreate ? pStream->pCreate->name : "unknown");
176,477✔
1112
  }
1113

1114
  tFreeSCMCreateStreamReq(pCreate);
184,267✔
1115
  taosMemoryFreeClear(pCreate);
184,267✔
1116

1117
  mndTransDrop(pTrans);
184,267✔
1118
  tFreeStreamObj(&streamObj);
184,267✔
1119
  mndReleaseUser(pMnode, pOperUser);
184,267✔
1120

1121
  return code;
184,267✔
1122
}
1123

1124
static int32_t mndProcessRecalcStreamReq(SRpcMsg *pReq) {
3,713✔
1125
  SMnode     *pMnode = pReq->info.node;
3,713✔
1126
  SStreamObj *pStream = NULL;
3,713✔
1127
  SUserObj   *pOperUser = NULL;
3,713✔
1128
  int32_t     code = 0;
3,713✔
1129
  int64_t     tss = taosGetTimestampMs();
3,713✔
1130

1131
  if ((code = grantCheckExpire(TSDB_GRANT_STREAMS)) < 0) {
3,713✔
1132
    return code;
×
1133
  }
1134

1135
  SMRecalcStreamReq recalcReq = {0};
3,713✔
1136
  if (tDeserializeSMRecalcStreamReq(pReq->pCont, pReq->contLen, &recalcReq) < 0) {
3,713✔
1137
    tFreeMRecalcStreamReq(&recalcReq);
×
1138
    TAOS_RETURN(TSDB_CODE_INVALID_MSG);
×
1139
  }
1140

1141
  code = mndAcquireStream(pMnode, recalcReq.name, &pStream);
3,713✔
1142
  if (pStream == NULL || code != 0) {
3,713✔
1143
    mError("stream:%s not exist, failed to recalc stream", recalcReq.name);
×
1144
    tFreeMRecalcStreamReq(&recalcReq);
×
1145
    TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
×
1146
  }
1147

1148
  int64_t streamId = pStream->pCreate->streamId;
3,713✔
1149
  
1150
  mstsInfo("start to recalc stream %s", recalcReq.name);
3,713✔
1151

1152
  // code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), MND_OPER_WRITE_DB, pStream->pCreate->streamDB);
1153
  // if (code != TSDB_CODE_SUCCESS) {
1154
  //   mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), recalcReq.name, tstrerror(code));
1155
  //   sdbRelease(pMnode->pSdb, pStream);
1156
  //   tFreeMRecalcStreamReq(&recalcReq);
1157
  //   return code;
1158
  // }
1159

1160
  if ((code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pOperUser))) {
3,713✔
1161
    mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
1162
    sdbRelease(pMnode->pSdb, pStream);
×
1163
    tFreeMRecalcStreamReq(&recalcReq);
×
1164
    TAOS_RETURN(code);
×
1165
  }
1166

1167
  if ((code = mndCheckDbPrivilegeByName(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_USE_DB,
3,713✔
1168
                                        pStream->pCreate->streamDB, false))) {
3,713✔
1169
    if (code == TSDB_CODE_MND_NO_RIGHTS) code = TSDB_CODE_PAR_DB_USE_PERMISSION_DENIED;
×
1170
  }
1171
  if ((code != TSDB_CODE_SUCCESS) ||
7,426✔
1172
      (code = mndCheckObjPrivilegeRecF(pMnode, pOperUser, PRIV_CM_RECALC, PRIV_OBJ_STREAM, pStream->ownerId,
3,713✔
1173
                                       pStream->pCreate->streamDB, mndGetStableStr(pStream->pCreate->name)))) {
3,713✔
1174
    mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), pStream->name, tstrerror(code));
×
1175
    mndReleaseUser(pMnode, pOperUser);
×
1176
    sdbRelease(pMnode->pSdb, pStream);
×
1177
    tFreeMRecalcStreamReq(&recalcReq);
×
1178
    return code;
×
1179
  }
1180

1181
  mndReleaseUser(pMnode, pOperUser); // release user after privilege check
3,713✔
1182

1183
  if (atomic_load_8(&pStream->userDropped)) {
3,713✔
1184
    code = TSDB_CODE_MND_STREAM_DROPPING;
×
1185
    mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), recalcReq.name, tstrerror(code));
×
1186
    sdbRelease(pMnode->pSdb, pStream);
×
1187
    tFreeMRecalcStreamReq(&recalcReq);
×
1188
    return code;
×
1189
  }
1190

1191
  if (atomic_load_8(&pStream->userStopped)) {
3,713✔
1192
    code = TSDB_CODE_MND_STREAM_STOPPED;
×
1193
    mstsError("user %s failed to recalc stream %s since %s", RPC_MSG_USER(pReq), recalcReq.name, tstrerror(code));
×
1194
    sdbRelease(pMnode->pSdb, pStream);
×
1195
    tFreeMRecalcStreamReq(&recalcReq);
×
1196
    return code;
×
1197
  }
1198

1199
  if (WINDOW_TYPE_PERIOD == pStream->pCreate->triggerType) {
3,713✔
1200
    code = TSDB_CODE_OPS_NOT_SUPPORT;
209✔
1201
    mstsError("failed to recalc stream %s since %s", recalcReq.name, tstrerror(code));
209✔
1202
    sdbRelease(pMnode->pSdb, pStream);
209✔
1203
    tFreeMRecalcStreamReq(&recalcReq);
209✔
1204
    return code;
209✔
1205
  }
1206

1207
  /*
1208
  pStream->updateTime = taosGetTimestampMs();
1209

1210
  STrans *pTrans = NULL;
1211
  code = mndStreamCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_RECALC_NAME, &pTrans);
1212
  if (pTrans == NULL || code) {
1213
    mstsError("failed to recalc stream %s since %s", recalcReq.name, tstrerror(code));
1214
    sdbRelease(pMnode->pSdb, pStream);
1215
    return code;
1216
  }
1217

1218
  // stop stream
1219
  code = mndStreamTransAppend(pStream, pTrans, SDB_STATUS_READY);
1220
  if (code != TSDB_CODE_SUCCESS) {
1221
    sdbRelease(pMnode->pSdb, pStream);
1222
    mndTransDrop(pTrans);
1223
    return code;
1224
  }
1225

1226
  code = mndTransPrepare(pMnode, pTrans);
1227
  if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
1228
    mError("trans:%d, failed to prepare stop stream trans since %s", pTrans->id, tstrerror(code));
1229
    sdbRelease(pMnode->pSdb, pStream);
1230
    mndTransDrop(pTrans);
1231
    return code;
1232
  }
1233
*/
1234

1235
  code = msmRecalcStream(pMnode, pStream->pCreate->streamId, &recalcReq.timeRange);
3,504✔
1236
  if (code != TSDB_CODE_SUCCESS) {
3,504✔
1237
    sdbRelease(pMnode->pSdb, pStream);
×
1238
    tFreeMRecalcStreamReq(&recalcReq);
×
1239
    return code;
×
1240
  }
1241

1242
  if (tsAuditLevel >= AUDIT_LEVEL_DATABASE){
3,504✔
1243
    char buf[128];
3,504✔
1244
    snprintf(buf, sizeof(buf), "start:%" PRId64 ", end:%" PRId64, recalcReq.timeRange.skey, recalcReq.timeRange.ekey);
3,504✔
1245
    int64_t tse = taosGetTimestampMs();
3,504✔
1246
    double  duration = (double)(tse - tss);
3,504✔
1247
    duration = duration / 1000;
3,504✔
1248
    auditRecord(pReq, pMnode->clusterId, "recalcStream", pStream->name, recalcReq.name, buf, strlen(buf), duration, 0);
3,504✔
1249
  }  
1250

1251
  sdbRelease(pMnode->pSdb, pStream);
3,504✔
1252
  tFreeMRecalcStreamReq(&recalcReq);
3,504✔
1253
//  mndTransDrop(pTrans);
1254

1255
  return TSDB_CODE_SUCCESS;
3,504✔
1256
}
1257

1258

1259
int32_t mndInitStream(SMnode *pMnode) {
427,526✔
1260
  SSdbTable table = {
427,526✔
1261
      .sdbType = SDB_STREAM,
1262
      .keyType = SDB_KEY_BINARY,
1263
      .encodeFp = (SdbEncodeFp)mndStreamActionEncode,
1264
      .decodeFp = (SdbDecodeFp)mndStreamActionDecode,
1265
      .insertFp = (SdbInsertFp)mndStreamActionInsert,
1266
      .updateFp = (SdbUpdateFp)mndStreamActionUpdate,
1267
      .deleteFp = (SdbDeleteFp)mndStreamActionDelete,
1268
  };
1269

1270
  if (!tsDisableStream) {
427,526✔
1271
    mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq);
427,526✔
1272
    mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);
427,526✔
1273
    mndSetMsgHandle(pMnode, TDMT_MND_START_STREAM, mndProcessStartStreamReq);
427,526✔
1274
    mndSetMsgHandle(pMnode, TDMT_MND_STOP_STREAM, mndProcessStopStreamReq);
427,526✔
1275
    mndSetMsgHandle(pMnode, TDMT_MND_STREAM_HEARTBEAT, mndProcessStreamHb);  
427,526✔
1276
    mndSetMsgHandle(pMnode, TDMT_MND_RECALC_STREAM, mndProcessRecalcStreamReq);
427,526✔
1277
  }
1278
  
1279
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream);
427,526✔
1280
  mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream);
427,526✔
1281
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndRetrieveStreamTask);
427,526✔
1282
  mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndCancelGetNextStreamTask);
427,526✔
1283
  mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAM_RECALCULATES, mndRetrieveStreamRecalculates);
427,526✔
1284
  mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAM_RECALCULATES, mndCancelGetNextStreamRecalculates);
427,526✔
1285

1286
  int32_t code = sdbSetTable(pMnode->pSdb, table);
427,526✔
1287
  if (code) {
427,526✔
1288
    return code;
×
1289
  }
1290

1291
  //code = sdbSetTable(pMnode->pSdb, tableSeq);
1292
  return code;
427,526✔
1293
}
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