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

taosdata / TDengine / #3653

14 Mar 2025 08:10AM UTC coverage: 22.565% (-41.0%) from 63.596%
#3653

push

travis-ci

web-flow
feat(keep): support keep on super table level. (#30097)

* Feat: support use keep while create super table.

* Test(keep): add test for create super table with keep option.

* Feat(keep): Add tmsg for create keep.

* Feat(keep): support alter table option keep.

* Fix(keep): Add baisc test for alter table option.

* Fix(keep): memory leek.

* Feat(keep): add keep to metaEntry&metaCache and fix earliestTs with stn keep.

* Test(keep): add some cases for select with stb keep.

* Fix: fix ci core while alter stb.

* Feat(keep): delete expired data in super table level.

* Feat: remove get stb keep while query.

* Fix : build error.

* Revert "Fix : build error."

This reverts commit 0ed66e4e8.

* Revert "Feat(keep): delete expired data in super table level."

This reverts commit 36330f6b4.

* Fix : build errors.

* Feat : support restart taosd.

* Fix : alter table comment problems.

* Test : add tests for super table keep.

* Fix: change sdb stb reserve size.

* Test: add more tests.

* Feat: Disable normal tables and sub tables from setting the keep parameter

* Fix: add more checks to avoid unknown address.

* Docs: Add docs for stable keep.

* Fix: some review changes.

* Fix: review errors.

49248 of 302527 branches covered (16.28%)

Branch coverage included in aggregate %.

53 of 99 new or added lines in 12 files covered. (53.54%)

155872 existing lines in 443 files now uncovered.

87359 of 302857 relevant lines covered (28.84%)

570004.22 hits per line

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

7.19
/utils/tsim/src/simSystem.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 "simInt.h"
18
#include "tconfig.h"
19

20
SScript *simScriptList[MAX_MAIN_SCRIPT_NUM];
21
SCommand simCmdList[SIM_CMD_END];
22
int32_t  simScriptPos = -1;
23
int32_t  simScriptSucceed = 0;
24
void     simCloseTaosdConnect(SScript *script);
25
char     simScriptDir[PATH_MAX] = {0};
26

27
extern bool simExecSuccess;
28

29
int32_t simInitCfg() {
3✔
30
  taosCreateLog("simlog", 1, configDir, NULL, NULL, NULL, NULL, 1);
3✔
31
  taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1);
3✔
32

33
  SConfig *pCfg = taosGetCfg();
3✔
34
  tstrncpy(simScriptDir, cfgGetItem(pCfg, "scriptDir")->str, PATH_MAX);
3✔
35
  return 0;
3✔
36
}
37

38
void simSystemInit() {
3✔
39
  simInitCfg();
3✔
40
  simInitsimCmdList();
3✔
41
  memset(simScriptList, 0, sizeof(SScript *) * MAX_MAIN_SCRIPT_NUM);
3✔
42
}
3✔
43

44
void simSystemCleanUp() {}
1✔
45

UNCOV
46
void simFreeScript(SScript *script) {
×
UNCOV
47
  if (script->type == SIM_SCRIPT_TYPE_MAIN) {
×
UNCOV
48
    simInfo("script:%s, background script num:%d, stop them", script->fileName, script->bgScriptLen);
×
49

UNCOV
50
    for (int32_t i = 0; i < script->bgScriptLen; ++i) {
×
UNCOV
51
      SScript *bgScript = script->bgScripts[i];
×
UNCOV
52
      simDebug("script:%s, is background script, set stop flag", bgScript->fileName);
×
UNCOV
53
      bgScript->killed = true;
×
UNCOV
54
      if (taosCheckPthreadValid(bgScript->bgPid)) {
×
UNCOV
55
        taosThreadJoin(bgScript->bgPid, NULL);
×
UNCOV
56
        taosThreadClear(&bgScript->bgPid);
×
57
      }
58

UNCOV
59
      simDebug("script:%s, background thread joined", bgScript->fileName);
×
UNCOV
60
      taos_close(bgScript->taos);
×
UNCOV
61
      taosMemoryFreeClear(bgScript->lines);
×
UNCOV
62
      taosMemoryFreeClear(bgScript->optionBuffer);
×
UNCOV
63
      taosMemoryFreeClear(bgScript);
×
64
    }
65

UNCOV
66
    simDebug("script:%s, is cleaned", script->fileName);
×
UNCOV
67
    taos_close(script->taos);
×
UNCOV
68
    taosMemoryFreeClear(script->lines);
×
UNCOV
69
    taosMemoryFreeClear(script->optionBuffer);
×
UNCOV
70
    taosMemoryFreeClear(script);
×
71
  }
UNCOV
72
}
×
73

