[td-3350]<fix>: Remove the illegal abort operation in case of multithread environment for sim.
This commit is contained in:
parent
ecfe8ecabb
commit
fee4bde52a
|
@ -149,6 +149,7 @@ extern int32_t simScriptSucced;
|
||||||
extern int32_t simDebugFlag;
|
extern int32_t simDebugFlag;
|
||||||
extern char tsScriptDir[];
|
extern char tsScriptDir[];
|
||||||
extern bool simAsyncQuery;
|
extern bool simAsyncQuery;
|
||||||
|
extern bool abortExecution;
|
||||||
|
|
||||||
SScript *simParseScript(char *fileName);
|
SScript *simParseScript(char *fileName);
|
||||||
SScript *simProcessCallOver(SScript *script);
|
SScript *simProcessCallOver(SScript *script);
|
||||||
|
|
|
@ -645,8 +645,12 @@ bool simCreateRestFulConnect(SScript *script, char *user, char *pass) {
|
||||||
bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
|
bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
|
||||||
simCloseTaosdConnect(script);
|
simCloseTaosdConnect(script);
|
||||||
void *taos = NULL;
|
void *taos = NULL;
|
||||||
taosMsleep(2000);
|
|
||||||
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
||||||
|
if (abortExecution) {
|
||||||
|
script->killed = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
taos = taos_connect(NULL, user, pass, NULL, tsDnodeShellPort);
|
taos = taos_connect(NULL, user, pass, NULL, tsDnodeShellPort);
|
||||||
if (taos == NULL) {
|
if (taos == NULL) {
|
||||||
simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL),
|
simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL),
|
||||||
|
@ -697,6 +701,11 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
||||||
TAOS_RES *pSql = NULL;
|
TAOS_RES *pSql = NULL;
|
||||||
|
|
||||||
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
||||||
|
if (abortExecution) {
|
||||||
|
script->killed = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
simLogSql(rest, false);
|
simLogSql(rest, false);
|
||||||
pSql = taos_query(script->taos, rest);
|
pSql = taos_query(script->taos, rest);
|
||||||
ret = taos_errno(pSql);
|
ret = taos_errno(pSql);
|
||||||
|
|
|
@ -21,10 +21,13 @@
|
||||||
|
|
||||||
bool simAsyncQuery = false;
|
bool simAsyncQuery = false;
|
||||||
bool simExecSuccess = false;
|
bool simExecSuccess = false;
|
||||||
|
bool abortExecution = false;
|
||||||
|
|
||||||
void simHandleSignal(int32_t signo, void *sigInfo, void *context) {
|
void simHandleSignal(int32_t signo, void *sigInfo, void *context) {
|
||||||
simSystemCleanUp();
|
simSystemCleanUp();
|
||||||
exit(1);
|
abortExecution = true;
|
||||||
|
// runningScript->killed = true;
|
||||||
|
// exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t main(int32_t argc, char *argv[]) {
|
int32_t main(int32_t argc, char *argv[]) {
|
||||||
|
@ -60,6 +63,11 @@ int32_t main(int32_t argc, char *argv[]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (abortExecution) {
|
||||||
|
simError("execute abort");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
simScriptList[++simScriptPos] = script;
|
simScriptList[++simScriptPos] = script;
|
||||||
simExecuteScript(script);
|
simExecuteScript(script);
|
||||||
|
|
||||||
|
|
|
@ -159,9 +159,17 @@ void *simExecuteScript(void *inputScript) {
|
||||||
script = simScriptList[simScriptPos];
|
script = simScriptList[simScriptPos];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (abortExecution) {
|
||||||
|
script->killed = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (script->killed || script->linePos >= script->numOfLines) {
|
if (script->killed || script->linePos >= script->numOfLines) {
|
||||||
|
printf("killed ---------------------->\n");
|
||||||
script = simProcessCallOver(script);
|
script = simProcessCallOver(script);
|
||||||
if (script == NULL) break;
|
if (script == NULL) {
|
||||||
|
printf("abort now!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SCmdLine *line = &script->lines[script->linePos];
|
SCmdLine *line = &script->lines[script->linePos];
|
||||||
char * option = script->optionBuffer + line->optionOffset;
|
char * option = script->optionBuffer + line->optionOffset;
|
||||||
|
|
Loading…
Reference in New Issue