未验证 提交 8b4a46de 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

Hotfix/sangshuduo/td 3985 taosdemo timestamp step overflow (#6139)

* [TD-3985]<fix>: taosdemo timestamp step overflow.

* fix specified subscribe test.

* replace potential overflow of int32 to int64

* replace potential int32 overflow variables to int64.

* replace potential int32 overflow variables to int64.

* change max of int16 to int64 after type changed.

* improve more and more.
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 5dee3afd
......@@ -212,8 +212,8 @@ typedef struct SArguments_S {
uint64_t interlace_rows;
uint64_t num_of_RPR; // num_of_records_per_req
uint64_t max_sql_len;
uint64_t num_of_tables;
uint64_t num_of_DPT;
int64_t num_of_tables;
int64_t num_of_DPT;
int abort;
int disorderRatio; // 0: no disorder, >0: x%
int disorderRange; // ms or us by database precision
......@@ -240,7 +240,7 @@ typedef struct SSuperTable_S {
char dataSource[MAX_TB_NAME_SIZE+1]; // rand_gen or sample
char insertMode[MAX_TB_NAME_SIZE]; // taosc, rest
int64_t childTblLimit;
uint64_t childTblOffset;
uint64_t childTblOffset;
// int multiThreadWriteOneTbl; // 0: no, 1: yes
uint64_t interlaceRows; //
......@@ -249,7 +249,7 @@ typedef struct SSuperTable_S {
uint64_t maxSqlLen; //
uint64_t insertInterval; // insert interval, will override global insert interval
uint64_t insertRows;
int64_t insertRows;
int64_t timeStampStep;
char startTimestamp[MAX_TB_NAME_SIZE];
char sampleFormat[MAX_TB_NAME_SIZE]; // csv, json
......@@ -258,7 +258,7 @@ typedef struct SSuperTable_S {
uint32_t columnCount;
StrColumn columns[MAX_COLUMN_COUNT];
uint32_t tagCount;
uint32_t tagCount;
StrColumn tags[MAX_TAG_COUNT];
char* childTblName;
......@@ -377,7 +377,7 @@ typedef struct SuperQueryInfo_S {
int subscribeRestart;
int subscribeKeepProgress;
uint64_t queryTimes;
uint64_t childTblCount;
int64_t childTblCount;
char childTblPrefix[MAX_TB_NAME_SIZE];
uint64_t sqlCount;
char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH+1];
......@@ -581,7 +581,7 @@ SArguments g_args = {
static SDbs g_Dbs;
static uint64_t g_totalChildTables = 0;
static int64_t g_totalChildTables = 0;
static SQueryMetaInfo g_queryInfo;
static FILE * g_fpOfInsertResult = NULL;
......@@ -1015,9 +1015,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->max_sql_len);
printf("# Length of Binary: %d\n", arguments->len_of_binary);
printf("# Number of Threads: %d\n", arguments->num_of_threads);
printf("# Number of Tables: %"PRIu64"\n",
printf("# Number of Tables: %"PRId64"\n",
arguments->num_of_tables);
printf("# Number of Data per Table: %"PRIu64"\n",
printf("# Number of Data per Table: %"PRId64"\n",
arguments->num_of_DPT);
printf("# Database name: %s\n", arguments->database);
printf("# Table prefix: %s\n", arguments->tb_prefix);
......@@ -1388,7 +1388,7 @@ static int printfInsertMeta() {
printf(" childTblExists: \033[33m%s\033[0m\n", "error");
}
printf(" childTblCount: \033[33m%"PRIu64"\033[0m\n",
printf(" childTblCount: \033[33m%"PRId64"\033[0m\n",
g_Dbs.db[i].superTbls[j].childTblCount);
printf(" childTblPrefix: \033[33m%s\033[0m\n",
g_Dbs.db[i].superTbls[j].childTblPrefix);
......@@ -1404,7 +1404,7 @@ static int printfInsertMeta() {
printf(" childTblOffset: \033[33m%"PRIu64"\033[0m\n",
g_Dbs.db[i].superTbls[j].childTblOffset);
}
printf(" insertRows: \033[33m%"PRIu64"\033[0m\n",
printf(" insertRows: \033[33m%"PRId64"\033[0m\n",
g_Dbs.db[i].superTbls[j].insertRows);
/*
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
......@@ -1571,7 +1571,7 @@ static void printfInsertMetaToFile(FILE* fp) {
fprintf(fp, " childTblExists: %s\n", "error");
}
fprintf(fp, " childTblCount: %"PRIu64"\n",
fprintf(fp, " childTblCount: %"PRId64"\n",
g_Dbs.db[i].superTbls[j].childTblCount);
fprintf(fp, " childTblPrefix: %s\n",
g_Dbs.db[i].superTbls[j].childTblPrefix);
......@@ -1579,7 +1579,7 @@ static void printfInsertMetaToFile(FILE* fp) {
g_Dbs.db[i].superTbls[j].dataSource);
fprintf(fp, " insertMode: %s\n",
g_Dbs.db[i].superTbls[j].insertMode);
fprintf(fp, " insertRows: %"PRIu64"\n",
fprintf(fp, " insertRows: %"PRId64"\n",
g_Dbs.db[i].superTbls[j].insertRows);
fprintf(fp, " interlace rows: %"PRIu64"\n",
g_Dbs.db[i].superTbls[j].interlaceRows);
......@@ -1697,7 +1697,7 @@ static void printfQueryMeta() {
g_queryInfo.superQueryInfo.queryInterval);
printf("threadCnt: \033[33m%d\033[0m\n",
g_queryInfo.superQueryInfo.threadCnt);
printf("childTblCount: \033[33m%"PRIu64"\033[0m\n",
printf("childTblCount: \033[33m%"PRId64"\033[0m\n",
g_queryInfo.superQueryInfo.childTblCount);
printf("stable name: \033[33m%s\033[0m\n",
g_queryInfo.superQueryInfo.sTblName);
......@@ -2327,7 +2327,7 @@ static int calcRowLen(SSuperTable* superTbls) {
static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
char* dbName, char* sTblName, char** childTblNameOfSuperTbl,
uint64_t* childTblCountOfSuperTbl, int64_t limit, uint64_t offset) {
int64_t* childTblCountOfSuperTbl, int64_t limit, uint64_t offset) {
char command[BUFFER_SIZE] = "\0";
char limitBuf[100] = "\0";
......@@ -2356,8 +2356,8 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
exit(-1);
}
int childTblCount = (limit < 0)?10000:limit;
int count = 0;
int64_t childTblCount = (limit < 0)?10000:limit;
int64_t count = 0;
if (childTblName == NULL) {
childTblName = (char*)calloc(1, childTblCount * TSDB_TABLE_NAME_LEN);
if (NULL == childTblName) {
......@@ -2404,7 +2404,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName,
char* sTblName, char** childTblNameOfSuperTbl,
uint64_t* childTblCountOfSuperTbl) {
int64_t* childTblCountOfSuperTbl) {
return getChildNameOfSuperTableWithLimitAndOffset(taos, dbName, sTblName,
childTblNameOfSuperTbl, childTblCountOfSuperTbl,
......@@ -3000,7 +3000,7 @@ static void createChildTables() {
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")");
verbosePrint("%s() LN%d: dbName: %s num of tb: %"PRIu64" schema: %s\n",
verbosePrint("%s() LN%d: dbName: %s num of tb: %"PRId64" schema: %s\n",
__func__, __LINE__,
g_Dbs.db[i].dbName, g_args.num_of_tables, tblColsBuf);
startMultiThreadCreateChildTable(
......@@ -4772,7 +4772,7 @@ static void getTableName(char *pTblName, threadInfo* pThreadInfo, uint64_t table
static int64_t generateDataTail(
SSuperTable* superTblInfo,
uint64_t batch, char* buffer, int64_t remainderBufLen, int64_t insertRows,
int64_t startFrom, int64_t startTime, int64_t *pSamplePos, int64_t *dataLen) {
uint64_t startFrom, int64_t startTime, int64_t *pSamplePos, int64_t *dataLen) {
uint64_t len = 0;
uint32_t ncols_per_record = 1; // count first col ts
......@@ -4948,7 +4948,7 @@ static int64_t generateInterlaceDataBuffer(
char *tableName, uint64_t batchPerTbl, uint64_t i, uint64_t batchPerTblTimes,
uint64_t tableSeq,
threadInfo *pThreadInfo, char *buffer,
uint64_t insertRows,
int64_t insertRows,
int64_t startTime,
uint64_t *pRemainderBufLen)
{
......@@ -5008,7 +5008,7 @@ static int64_t generateProgressiveDataBuffer(
int64_t tableSeq,
threadInfo *pThreadInfo, char *buffer,
int64_t insertRows,
int64_t startFrom, int64_t startTime, int64_t *pSamplePos,
uint64_t startFrom, int64_t startTime, int64_t *pSamplePos,
int64_t *pRemainderBufLen)
{
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
......@@ -5061,7 +5061,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
debugPrint("[%d] %s() LN%d: ### interlace write\n",
pThreadInfo->threadID, __func__, __LINE__);
uint64_t insertRows;
int64_t insertRows;
uint64_t interlaceRows;
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
......@@ -5341,7 +5341,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
tableSeq ++) {
int64_t start_time = pThreadInfo->start_time;
uint64_t insertRows = (superTblInfo)?superTblInfo->insertRows:g_args.num_of_DPT;
int64_t insertRows = (superTblInfo)?superTblInfo->insertRows:g_args.num_of_DPT;
verbosePrint("%s() LN%d insertRows=%"PRId64"\n", __func__, __LINE__, insertRows);
for (uint64_t i = 0; i < insertRows;) {
......@@ -5658,7 +5658,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
}
int64_t ntables = 0;
int64_t startFrom;
uint64_t startFrom;
if (superTblInfo) {
int64_t limit;
......@@ -5714,7 +5714,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
exit(-1);
}
uint64_t childTblCount;
int64_t childTblCount;
getChildNameOfSuperTableWithLimitAndOffset(
taos,
db_name, superTblInfo->sTblName,
......@@ -5890,7 +5890,7 @@ static void *readTable(void *sarg) {
return NULL;
}
uint64_t num_of_DPT;
int64_t num_of_DPT;
/* if (rinfo->superTblInfo) {
num_of_DPT = rinfo->superTblInfo->insertRows; // nrecords_per_table;
} else {
......@@ -5909,11 +5909,11 @@ static void *readTable(void *sarg) {
printf("%"PRId64" records:\n", totalData);
fprintf(fp, "| QFunctions | QRecords | QSpeed(R/s) | QLatency(ms) |\n");
for (uint64_t j = 0; j < n; j++) {
for (int j = 0; j < n; j++) {
double totalT = 0;
uint64_t count = 0;
for (uint64_t i = 0; i < num_of_tables; i++) {
sprintf(command, "select %s from %s%"PRIu64" where ts>= %" PRIu64,
for (int64_t i = 0; i < num_of_tables; i++) {
sprintf(command, "select %s from %s%"PRId64" where ts>= %" PRIu64,
aggreFunc[j], tb_prefix, i, sTime);
double t = taosGetTimestampMs();
......@@ -5976,13 +5976,13 @@ static void *readMetric(void *sarg) {
char condition[COND_BUF_LEN] = "\0";
char tempS[64] = "\0";
int m = 10 < num_of_tables ? 10 : num_of_tables;
int64_t m = 10 < num_of_tables ? 10 : num_of_tables;
for (int i = 1; i <= m; i++) {
for (int64_t i = 1; i <= m; i++) {
if (i == 1) {
sprintf(tempS, "t1 = %d", i);
sprintf(tempS, "t1 = %"PRId64"", i);
} else {
sprintf(tempS, " or t1 = %d ", i);
sprintf(tempS, " or t1 = %"PRId64" ", i);
}
strncat(condition, tempS, COND_BUF_LEN - 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册