UNCOV
74
SScript *simProcessCallOver(SScript *script) {
×
UNCOV
75
  if (script->type == SIM_SCRIPT_TYPE_MAIN) {
×
UNCOV
76
    simDebug("script:%s, is main script, set stop flag", script->fileName);
×
UNCOV
77
    if (script->killed) {
×
78
      simExecSuccess = false;
×
79
      simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX "failed" FAILED_POSTFIX ", error:%s",
×
80
              script->fileName, script->error);
81
    } else {
UNCOV
82
      simExecSuccess = true;
×
UNCOV
83
      simInfo("script:" SUCCESS_PREFIX "%s" SUCCESS_POSTFIX ", " SUCCESS_PREFIX "success" SUCCESS_POSTFIX,
×
84
              script->fileName);
85
    }
86

UNCOV
87
    simCloseTaosdConnect(script);
×
UNCOV
88
    simScriptSucceed++;
×
UNCOV
89
    simScriptPos--;
×
UNCOV
90
    simFreeScript(script);
×
91

UNCOV
92
    if (simScriptPos == -1 && simExecSuccess) {
×
UNCOV
93
      simInfo("----------------------------------------------------------------------");
×
UNCOV
94
      simInfo("Simulation Test Done, " SUCCESS_PREFIX "%d" SUCCESS_POSTFIX " Passed:\n", simScriptSucceed);
×
UNCOV
95
      return NULL;
×
96
    }
97

UNCOV
98
    if (simScriptPos == -1) return NULL;
×
UNCOV
99
    if (!simExecSuccess) return NULL;
×
100

UNCOV
101
    return simScriptList[simScriptPos];
×
102
  } else {
UNCOV
103
    simDebug("script:%s,  is stopped", script->fileName);
×
UNCOV
104
    simFreeScript(script);
×
UNCOV
105
    return NULL;
×
106
  }
107
}
108

UNCOV
109
void *simExecuteScript(void *inputScript) {
×
UNCOV
110
  SScript *script = (SScript *)inputScript;
×
111

112
  while (1) {
UNCOV
113
    if (script->type == SIM_SCRIPT_TYPE_MAIN) {
×
UNCOV
114
      script = simScriptList[simScriptPos];
×
115
    }
116

UNCOV
117
    if (abortExecution) {
×
118
      script->killed = true;
×
119
    }
120

UNCOV
121
    if (script->killed || script->linePos >= script->numOfLines) {
×
UNCOV
122
      script = simProcessCallOver(script);
×
UNCOV
123
      if (script == NULL) {
×
UNCOV
124
        simDebug("sim test abort now!");
×
UNCOV
125
        break;
×
126
      }
127
    } else {
UNCOV
128
      SCmdLine *line = &script->lines[script->linePos];
×
UNCOV
129
      char     *option = script->optionBuffer + line->optionOffset;
×
UNCOV
130
      simDebug("script:%s, line:%d with option \"%s\"", script->fileName, line->lineNum, option);
×
131

UNCOV
132
      SCommand *cmd = &simCmdList[line->cmdno];
×
UNCOV
133
      int32_t   ret = (*(cmd->executeCmd))(script, option);
×
UNCOV
134
      if (!ret) {
×
135
        script->killed = true;
×
136
      }
137
    }
138
  }
139

UNCOV
140
  simInfo("thread is stopped");
×
UNCOV
141
  return NULL;
×
142
}
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