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

taosdata / TDengine / #5071

17 May 2026 01:15AM UTC coverage: 63.054% (-10.3%) from 73.326%
#5071

push

travis-ci

web-flow
feat (TDgpt): Dynamic Model Synchronization Enhancements (#35344)

* refactor: do some internal refactor.

* fix: fix multiprocess sync issue.

* feat: add dynamic anomaly detection and forecasting services

* fix: log error message for undeploying model in exception handling

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix: handle undeploy when model exists only on disk

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/286aafa0-c3ce-4c27-b803-2707571e9dc1

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: guard dynamic registry concurrent access

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/5e4db858-6458-40f4-ac28-d1b1b7f97c18

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: tighten service list locking scope

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/5e4db858-6458-40f4-ac28-d1b1b7f97c18

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: restore prophet support and update tests per review feedback

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/92298ae1-7da6-4d07-b20e-101c7cd0b26b

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: improve test name and move copy inside lock scope

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/92298ae1-7da6-4d07-b20e-101c7cd0b26b

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* Potential fix for pull request finding

Co-au... (continued)

238317 of 377957 relevant lines covered (63.05%)

130539817.12 hits per line

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

61.7
/source/dnode/mnode/impl/src/mndPerfSchema.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
#define _DEFAULT_SOURCE
17
#include "mndInt.h"
18
#include "systable.h"
19

20
// connection/application/
21
int32_t mndInitPerfsTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
2,428,524✔
22
  int32_t  code = 0;
2,428,524✔
23
  SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
2,428,524✔
24
  if (NULL == schema) {
2,428,524✔
25
    code = terrno;
×
26
    TAOS_RETURN(code);
×
27
  }
28

29
  for (int32_t i = 0; i < colNum; ++i) {
32,380,320✔
30
    tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name));
29,951,796✔
31

32
    schema[i].type = pSrc[i].type;
29,951,796✔
33
    schema[i].colId = i + 1;
29,951,796✔
34
    schema[i].bytes = pSrc[i].bytes;
29,951,796✔
35
  }
36

37
  *pDst = schema;
2,428,524✔
38
  TAOS_RETURN(code);
2,428,524✔
39
}
40

41
int32_t mndPerfsInitMeta(SHashObj *hash) {
404,754✔
42
  int32_t       code = 0;
404,754✔
43
  STableMetaRsp meta = {0};
404,754✔
44

45
  tstrncpy(meta.dbFName, TSDB_PERFORMANCE_SCHEMA_DB, sizeof(meta.dbFName));
404,754✔
46
  meta.tableType = TSDB_SYSTEM_TABLE;
404,754✔
47
  meta.sversion = 1;
404,754✔
48
  meta.tversion = 1;
404,754✔
49
  meta.rversion = 1;
404,754✔
50
  meta.virtualStb = false;
404,754✔
51

52
  size_t               size = 0;
404,754✔
53
  const SSysTableMeta *pSysDbTableMeta = NULL;
404,754✔
54
  getPerfDbMeta(&pSysDbTableMeta, &size);
404,754✔
55

56
  for (int32_t i = 0; i < size; ++i) {
2,833,278✔
57
    tstrncpy(meta.tbName, pSysDbTableMeta[i].name, sizeof(meta.tbName));
2,428,524✔
58
    meta.numOfColumns = pSysDbTableMeta[i].colNum;
2,428,524✔
59
    meta.sysInfo = pSysDbTableMeta[i].sysInfo;
2,428,524✔
60
    meta.privCat = pSysDbTableMeta[i].privCat;
2,428,524✔
61

62
    TAOS_CHECK_RETURN(mndInitPerfsTableSchema(pSysDbTableMeta[i].schema, pSysDbTableMeta[i].colNum, &meta.pSchemas));
2,428,524✔
63

64
    if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) {
2,428,524✔
65
      code = terrno;
×
66
      TAOS_RETURN(code);
×
67
    }
68
  }
69

70
  TAOS_RETURN(code);
404,754✔
71
}
72

73
int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
118,460✔
74
  int32_t code = 0;
118,460✔
75
  if (NULL == pMnode->perfsMeta) {
118,460✔
76
    code = TSDB_CODE_APP_ERROR;
×
77
    TAOS_RETURN(code);
×
78
  }
79

80
  STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName));
118,460✔
81
  if (NULL == meta) {
118,460✔
82
    mError("invalid performance schema table name:%s", tbName);
96,976✔
83
    code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
96,976✔
84
    TAOS_RETURN(code);
96,976✔
85
  }
86

87
  *pRsp = *meta;
21,484✔
88

89
  pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema));
21,484✔
90
  if (pRsp->pSchemas == NULL) {
21,484✔
91
    code = terrno;
×
92
    pRsp->pSchemas = NULL;
×
93
    TAOS_RETURN(code);
×
94
  }
95

96
  memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema));
21,484✔
97
  TAOS_RETURN(code);
21,484✔
98
}
99

100
int32_t mndBuildPerfsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) {
×
101
  int32_t code = 0;
×
102
  if (NULL == pMnode->perfsMeta) {
×
103
    code = TSDB_CODE_APP_ERROR;
×
104
    TAOS_RETURN(code);
×
105
  }
106

107
  STableMetaRsp *pMeta = taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName));
×
108
  if (NULL == pMeta) {
×
109
    mError("invalid performance schema table name:%s", tbName);
×
110
    code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
×
111
    TAOS_RETURN(code);
×
112
  }
113

114
  tstrncpy(pRsp->tbName, pMeta->tbName, sizeof(pRsp->tbName));
×
115
  tstrncpy(pRsp->stbName, pMeta->stbName, sizeof(pRsp->stbName));
×
116
  tstrncpy(pRsp->dbFName, pMeta->dbFName, sizeof(pRsp->dbFName));
×
117
  pRsp->numOfTags = pMeta->numOfTags;
×
118
  pRsp->numOfColumns = pMeta->numOfColumns;
×
119
  pRsp->tableType = pMeta->tableType;
×
120
  pRsp->virtualStb = pMeta->virtualStb;
×
121

122
  pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema));
×
123
  if (pRsp->pSchemas == NULL) {
×
124
    code = terrno;
×
125
    pRsp->pSchemas = NULL;
×
126
    TAOS_RETURN(code);
×
127
  }
128

129
  memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema));
×
130
  TAOS_RETURN(code);
×
131
}
132

133
int32_t mndInitPerfs(SMnode *pMnode) {
404,754✔
134
  int32_t code = 0;
404,754✔
135
  pMnode->perfsMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
404,754✔
136
  if (pMnode->perfsMeta == NULL) {
404,754✔
137
    code = terrno;
×
138
    TAOS_RETURN(code);
×
139
  }
140

141
  return mndPerfsInitMeta(pMnode->perfsMeta);
404,754✔
142
}
143

144
void mndCleanupPerfs(SMnode *pMnode) {
404,754✔
145
  if (NULL == pMnode->perfsMeta) {
404,754✔
146
    return;
×
147
  }
148

149
  void *pIter = taosHashIterate(pMnode->perfsMeta, NULL);
404,754✔
150
  while (pIter) {
2,833,278✔
151
    STableMetaRsp *meta = (STableMetaRsp *)pIter;
2,428,524✔
152

153
    taosMemoryFreeClear(meta->pSchemas);
2,428,524✔
154

155
    pIter = taosHashIterate(pMnode->perfsMeta, pIter);
2,428,524✔
156
  }
157

158
  taosHashCleanup(pMnode->perfsMeta);
404,754✔
159
  pMnode->perfsMeta = NULL;
404,754✔
160
}
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