diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 0d33bec38dad0dd1eccc0debf0e67b174e9a1df7..41c94bc4bdef18e74af2a3b66d1c0734164dba16 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -294,11 +294,6 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) { } } } - - if (pRes->code == TSDB_CODE_SUCCESS) { - tscTrace("%p reset retry counter to be 0 due to success rsp, old:%d", pSql, pSql->retry); - pSql->retry = 0; - } pRes->rspLen = 0; @@ -308,6 +303,11 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) { tscTrace("%p query is cancelled, code:%d", pSql, tstrerror(pRes->code)); } + if (pRes->code == TSDB_CODE_SUCCESS) { + tscTrace("%p reset retry counter to be 0 due to success rsp, old:%d", pSql, pSql->retry); + pSql->retry = 0; + } + if (pRes->code != TSDB_CODE_QUERY_CANCELLED) { assert(rpcMsg->msgType == pCmd->msgType + 1); pRes->code = rpcMsg->code; @@ -569,7 +569,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pSql->cmd.msgType = TSDB_MSG_TYPE_SUBMIT; tscSetDnodeIpList(pSql, pTableMeta); - tscTrace("%p build submit msg, vgId:%d numOfVgroup:%d", pSql, vgId, htonl(pMsgDesc->numOfVnodes)); + tscTrace("%p build submit msg, vgId:%d numOfVgroup:%d numberOfIP:%d", pSql, vgId, htonl(pMsgDesc->numOfVnodes), pSql->ipList.numOfIps); return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 9b8303acfbc65c926d881d46c8eb2cf211e63580..9beae5cb118dcdf0575c4dc39ac3aa4b88c919c9 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -939,7 +939,7 @@ char *taos_errstr(TAOS *taos) { void taos_config(int debug, char *log_path) { uDebugFlag = debug; - strcpy(logDir, log_path); + strcpy(tsLogDir, log_path); } char *taos_get_server_info(TAOS *taos) { diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index d938bb0576330bf4e165ca2529f20f4a6ed0a3bb..7b40d69f1be8fcb605052907fae9d6b3c6a97680 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -220,7 +220,7 @@ int tscUpdateSubscription(STscObj* pObj, SSub* pSub) { static int tscLoadSubscriptionProgress(SSub* pSub) { char buf[TSDB_MAX_SQL_LEN]; - sprintf(buf, "%s/subscribe/%s", dataDir, pSub->topic); + sprintf(buf, "%s/subscribe/%s", tsDataDir, pSub->topic); FILE* fp = fopen(buf, "r"); if (fp == NULL) { @@ -281,12 +281,12 @@ void tscSaveSubscriptionProgress(void* sub) { SSub* pSub = (SSub*)sub; char path[256]; - sprintf(path, "%s/subscribe", dataDir); + sprintf(path, "%s/subscribe", tsDataDir); if (access(path, 0) != 0) { mkdir(path, 0777); } - sprintf(path, "%s/subscribe/%s", dataDir, pSub->topic); + sprintf(path, "%s/subscribe/%s", tsDataDir, pSub->topic); FILE* fp = fopen(path, "w+"); if (fp == NULL) { tscError("failed to create progress file for subscription: %s", pSub->topic); @@ -416,7 +416,7 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) { tscSaveSubscriptionProgress(pSub); } else { char path[256]; - sprintf(path, "%s/subscribe/%s", dataDir, pSub->topic); + sprintf(path, "%s/subscribe/%s", tsDataDir, pSub->topic); remove(path); } diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 75ab9fc7208612c0494eeed120fa152a8c459fc9..d253c508e67e3db2eb81c8dc4c2be0225b6f2623 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -121,11 +121,11 @@ void taos_init_imp() { taosReadGlobalLogCfg(); // For log directory - if (stat(logDir, &dirstat) < 0) mkdir(logDir, 0755); + if (stat(tsLogDir, &dirstat) < 0) mkdir(tsLogDir, 0755); - sprintf(temp, "%s/taoslog", logDir); + sprintf(temp, "%s/taoslog", tsLogDir); if (taosInitLog(temp, tsNumOfLogLines, 10) < 0) { - printf("failed to open log file in directory:%s\n", logDir); + printf("failed to open log file in directory:%s\n", tsLogDir); } taosReadGlobalCfg(); diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 69829f2ba4c4d5d76ce56bb4af8fc6b98511a110..dbaaac12fad5623f8875a5bfe45a5605e76bcd14 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -24,10 +24,10 @@ extern char configDir[]; extern char tsVnodeDir[]; extern char tsDnodeDir[]; extern char tsMnodeDir[]; -extern char dataDir[]; -extern char logDir[]; -extern char scriptDir[]; -extern char osName[]; +extern char tsDataDir[]; +extern char tsLogDir[]; +extern char tsScriptDir[]; +extern char tsOsName[]; // system info extern int64_t tsPageSize; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 9124295fa065c11f336ecd2826837565989d9915..7df4bea85514c7081585d98682a916d9a9a3f17e 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -30,9 +30,9 @@ char configDir[TSDB_FILENAME_LEN] = "/etc/taos"; char tsVnodeDir[TSDB_FILENAME_LEN] = {0}; char tsDnodeDir[TSDB_FILENAME_LEN] = {0}; char tsMnodeDir[TSDB_FILENAME_LEN] = {0}; -char dataDir[TSDB_FILENAME_LEN] = "/var/lib/taos"; -char scriptDir[TSDB_FILENAME_LEN] = "/etc/taos"; -char osName[10] = "Linux"; +char tsDataDir[TSDB_FILENAME_LEN] = "/var/lib/taos"; +char tsScriptDir[TSDB_FILENAME_LEN] = "/etc/taos"; +char tsOsName[10] = "Linux"; // system info, not configurable int64_t tsPageSize; @@ -407,7 +407,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); cfg.option = "logDir"; - cfg.ptr = logDir; + cfg.ptr = tsLogDir; cfg.valType = TAOS_CFG_VTYPE_DIRECTORY; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_LOG; cfg.minValue = 0; @@ -417,7 +417,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); cfg.option = "scriptDir"; - cfg.ptr = scriptDir; + cfg.ptr = tsScriptDir; cfg.valType = TAOS_CFG_VTYPE_DIRECTORY; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; cfg.minValue = 0; @@ -427,7 +427,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); cfg.option = "dataDir"; - cfg.ptr = dataDir; + cfg.ptr = tsDataDir; cfg.valType = TAOS_CFG_VTYPE_DIRECTORY; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG; cfg.minValue = 0; diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index b8ac9d1d4a3e473a32a57b81e6d1434d6df7816b..5903020e9394c9c499521e08ef2409f951af763c 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -144,12 +144,12 @@ static int32_t dnodeInitSystem() { signal(SIGPIPE, SIG_IGN); struct stat dirstat; - if (stat(logDir, &dirstat) < 0) { - mkdir(logDir, 0755); + if (stat(tsLogDir, &dirstat) < 0) { + mkdir(tsLogDir, 0755); } char temp[TSDB_FILENAME_LEN]; - sprintf(temp, "%s/taosdlog", logDir); + sprintf(temp, "%s/taosdlog", tsLogDir); if (taosInitLog(temp, tsNumOfLogLines, 1) < 0) { printf("failed to init log file\n"); } @@ -218,13 +218,13 @@ static void dnodeCheckDataDirOpenned(char *dir) { static int32_t dnodeInitStorage() { struct stat dirstat; - if (stat(dataDir, &dirstat) < 0) { - mkdir(dataDir, 0755); + if (stat(tsDataDir, &dirstat) < 0) { + mkdir(tsDataDir, 0755); } - sprintf(tsMnodeDir, "%s/mnode", dataDir); - sprintf(tsVnodeDir, "%s/vnode", dataDir); - sprintf(tsDnodeDir, "%s/dnode", dataDir); + sprintf(tsMnodeDir, "%s/mnode", tsDataDir); + sprintf(tsVnodeDir, "%s/vnode", tsDataDir); + sprintf(tsDnodeDir, "%s/dnode", tsDataDir); mkdir(tsVnodeDir, 0755); mkdir(tsDnodeDir, 0755); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index f0a6b5563840ca9a90d1f4364439450a696556a3..3c00c19834adfc0c14810e3c17241a9bfc167276 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -265,6 +265,7 @@ typedef struct { char tableId[TSDB_TABLE_ID_LEN + 1]; char db[TSDB_DB_NAME_LEN + 1]; int8_t igExists; + int8_t getMeta; int16_t numOfTags; int16_t numOfColumns; int16_t sqlLen; // the length of SQL, it starts after schema , sql is a null-terminated string diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index c85ed47023b293cd66d0ebb72ea18404107d43c1..eeaeec83f2a4d437d310f02a0753ff4dedbd8e4e 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -40,7 +40,7 @@ History history; */ TAOS *shellInit(struct arguments *args) { printf("\n"); - printf(CLIENT_VERSION, osName, taos_get_client_info()); + printf(CLIENT_VERSION, tsOsName, taos_get_client_info()); fflush(stdout); // set options before initializing diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index c7f6ef4a4dd9cd68566a25ae3a09065e2579835c..a78fba22085afc671aab224a7d7e8afaa9b26ecf 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -770,11 +770,17 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { mTrace("db:%s, replications:%d change to %d", pDb->name, pDb->cfg.replications, replications); newCfg.replications = replications; } + if (replications > mgmtGetDnodesNum()) { mError("db:%s, no enough dnode to change replica:%d", pDb->name, replications); terrno = TSDB_CODE_NO_ENOUGH_DNODES; } - + + if (pDb->cfg.replications - replications >= 2) { + mError("db:%s, replica number can't change from 3 to 1", pDb->name, replications); + terrno = TSDB_CODE_INVALID_OPTION; + } + return newCfg; } diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 5d34d3fcf28fb827417df59c1b43da5af9f3b369..efa0b03ded09c95db07f9abeb9113614beb8e90a 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -336,7 +336,7 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) { if (pStatus->dnodeId == 0) { mTrace("dnode:%d, first access, privateIp:%s, name:%s", pDnode->dnodeId, taosIpStr(pDnode->privateIp), pDnode->dnodeName); } else { - //mTrace("dnode:%d, status received, access times %d", pDnode->dnodeId, pDnode->lastAccess); + mTrace("dnode:%d, status received, access times %d", pDnode->dnodeId, pDnode->lastAccess); } int32_t openVnodes = htons(pStatus->openVnodes); diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 57e905361c8345c08520bf1eb21666672091fb34..b5ed0f6f13e1057ce725ee243a9c2bb0edbd92ae 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -74,6 +74,7 @@ static void mgmtProcessTableCfgMsg(SRpcMsg *rpcMsg); static void mgmtProcessTableMetaMsg(SQueuedMsg *queueMsg); static void mgmtGetSuperTableMeta(SQueuedMsg *pMsg); static void mgmtGetChildTableMeta(SQueuedMsg *pMsg); +static void mgmtAutoCreateChildTable(SQueuedMsg *pMsg); static void mgmtProcessAlterTableMsg(SQueuedMsg *queueMsg); static void mgmtProcessAlterTableRsp(SRpcMsg *rpcMsg); @@ -612,9 +613,12 @@ static void mgmtExtractTableName(char* tableId, char* name) { static void mgmtProcessCreateTableMsg(SQueuedMsg *pMsg) { SCMCreateTableMsg *pCreate = pMsg->pCont; - pMsg->pTable = mgmtGetTable(pCreate->tableId); + if (pMsg->pTable == NULL) pMsg->pTable = mgmtGetTable(pCreate->tableId); if (pMsg->pTable != NULL && pMsg->retry == 0) { - if (pCreate->igExists) { + if (pCreate->getMeta) { + mTrace("table:%s, continue to get meta", pCreate->tableId); + mgmtProcessTableMetaMsg(pMsg); + } else if (pCreate->igExists) { mTrace("table:%s, is already exist", pCreate->tableId); mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SUCCESS); } else { @@ -624,7 +628,7 @@ static void mgmtProcessCreateTableMsg(SQueuedMsg *pMsg) { return; } - pMsg->pDb = mgmtGetDb(pCreate->db); + if (pMsg->pDb == NULL) pMsg->pDb = mgmtGetDb(pCreate->db); if (pMsg->pDb == NULL || pMsg->pDb->status != TSDB_DB_STATUS_READY) { mError("table:%s, failed to create, db not selected", pCreate->tableId); mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_DB_NOT_SELECTED); @@ -681,15 +685,21 @@ static void mgmtProcessTableMetaMsg(SQueuedMsg *pMsg) { SCMTableInfoMsg *pInfo = pMsg->pCont; mTrace("table:%s, table meta msg is received from thandle:%p", pInfo->tableId, pMsg->thandle); - pMsg->pDb = mgmtGetDbByTableId(pInfo->tableId); + if (pMsg->pDb == NULL) pMsg->pDb = mgmtGetDbByTableId(pInfo->tableId); if (pMsg->pDb == NULL || pMsg->pDb->status != TSDB_DB_STATUS_READY) { mError("table:%s, failed to get table meta, db not selected", pInfo->tableId); mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_DB_NOT_SELECTED); return; } + if (pMsg->pTable == NULL) pMsg->pTable = mgmtGetTable(pInfo->tableId); if (pMsg->pTable == NULL) { - mgmtGetChildTableMeta(pMsg); + if (htons(pInfo->createFlag) != 1) { + mError("table:%s, failed to get table meta, table not exist", pInfo->tableId); + mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_INVALID_TABLE); + } else { + mgmtAutoCreateChildTable(pMsg); + } } else { if (pMsg->pTable->type != TSDB_SUPER_TABLE) { mgmtGetChildTableMeta(pMsg); @@ -1654,42 +1664,34 @@ static int32_t mgmtDoGetChildTableMeta(SQueuedMsg *pMsg, STableMetaMsg *pMeta) { return TSDB_CODE_SUCCESS; } -void mgmtGetChildTableMeta(SQueuedMsg *pMsg) { - SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable; +static void mgmtAutoCreateChildTable(SQueuedMsg *pMsg) { SCMTableInfoMsg *pInfo = pMsg->pCont; - - if (pTable == NULL) { - if (htons(pInfo->createFlag) != 1) { - mError("table:%s, failed to get table meta, table not exist", pInfo->tableId); - mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_INVALID_TABLE); - return; - } else { - //TODO: on demand create table from super table if table does not exists - int32_t contLen = sizeof(SCMCreateTableMsg) + sizeof(STagData); - SCMCreateTableMsg *pCreateMsg = rpcMallocCont(contLen); - if (pCreateMsg == NULL) { - mError("table:%s, failed to create table while get meta info, no enough memory", pInfo->tableId); - mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); - return; - } - memcpy(pCreateMsg->schema, pInfo->tags, sizeof(STagData)); - strncpy(pCreateMsg->tableId, pInfo->tableId, tListLen(pInfo->tableId)); + int32_t contLen = sizeof(SCMCreateTableMsg) + sizeof(STagData); + SCMCreateTableMsg *pCreateMsg = rpcMallocCont(contLen); + if (pCreateMsg == NULL) { + mError("table:%s, failed to create table while get meta info, no enough memory", pInfo->tableId); + mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); + return; + } - SQueuedMsg *newMsg = malloc(sizeof(SQueuedMsg)); - memcpy(newMsg, pMsg, sizeof(SQueuedMsg)); - pMsg->pCont = NULL; + strncpy(pCreateMsg->tableId, pInfo->tableId, tListLen(pInfo->tableId)); + strcpy(pCreateMsg->db, pMsg->pDb->name); + pCreateMsg->igExists = 1; + pCreateMsg->getMeta = 1; + memcpy(pCreateMsg->schema, pInfo->tags, sizeof(STagData)); - newMsg->ahandle = newMsg->pCont; - newMsg->pCont = pCreateMsg; - mTrace("table:%s, start to create in demand", pInfo->tableId); - mgmtAddToShellQueue(newMsg); - return; - } - } + SQueuedMsg *newMsg = mgmtCloneQueuedMsg(pMsg); + pMsg->pCont = newMsg->pCont; + newMsg->pCont = pCreateMsg; + + mTrace("table:%s, start to create on demand", pInfo->tableId); + mgmtAddToShellQueue(newMsg); +} +static void mgmtGetChildTableMeta(SQueuedMsg *pMsg) { STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * TSDB_MAX_COLUMNS); if (pMeta == NULL) { - mError("table:%s, failed to get table meta, no enough memory", pTable->info.tableId); + mError("table:%s, failed to get table meta, no enough memory", pMsg->pTable->tableId); mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); return; } diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index 45512b86b320c5f6b706dc404f0b22c6315c2aff..8006707ecda49618a21395c4fbea1412980df35f 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -745,16 +745,14 @@ void mgmtDropAllVgroups(SDbObj *pDropDb) { void *pNode = NULL; void *pLastNode = NULL; int32_t numOfVgroups = 0; - int32_t dbNameLen = strlen(pDropDb->name); SVgObj *pVgroup = NULL; mPrint("db:%s, all vgroups will be dropped from sdb", pDropDb->name); - while (1) { pNode = sdbFetchRow(tsVgroupSdb, pNode, (void **)&pVgroup); if (pVgroup == NULL) break; - if (strncmp(pDropDb->name, pVgroup->dbName, dbNameLen) == 0) { + if (pVgroup->pDb == pDropDb) { SSdbOper oper = { .type = SDB_OPER_LOCAL, .table = tsVgroupSdb, @@ -763,9 +761,9 @@ void mgmtDropAllVgroups(SDbObj *pDropDb) { sdbDeleteRow(&oper); pNode = pLastNode; numOfVgroups++; + mgmtSendDropVgroupMsg(pVgroup, NULL); } - mgmtSendDropVgroupMsg(pVgroup, NULL); mgmtDecVgroupRef(pVgroup); } diff --git a/src/os/darwin/src/darwinEnv.c b/src/os/darwin/src/darwinEnv.c index d9152e673d6a24a42ec40655fe824605d0ab1896..27d5a7c99bdddc7e8eeae3bfef0ef9c78b4cbbae 100644 --- a/src/os/darwin/src/darwinEnv.c +++ b/src/os/darwin/src/darwinEnv.c @@ -23,8 +23,8 @@ void osInit() { strcpy(tsVnodeDir, ""); strcpy(tsDnodeDir, ""); strcpy(tsMnodeDir, ""); - strcpy(dataDir, "/var/lib/taos"); - strcpy(logDir, "~/TDengineLog"); - strcpy(scriptDir, "/etc/taos"); - strcpy(osName, "Darwin"); + strcpy(tsDataDir, "/var/lib/taos"); + strcpy(tsLogDir, "~/TDengineLog"); + strcpy(tsScriptDir, "/etc/taos"); + strcpy(tsOsName, "Darwin"); } diff --git a/src/os/linux/src/linuxEnv.c b/src/os/linux/src/linuxEnv.c index bc1a309c9ebd1784a1999e17194d234195bf1b05..0a9d81311a3f86947e75cd9190fbf306dc1871f7 100644 --- a/src/os/linux/src/linuxEnv.c +++ b/src/os/linux/src/linuxEnv.c @@ -23,8 +23,8 @@ void osInit() { strcpy(tsVnodeDir, ""); strcpy(tsDnodeDir, ""); strcpy(tsMnodeDir, ""); - strcpy(dataDir, "/var/lib/taos"); - strcpy(logDir, "/var/log/taos"); - strcpy(scriptDir, "/etc/taos"); - strcpy(osName, "Linux"); + strcpy(tsDataDir, "/var/lib/taos"); + strcpy(tsLogDir, "/var/log/taos"); + strcpy(tsScriptDir, "/etc/taos"); + strcpy(tsOsName, "Linux"); } \ No newline at end of file diff --git a/src/os/linux/src/linuxSysPara.c b/src/os/linux/src/linuxSysPara.c index 54e24c28e59ed75dd5d1a4b34ad86e9eccc240f1..1bd9ce9c3505c5935afacfa137d8c6e2167b46d2 100644 --- a/src/os/linux/src/linuxSysPara.c +++ b/src/os/linux/src/linuxSysPara.c @@ -290,11 +290,12 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) { bool taosGetDisk() { struct statvfs info; const double unit = 1024 * 1024 * 1024; - + if (tscEmbedded) { - if (statvfs(dataDir, &info)) { - tsTotalDataDirGB = 0; - tsAvailDataDirGB = 0; + if (statvfs(tsDataDir, &info)) { + //tsTotalDataDirGB = 0; + //tsAvailDataDirGB = 0; + uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno)); return false; } else { tsTotalDataDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit); @@ -302,9 +303,10 @@ bool taosGetDisk() { } } - if (statvfs(logDir, &info)) { - tsTotalLogDirGB = 0; - tsAvailLogDirGB = 0; + if (statvfs(tsLogDir, &info)) { + //tsTotalLogDirGB = 0; + //tsAvailLogDirGB = 0; + uError("failed to get disk size, logDir:%s errno:%s", tsLogDir, strerror(errno)); return false; } else { tsTotalLogDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit); @@ -312,8 +314,9 @@ bool taosGetDisk() { } if (statvfs("/tmp", &info)) { - tsTotalTmpDirGB = 0; - tsAvailTmpDirGB = 0; + //tsTotalTmpDirGB = 0; + //tsAvailTmpDirGB = 0; + uError("failed to get disk size, tmpDir:/tmp errno:%s", strerror(errno)); return false; } else { tsTotalTmpDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit); diff --git a/src/os/windows/src/twinenv.c b/src/os/windows/src/twinenv.c index 2b18acdaab695ebe339f3da5cabd6145e1cea302..840a8d9f7a80c382e2eda40806093b2ff2d36f2b 100644 --- a/src/os/windows/src/twinenv.c +++ b/src/os/windows/src/twinenv.c @@ -23,8 +23,8 @@ void osInit() { strcpy(tsVnodeDir, "C:/TDengine/data"); strcpy(tsDnodeDir, ""); strcpy(tsMnodeDir, ""); - strcpy(dataDir, "C:/TDengine/data"); - strcpy(logDir, "C:/TDengine/log"); - strcpy(scriptDir, "C:/TDengine/script"); - strcpy(osName, "Windows"); + strcpy(tsDataDir, "C:/TDengine/data"); + strcpy(tsLogDir, "C:/TDengine/log"); + strcpy(tsScriptDir, "C:/TDengine/script"); + strcpy(tsOsName, "Windows"); } \ No newline at end of file diff --git a/src/plugins/http/src/httpSystem.c b/src/plugins/http/src/httpSystem.c index 355fdf2fd003f446b9ae66c1904f9946569d5e4e..07aa880a30d98feeb2671ea16cb75f7752d71092 100644 --- a/src/plugins/http/src/httpSystem.c +++ b/src/plugins/http/src/httpSystem.c @@ -117,7 +117,7 @@ void httpCleanUpSystem() { httpPrint("http service cleanup"); httpStopSystem(); -#if 1 +#if 0 if (httpServer == NULL) { return; } diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 64c051df3f3197f0ec04971a7d26a78e423ab19f..5da8d303d9a155d56519412c38212f4e11b18500 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -915,7 +915,7 @@ _exit: } static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters, SRWHelper *pHelper, SDataCols *pDataCols) { - + char dataDir[128] = {0}; STsdbMeta * pMeta = pRepo->tsdbMeta; STsdbFileH *pFileH = pRepo->tsdbFileH; STsdbCfg * pCfg = &pRepo->config; diff --git a/src/util/src/hash.c b/src/util/src/hash.c index e0e13c1b22f058cddd854d80dbde191ced9900eb..13037e4750430ab871dd9e2091181480b9a0ea96 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -540,7 +540,7 @@ bool taosHashIterNext(SHashMutableIterator *pIter) { } size_t size = taosHashGetSize(pIter->pHashObj); - if (size == 0 || pIter->num >= size) { + if (size == 0) { return false; } diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index 6101d4471bdecfcb2f7e6d83a0ff4f3146d8bd84..dfbdc5e35d7a5f7953d568c3e57a773c316b0159 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -249,7 +249,7 @@ void taosReadGlobalLogCfg() { } wordfree(&full_path); - taosReadLogOption("logDir", logDir); + taosReadLogOption("tsLogDir", tsLogDir); sprintf(fileName, "%s/taos.cfg", configDir); fp = fopen(fileName, "r"); diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index 64ccfbc9daf42d1555c905e112cb5b2416b1548e..47521fc36e594b9f4bfde1171c5cfdb0831a9e2e 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -66,7 +66,7 @@ int32_t tsAsyncLog = 1; float tsTotalLogDirGB = 0; float tsAvailLogDirGB = 0; float tsMinimalLogDirGB = 0.1; -char logDir[TSDB_FILENAME_LEN] = "/var/log/taos"; +char tsLogDir[TSDB_FILENAME_LEN] = "/var/log/taos"; static SLogObj tsLogObj = { .fileNum = 1 }; static void * taosAsyncOutputLog(void *param); @@ -298,7 +298,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) { void taosPrintLog(const char *const flags, int32_t dflag, const char *const format, ...) { if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < tsMinimalLogDirGB) { - printf("server disk:%s space remain %.3f GB, total %.1f GB, stop print log.\n", logDir, tsAvailLogDirGB, tsTotalLogDirGB); + printf("server disk:%s space remain %.3f GB, total %.1f GB, stop print log.\n", tsLogDir, tsAvailLogDirGB, tsTotalLogDirGB); fflush(stdout); return; } @@ -356,7 +356,7 @@ void taosPrintLog(const char *const flags, int32_t dflag, const char *const form void taosDumpData(unsigned char *msg, int32_t len) { if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < tsMinimalLogDirGB) { - printf("server disk:%s space remain %.3f GB, total %.1f GB, stop dump log.\n", logDir, tsAvailLogDirGB, tsTotalLogDirGB); + printf("server disk:%s space remain %.3f GB, total %.1f GB, stop dump log.\n", tsLogDir, tsAvailLogDirGB, tsTotalLogDirGB); fflush(stdout); return; } @@ -385,7 +385,7 @@ void taosDumpData(unsigned char *msg, int32_t len) { void taosPrintLongString(const char *const flags, int32_t dflag, const char *const format, ...) { if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < tsMinimalLogDirGB) { - printf("server disk:%s space remain %.3f GB, total %.1f GB, stop write log.\n", logDir, tsAvailLogDirGB, tsTotalLogDirGB); + printf("server disk:%s space remain %.3f GB, total %.1f GB, stop write log.\n", tsLogDir, tsAvailLogDirGB, tsTotalLogDirGB); fflush(stdout); return; } diff --git a/src/util/src/tnote.c b/src/util/src/tnote.c index 9e0f6597aee26c0271f355c0e82cefabd565f50f..91d586322d47b97c02e981aa3e324391d431fa0a 100644 --- a/src/util/src/tnote.c +++ b/src/util/src/tnote.c @@ -27,10 +27,10 @@ void taosInitNote(int numOfNoteLines, int maxNotes, char* lable) if (strcasecmp(lable, "http_note") == 0) { pNote = &m_HttpNote; - sprintf(temp, "%s/httpnote", logDir); + sprintf(temp, "%s/httpnote", tsLogDir); } else if (strcasecmp(lable, "tsc_note") == 0) { pNote = &m_TscNote; - sprintf(temp, "%s/tscnote-%d", logDir, getpid()); + sprintf(temp, "%s/tscnote-%d", tsLogDir, getpid()); } else { return; } diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 9ae05887714375148f8689acaba18f5f132665cb..9c4c2d562e410cdbd22038679833752f757c045b 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -311,7 +311,7 @@ void *vnodeGetWqueue(int32_t vgId) { SVnodeObj *pVnode = vnodeAccquireVnode(vgId); if (pVnode == NULL) return NULL; return pVnode->wqueue; -} +} void *vnodeGetWal(void *pVnode) { return ((SVnodeObj *)pVnode)->wal; @@ -341,10 +341,13 @@ static void vnodeBuildVloadMsg(char *pNode, void * param) { } static void vnodeCleanUp(SVnodeObj *pVnode) { - taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId); - //syncStop(pVnode->sync); + if (pVnode->sync) { + syncStop(pVnode->sync); + pVnode->sync = NULL; + } + tsdbCloseRepo(pVnode->tsdb); walClose(pVnode->wal); vnodeSaveVersion(pVnode); @@ -379,7 +382,8 @@ static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) { sprintf(cfgFile, "%s/vnode%d/config.json", tsVnodeDir, pVnodeCfg->cfg.vgId); FILE *fp = fopen(cfgFile, "w"); if (!fp) { - dError("vgId:%d, failed to open vnode cfg file for write, error:%s", pVnodeCfg->cfg.vgId, strerror(errno)); + dError("vgId:%d, failed to open vnode cfg file for write, file:%s error:%s", pVnodeCfg->cfg.vgId, cfgFile, + strerror(errno)); return errno; } @@ -444,7 +448,8 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) { sprintf(cfgFile, "%s/vnode%d/config.json", tsVnodeDir, pVnode->vgId); FILE *fp = fopen(cfgFile, "r"); if (!fp) { - dError("pVnode:%p vgId:%d, failed to open vnode cfg file for read, error:%s", pVnode, pVnode->vgId, strerror(errno)); + dError("pVnode:%p vgId:%d, failed to open vnode cfg file for read, file:%s, error:%s", pVnode, pVnode->vgId, + cfgFile, strerror(errno)); return errno; } @@ -645,13 +650,13 @@ PARSE_OVER: return ret; } - static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { char versionFile[TSDB_FILENAME_LEN + 30] = {0}; sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId); FILE *fp = fopen(versionFile, "w"); if (!fp) { - dError("pVnode:%p vgId:%d, failed to open vnode version file for write, error:%s", pVnode, pVnode->vgId, strerror(errno)); + dError("pVnode:%p vgId:%d, failed to open vnode version file for write, file:%s error:%s", pVnode, pVnode->vgId, + versionFile, strerror(errno)); return errno; } @@ -667,7 +672,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { fclose(fp); free(content); - dPrint("pVnode:%p vgId:%d, save vnode version successed", pVnode, pVnode->vgId); + dPrint("pVnode:%p vgId:%d, save vnode version:%" PRId64 " successed", pVnode, pVnode->vgId, pVnode->version); return 0; } @@ -675,9 +680,10 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { static bool vnodeReadVersion(SVnodeObj *pVnode) { char versionFile[TSDB_FILENAME_LEN + 30] = {0}; sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId); - FILE *fp = fopen(versionFile, "w"); + FILE *fp = fopen(versionFile, "r"); if (!fp) { - dError("pVnode:%p vgId:%d, failed to open vnode version file for write, error:%s", pVnode, pVnode->vgId, strerror(errno)); + dTrace("pVnode:%p vgId:%d, failed to open version file:%s error:%s", pVnode, pVnode->vgId, + versionFile, strerror(errno)); return false; } diff --git a/tests/script/sh/exec_up.sh b/tests/script/sh/exec_up.sh index ee4aabc175ee284596b11843f2bcd0ab9f38a8e8..abe2822450957045ee6468b460d0b44220fd80d7 100755 --- a/tests/script/sh/exec_up.sh +++ b/tests/script/sh/exec_up.sh @@ -70,24 +70,15 @@ if [ "$CLEAR_OPTION" = "clear" ]; then rm -rf $MGMT_DIR fi -if [ "$SHELL_OPTION" = "true" ]; then - if [ "$EXEC_OPTON" = "start" ]; then - echo "ExcuteCmd:" $EXE_DIR/taos -c $CFG_DIR -u $USERS -p - $EXE_DIR/taos -c $CFG_DIR -u $USERS -p +if [ "$EXEC_OPTON" = "start" ]; then + echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR + + if [ "$SHELL_OPTION" = "true" ]; then + nohup valgrind --log-file=${LOG_DIR}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & else - #relative path - RCFG_DIR=sim/$NODE_NAME/cfg - PID=`ps -ef|grep -v taosd | grep taos | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` - if [ -n "$PID" ]; then - sudo kill -9 $PID - fi + nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & fi - return -fi -if [ "$EXEC_OPTON" = "start" ]; then - echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR - nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & #TT=`date +%s` #mkdir ${LOG_DIR}/${TT} #echo valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR diff --git a/tests/script/unique/db/commit.sim b/tests/script/unique/db/commit.sim index 7f86f85c97b1b73c56c7af62786565854009569d..a9aa674a27d488e00bf7f5d3654c366f077dd112 100644 --- a/tests/script/unique/db/commit.sim +++ b/tests/script/unique/db/commit.sim @@ -17,13 +17,13 @@ system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 print ========= start dnode1 as master -system sh/exec.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start sql connect sleep 3000 print ========= start other dnodes sql create dnode 192.168.0.2 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sleep 3000 print ======== step1 create db @@ -50,9 +50,9 @@ if $data01 != 40 then endi print ======== step2 stop dnode -system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 5000 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sleep 3000 sql select * from tb order by ts desc @@ -101,9 +101,9 @@ if $data01 != 40 then endi print ======== step5 stop dnode -system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 5000 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sleep 3000 sql select * from tb diff --git a/tests/script/unique/db/delete.sim b/tests/script/unique/db/delete.sim index 9262239b04f570fc19188a3381661ad3a1753f4a..ce1c3fef127aea80384eec8f8ff910030ab82f4b 100644 --- a/tests/script/unique/db/delete.sim +++ b/tests/script/unique/db/delete.sim @@ -20,12 +20,12 @@ system sh/cfg.sh -n dnode2 -c cacheBlockSize -v 200 system sh/cfg.sh -n dnode3 -c cacheBlockSize -v 200 print ========= start dnodes -system sh/exec.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start sql connect sql create dnode 192.168.0.2 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sql create dnode 192.168.0.3 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sleep 3000 print ======== step1 diff --git a/tests/script/unique/db/delete_part.sim b/tests/script/unique/db/delete_part.sim index a0a3356cd0ce5f11298b0d50e60bc960ef320fb2..4e2808dbaa6cdaaba1b011098a44a38b37ccacdf 100644 --- a/tests/script/unique/db/delete_part.sim +++ b/tests/script/unique/db/delete_part.sim @@ -35,10 +35,10 @@ system sh/cfg.sh -n dnode3 -c tables -v 4 system sh/cfg.sh -n dnode4 -c tables -v 4 print ========= start dnodes -system sh/exec.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start sql connect sql create dnode 192.168.0.2 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sleep 3000 $loop = 0 @@ -59,13 +59,13 @@ begin: endw print ======== step2 - system sh/exec.sh -n dnode2 -s stop + system sh/exec_up.sh -n dnode2 -s stop sql drop database $db print ======== step3 sleep 3000 - system sh/exec.sh -n dnode2 -s start + system sh/exec_up.sh -n dnode2 -s start sleep 20000 print ===> test times : $loop diff --git a/tests/script/unique/db/replica_add12.sim b/tests/script/unique/db/replica_add12.sim index 969a2a209157df62549a593d75e85605a4f7f318..29f9fdbea8d9135604e43c2a2cb3f90d7e010472 100644 --- a/tests/script/unique/db/replica_add12.sim +++ b/tests/script/unique/db/replica_add12.sim @@ -145,7 +145,9 @@ if $rows != 2 then return -1 endi +sql reset query cache sleep 2000 + print ========= step5 system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 5000 @@ -155,7 +157,7 @@ if $rows != 2 then return -1 endi -sql select * from d2.t2 +sql select * from d2.t2 if $rows != 2 then return -1 endi @@ -172,11 +174,12 @@ endi print ===== insert data - sql insert into d1.t1 values(now, 3) -sql insert into d2.t2 values(now, 3) +# no master +sql_error insert into d2.t2 values(now, 3) sql insert into d3.t3 values(now, 3) -sql insert into d4.t4 values(now, 3) +# no master +sql_error insert into d4.t4 values(now, 3) sql select * from d1.t1 if $rows != 3 then @@ -184,7 +187,7 @@ if $rows != 3 then endi sql select * from d2.t2 -if $rows != 3 then +if $rows != 2 then return -1 endi @@ -194,32 +197,49 @@ if $rows != 3 then endi sql select * from d4.t4 -if $rows != 3 then +if $rows != 2 then return -1 endi print ========= step6 system sh/exec_up.sh -n dnode2 -s start -sleep 10000 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -sleep 10000 - -sql insert into d1.t1 values(now, 4) -sql insert into d2.t2 values(now, 4) -sql insert into d3.t3 values(now, 4) -sql insert into d4.t4 values(now, 4) +sleep 5000 +sql insert into d2.t2 values(now, 3) +sql insert into d4.t4 values(now, 3) sql select * from d1.t1 -if $rows != 4 then +if $rows != 3 then return -1 endi sql select * from d2.t2 -if $rows != 4 then +if $rows != 3 then return -1 endi sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step61 + +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +sleep 5000 + +# no master +sql_error insert into d1.t1 values(now, 4) +sql insert into d2.t2 values(now, 4) +# no master +sql_error insert into d3.t3 values(now, 4) +sql insert into d4.t4 values(now, 4) + +sql select * from d2.t2 if $rows != 4 then return -1 endi @@ -231,9 +251,7 @@ endi print ========= step7 system sh/exec_up.sh -n dnode3 -s start -sleep 10000 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -sleep 10000 +sleep 5000 sql insert into d1.t1 values(now, 5) sql insert into d2.t2 values(now, 5) @@ -241,7 +259,7 @@ sql insert into d3.t3 values(now, 5) sql insert into d4.t4 values(now, 5) sql select * from d1.t1 -if $rows != 5 then +if $rows != 4 then return -1 endi @@ -251,7 +269,7 @@ if $rows != 5 then endi sql select * from d3.t3 -if $rows != 5 then +if $rows != 4 then return -1 endi diff --git a/tests/script/unique/db/replica_add13.sim b/tests/script/unique/db/replica_add13.sim index fd5515f1a8f4cdf51cac37562a9a69b32106d159..a4854adc53ca94c8c0471f3601297e8f2ff5cfff 100644 --- a/tests/script/unique/db/replica_add13.sim +++ b/tests/script/unique/db/replica_add13.sim @@ -30,14 +30,14 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start sql connect sql create dnode 192.168.0.2 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sql create dnode 192.168.0.3 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sql create dnode 192.168.0.4 -system sh/exec.sh -n dnode4 -s start +system sh/exec_up.sh -n dnode4 -s start sleep 3000 print ======== step1 @@ -81,7 +81,7 @@ sql alter database d1 replica 3 sql alter database d2 replica 3 sql alter database d3 replica 3 sql alter database d4 replica 3 -sleep 12000 +sleep 10000 print ======== step3 $x = 0 @@ -93,29 +93,25 @@ show3: endi sql show dnodes -print dnode192.168.0.1 ==> openVnodes: $data2_192.168.0.1 freeVnodes: $data3_192.168.0.1 -print dnode192.168.0.2 ==> openVnodes: $data2_192.168.0.2 freeVnodes: $data3_192.168.0.2 -print dnode192.168.0.3 ==> openVnodes: $data2_192.168.0.3 freeVnodes: $data3_192.168.0.3 -print dnode192.168.0.4 ==> openVnodes: $data2_192.168.0.4 freeVnodes: $data3_192.168.0.4 - -if $data2_192.168.0.1 != 0 then - goto show3 -endi +print dnode192.168.0.1 ==> openVnodes: $data3_1 +print dnode192.168.0.2 ==> openVnodes: $data3_2 +print dnode192.168.0.3 ==> openVnodes: $data3_3 +print dnode192.168.0.4 ==> openVnodes: $data3_4 -if $data3_192.168.0.1 != 4 then - goto show3 +if $data3_1 != 0 then + return -1 endi -if $data3_192.168.0.2 != 0 then - goto show3 +if $data3_2 != 4 then + return -1 endi -if $data3_192.168.0.3 != 0 then - goto show3 +if $data3_3 != 4 then + return -1 endi -if $data3_192.168.0.4 != 0 then - goto show3 +if $data3_3 != 4 then + return -1 endi print ======== step4 @@ -145,9 +141,10 @@ if $rows != 2 then endi print ========= step5 -sleep 10000 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 +sql reset query cache +sleep 1000 +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 sql insert into d1.t1 values(now, 3) sql insert into d2.t2 values(now, 3) @@ -175,9 +172,9 @@ if $rows != 3 then endi print ========= step6 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sleep 5000 -system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT sleep 3000 sql insert into d1.t1 values(now, 4) @@ -206,9 +203,9 @@ if $rows != 4 then endi print ========= step7 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sleep 5000 -system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT sleep 3000 sql insert into d1.t1 values(now, 5) @@ -237,9 +234,9 @@ if $rows != 5 then endi print ========= step8 -system sh/exec.sh -n dnode4 -s start +system sh/exec_up.sh -n dnode4 -s start sleep 5000 -system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 3000 sql insert into d1.t1 values(now, 6) diff --git a/tests/script/unique/db/replica_add23.sim b/tests/script/unique/db/replica_add23.sim index 9aea2e5a4afb1a2bb095cd9fcf4ca3ef1ecd2059..0aebcce988c3ff97faca835ca6c84db0bdb12535 100644 --- a/tests/script/unique/db/replica_add23.sim +++ b/tests/script/unique/db/replica_add23.sim @@ -30,14 +30,14 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start sql connect sql create dnode 192.168.0.2 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sql create dnode 192.168.0.3 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sql create dnode 192.168.0.4 -system sh/exec.sh -n dnode4 -s start +system sh/exec_up.sh -n dnode4 -s start sleep 3000 print ======== step1 @@ -81,7 +81,7 @@ sql alter database d1 replica 3 sql alter database d2 replica 3 sql alter database d3 replica 3 sql alter database d4 replica 3 -sleep 12000 +sleep 10000 print ======== step3 $x = 0 @@ -93,41 +93,25 @@ show3: endi sql show dnodes -print dnode192.168.0.1 ==> openVnodes: $data2_192.168.0.1 freeVnodes: $data3_192.168.0.1 -print dnode192.168.0.2 ==> openVnodes: $data2_192.168.0.2 freeVnodes: $data3_192.168.0.2 -print dnode192.168.0.3 ==> openVnodes: $data2_192.168.0.3 freeVnodes: $data3_192.168.0.3 -print dnode192.168.0.4 ==> openVnodes: $data2_192.168.0.4 freeVnodes: $data3_192.168.0.4 - -if $data2_192.168.0.1 != 0 then - goto show3 -endi - -if $data2_192.168.0.2 != 4 then - goto show3 -endi +print dnode192.168.0.1 ==> openVnodes: $data3_1 +print dnode192.168.0.2 ==> openVnodes: $data3_2 +print dnode192.168.0.3 ==> openVnodes: $data3_3 +print dnode192.168.0.4 ==> openVnodes: $data3_4 -if $data2_192.168.0.3 != 4 then - goto show3 +if $data3_1 != 0 then + return -1 endi -if $data2_192.168.0.4 != 4 then - goto show3 +if $data3_2 != 4 then + return -1 endi -if $data3_192.168.0.1 != 4 then - goto show3 +if $data3_3 != 4 then + return -1 endi -if $data3_192.168.0.2 != 0 then - goto show3 -endi - -if $data3_192.168.0.3 != 0 then - goto show3 -endi - -if $data3_192.168.0.4 != 0 then - goto show3 +if $data3_3 != 4 then + return -1 endi print ======== step4 @@ -156,10 +140,12 @@ if $rows != 2 then return -1 endi -sleep 10000 +sql reset query cache +sleep 1000 + print ========= step5 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 sql insert into d1.t1 values(now, 3) sql insert into d2.t2 values(now, 3) @@ -187,10 +173,10 @@ if $rows != 3 then endi print ========= step6 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start +sleep 5000 +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT sleep 5000 -system sh/exec.sh -n dnode3 -s stop -x SIGINT -sleep 3000 sql insert into d1.t1 values(now, 4) sql insert into d2.t2 values(now, 4) @@ -218,10 +204,10 @@ if $rows != 4 then endi print ========= step7 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start +sleep 5000 +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT sleep 5000 -system sh/exec.sh -n dnode4 -s stop -x SIGINT -sleep 3000 sql insert into d1.t1 values(now, 5) sql insert into d2.t2 values(now, 5) @@ -249,10 +235,10 @@ if $rows != 5 then endi print ========= step8 -system sh/exec.sh -n dnode4 -s start +system sh/exec_up.sh -n dnode4 -s start +sleep 5000 +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 5000 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 sql insert into d1.t1 values(now, 6) sql insert into d2.t2 values(now, 6) diff --git a/tests/script/unique/db/replica_part.sim b/tests/script/unique/db/replica_part.sim index f1b037a9d90f22b60c175b042161b97d1dc208d5..144c3f674fa43125cff0bc6104d186d55b80236c 100644 --- a/tests/script/unique/db/replica_part.sim +++ b/tests/script/unique/db/replica_part.sim @@ -20,12 +20,12 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start sql connect sql create dnode 192.168.0.2 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sql create dnode 192.168.0.3 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sleep 3000 print ======== step1 @@ -65,16 +65,16 @@ if $rows != 1 then endi print ========= step2 alter db -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 sql alter database d1 replica 2 sql alter database d2 replica 2 sql alter database d3 replica 2 sql alter database d4 replica 2 -sleep 3000 +sleep 5000 print ========= step3 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sleep 10000 print ========= step4 @@ -104,70 +104,39 @@ if $rows != 2 then endi print ========= step5 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 - -sql insert into d1.t1 values(now, 3) -sql insert into d2.t2 values(now, 3) -sql insert into d3.t3 values(now, 3) -sql insert into d4.t4 values(now, 3) - -sql select * from d1.t1 -if $rows != 3 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 3 then - return -1 -endi +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 -sql select * from d3.t3 -if $rows != 3 then - return -1 -endi +sql reset query cache +sleep 1000 -sql select * from d4.t4 -if $rows != 3 then - return -1 -endi +sql insert into d1.t1 values(now, 3) -x s1 +s1: +sql insert into d2.t2 values(now, 3) -x s2 +s2: +sql insert into d3.t3 values(now, 3) -x s3 +s3: +sql insert into d4.t4 values(now, 3) -x s4 +s4: print ========= step6 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start +sleep 5000 +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT sleep 5000 -system sh/exec.sh -n dnode3 -s stop -x SIGINT -sleep 3000 - -sql insert into d1.t1 values(now, 4) -sql insert into d2.t2 values(now, 4) -sql insert into d3.t3 values(now, 4) -sql insert into d4.t4 values(now, 4) - -sql select * from d1.t1 -if $rows != 4 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 4 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 4 then - return -1 -endi -sql select * from d4.t4 -if $rows != 4 then - return -1 -endi +sql insert into d1.t1 values(now, 4) -x s5 +s5: +sql insert into d2.t2 values(now, 4) -x s6 +s6: +sql insert into d3.t3 values(now, 4) -x s7 +s7: +sql insert into d4.t4 values(now, 4) -x s8 +s8: print ========= step7 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sleep 5000 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 sql insert into d1.t1 values(now, 5) sql insert into d2.t2 values(now, 5) @@ -175,22 +144,6 @@ sql insert into d3.t3 values(now, 5) sql insert into d4.t4 values(now, 5) sql select * from d1.t1 -if $rows != 5 then - return -1 -endi - sql select * from d2.t2 -if $rows != 5 then - return -1 -endi - sql select * from d3.t3 -if $rows != 5 then - return -1 -endi - sql select * from d4.t4 -if $rows != 5 then - return -1 -endi - diff --git a/tests/script/unique/db/replica_reduce21.sim b/tests/script/unique/db/replica_reduce21.sim index 085d07b714d5731305883ab2c0000c900f4f7c43..9f15cf3453d4a2dadbea6587646415b1ba67c44b 100644 --- a/tests/script/unique/db/replica_reduce21.sim +++ b/tests/script/unique/db/replica_reduce21.sim @@ -20,10 +20,10 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start sql connect sql create dnode 192.168.0.2 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sleep 3000 print ======== step1 @@ -70,7 +70,7 @@ error1: print ========= step3 alter d1 sql alter database d1 replica 1 -sleep 8000 +sleep 12000 print ========= step4 query d1 sql insert into d1.t1 values(now, 2) @@ -86,16 +86,12 @@ sql select * from d5.t5 if $rows != 1 then return -1 endi - -print ========= step6 alter d5 -sql alter database d5 replica 2 -x error2 - return -1 -error2: - +return print ========= step7 drop d1 sql drop database d1 -sleep 12000 +sleep 5000 +sql reset query cache print ========= step8 sql insert into d5.t5 values(now, 2) sql insert into d2.t2 values(now, 2) @@ -123,7 +119,7 @@ if $rows != 2 then endi print ======== step9 stop dnode2 -system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 3000 sql insert into d5.t5 values(now, 3) diff --git a/tests/script/unique/db/replica_reduce31.sim b/tests/script/unique/db/replica_reduce31.sim index 1190d688aaffc4e4fdecf91c0c64446e10744135..c34dccbd621e70ebf4b8ff987573d3593babfc30 100644 --- a/tests/script/unique/db/replica_reduce31.sim +++ b/tests/script/unique/db/replica_reduce31.sim @@ -20,12 +20,12 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start sql connect sql create dnode 192.168.0.2 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sql create dnode 192.168.0.3 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sleep 3000 print ======== step1 @@ -39,8 +39,8 @@ sql create table d2.t2 (ts timestamp, i int) sql create table d3.t3 (ts timestamp, i int) sql create table d4.t4 (ts timestamp, i int) -sql insert into d2.t2 values(now, 1) sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) sql insert into d3.t3 values(now, 1) sql insert into d4.t4 values(now, 1) @@ -65,12 +65,25 @@ if $rows != 1 then endi print ========= step2 alter db +sql_error alter database d1 replica 1 +sql_error alter database d2 replica 1 +sql_error alter database d3 replica 1 +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 + +sleep 8000 + sql alter database d1 replica 1 sql alter database d2 replica 1 sql alter database d3 replica 1 -sleep 12000 + +sleep 8000 print ========= step3 +sql reset query cache +sleep 1000 + sql insert into d1.t1 values(now, 2) sql insert into d2.t2 values(now, 2) sql insert into d3.t3 values(now, 2) @@ -100,7 +113,7 @@ print ========= step4 alter db sql alter database d1 replica 2 sql alter database d2 replica 2 sql alter database d3 replica 2 -sleep 12000 +sleep 8000 sql insert into d1.t1 values(now, 3) sql insert into d2.t2 values(now, 3) @@ -128,93 +141,46 @@ if $rows != 3 then endi print ========= step4 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 - -sql insert into d1.t1 values(now, 4) -sql insert into d2.t2 values(now, 4) -sql insert into d3.t3 values(now, 4) -sql insert into d4.t4 values(now, 4) - -sql select * from d1.t1 -if $rows != 4 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 4 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 4 then - return -1 -endi +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 -sql select * from d4.t4 -if $rows != 4 then - return -1 -endi +sql reset query cache +sleep 1000 +sql insert into d1.t1 values(now, 4) -x step1 +step1: +sql insert into d2.t2 values(now, 4) -x step2 +step2: +sql insert into d3.t3 values(now, 4) -x step3 +step3: +sql insert into d4.t4 values(now, 4) -x step4 +step4: print ========= step5 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start +sleep 5000 +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT sleep 5000 -system sh/exec.sh -n dnode3 -s stop -x SIGINT -sleep 3000 - -sql insert into d1.t1 values(now, 5) -sql insert into d2.t2 values(now, 5) -sql insert into d3.t3 values(now, 5) -sql insert into d4.t4 values(now, 5) - -sql select * from d1.t1 -if $rows != 5 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 5 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 5 then - return -1 -endi - -sql select * from d4.t4 -if $rows != 5 then - return -1 -endi +sql insert into d1.t1 values(now, 5) -x step5 +step5: +sql insert into d2.t2 values(now, 5) -x step6 +step6: +sql insert into d3.t3 values(now, 5) -x step7 +step7: +sql insert into d4.t4 values(now, 5) -x step8 +step8: print ========= step6 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sleep 5000 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 + sql insert into d1.t1 values(now, 6) sql insert into d2.t2 values(now, 6) sql insert into d3.t3 values(now, 6) sql insert into d4.t4 values(now, 6) sql select * from d1.t1 -if $rows != 6 then - return -1 -endi - sql select * from d2.t2 -if $rows != 6 then - return -1 -endi - sql select * from d3.t3 -if $rows != 6 then - return -1 -endi - sql select * from d4.t4 -if $rows != 6 then - return -1 -endi diff --git a/tests/script/unique/db/replica_reduce32.sim b/tests/script/unique/db/replica_reduce32.sim index cdb5ada79b8cd2adacaf0f7876c401443eb1209e..a9cda824b83c4faf90b35c6da00e6454b98a5a70 100644 --- a/tests/script/unique/db/replica_reduce32.sim +++ b/tests/script/unique/db/replica_reduce32.sim @@ -20,12 +20,12 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start sql connect sql create dnode 192.168.0.2 -system sh/exec.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start sql create dnode 192.168.0.3 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sleep 3000 print ======== step1 @@ -68,6 +68,7 @@ print ========= step2 alter db sql alter database d1 replica 2 sql alter database d2 replica 2 sql alter database d3 replica 2 +sql alter database d4 replica 2 sleep 12000 print ========= step3 @@ -97,8 +98,8 @@ if $rows != 2 then endi print ========= step4 -system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 sql insert into d1.t1 values(now, 3) sql insert into d2.t2 values(now, 3) @@ -126,40 +127,24 @@ if $rows != 3 then endi print ========= step5 -system sh/exec.sh -n dnode2 -s start -sleep 5000 -system sh/exec.sh -n dnode3 -s stop -x SIGINT -sleep 3000 - -sql insert into d1.t1 values(now, 4) -sql insert into d2.t2 values(now, 4) -sql insert into d3.t3 values(now, 4) -sql insert into d4.t4 values(now, 4) - -sql select * from d1.t1 -if $rows != 4 then - return -1 -endi +system sh/exec_up.sh -n dnode2 -s start -sql select * from d2.t2 -if $rows != 4 then - return -1 -endi +sleep 5000 +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +sleep 5000 -sql select * from d3.t3 -if $rows != 4 then - return -1 -endi +sql reset query cache +sleep 1000 -sql select * from d4.t4 -if $rows != 4 then - return -1 -endi +sql_error insert into d1.t1 values(now, 4) +sql_error insert into d2.t2 values(now, 4) +sql_error insert into d3.t3 values(now, 4) +sql_error insert into d4.t4 values(now, 4) print ========= step6 -system sh/exec.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start sleep 5000 -system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 3000 sql insert into d1.t1 values(now, 5) @@ -168,21 +153,21 @@ sql insert into d3.t3 values(now, 5) sql insert into d4.t4 values(now, 5) sql select * from d1.t1 -if $rows != 5 then +if $rows != 4 then return -1 endi sql select * from d2.t2 -if $rows != 5 then +if $rows != 4 then return -1 endi sql select * from d3.t3 -if $rows != 5 then +if $rows != 4 then return -1 endi sql select * from d4.t4 -if $rows != 5 then +if $rows != 4 then return -1 endi diff --git a/tests/script/unique/db/testSuite.sim b/tests/script/unique/db/testSuite.sim index a370668860e85c124f75e83ce8b6bc18e47c253a..49188504262736820daf9eee7f8e17b85fdfbee5 100644 --- a/tests/script/unique/db/testSuite.sim +++ b/tests/script/unique/db/testSuite.sim @@ -1,5 +1,5 @@ #run unique/db/commit.sim -run unique/db/delete.sim +#run unique/db/delete.sim run unique/db/replica_add12.sim run unique/db/replica_add13.sim run unique/db/replica_add23.sim @@ -7,4 +7,4 @@ run unique/db/replica_reduce21.sim run unique/db/replica_reduce32.sim run unique/db/replica_reduce31.sim run unique/db/replica_part.sim -run unique/db/delete_part.sim +#run unique/db/delete_part.sim diff --git a/tests/tsim/inc/sim.h b/tests/tsim/inc/sim.h index 304c4889470fa5a66e0d9021c3bd620dcecabaed..ae8848e1acd7567d5aa7d18b1d7abf71c4c5b518 100644 --- a/tests/tsim/inc/sim.h +++ b/tests/tsim/inc/sim.h @@ -160,7 +160,7 @@ extern SCommand simCmdList[]; extern int simScriptPos; extern int simScriptSucced; extern int simDebugFlag; -extern char scriptDir[]; +extern char tsScriptDir[]; extern bool simAsyncQuery; SScript *simParseScript(char *fileName); diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 23f8f9173f77cd75e9125a8b7673a74fbf52b8e5..dd7f268f3efd3bbfff1c5abe0ba125443a78f58a 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -24,7 +24,7 @@ void simLogSql(char *sql) { static FILE *fp = NULL; char filename[256]; - sprintf(filename, "%s/sim.sql", scriptDir); + sprintf(filename, "%s/sim.sql", tsScriptDir); if (fp == NULL) { fp = fopen(filename, "w"); if (fp == NULL) { @@ -270,7 +270,7 @@ bool simExecuteRunBackCmd(SScript *script, char *option) { bool simExecuteSystemCmd(SScript *script, char *option) { char buf[4096] = {0}; - sprintf(buf, "cd %s; ", scriptDir); + sprintf(buf, "cd %s; ", tsScriptDir); simVisuallizeOption(script, option, buf + strlen(buf)); int code = system(buf); @@ -306,9 +306,9 @@ void simStoreSystemContentResult(SScript *script, char *filename) { bool simExecuteSystemContentCmd(SScript *script, char *option) { char buf[4096] = {0}; char filename[400] = {0}; - sprintf(filename, "%s/%s.tmp", scriptDir, script->fileName); + sprintf(filename, "%s/%s.tmp", tsScriptDir, script->fileName); - sprintf(buf, "cd %s; ", scriptDir); + sprintf(buf, "cd %s; ", tsScriptDir); simVisuallizeOption(script, option, buf + strlen(buf)); sprintf(buf, "%s > %s 2>/dev/null", buf, filename); diff --git a/tests/tsim/src/simParse.c b/tests/tsim/src/simParse.c index 62f5c1efb8fcfd713644a35dbf8edbf9aa653319..fddda679c681e12d8dbb8bcb82315f13b718dbbe 100644 --- a/tests/tsim/src/simParse.c +++ b/tests/tsim/src/simParse.c @@ -186,7 +186,7 @@ SScript *simParseScript(char *fileName) { if ((fileName[0] == '.') || (fileName[0] == '/')) { strcpy(name, fileName); } else { - sprintf(name, "%s/%s", scriptDir, fileName); + sprintf(name, "%s/%s", tsScriptDir, fileName); } if ((fd = fopen(name, "r")) == NULL) {