retry afer batch execute reconfigure table
This commit is contained in:
parent
ddb783f407
commit
bcba45e38b
|
@ -324,7 +324,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t destorySmlSTableSchema(SSmlSTableSchema* schema) {
|
static int32_t destroySmlSTableSchema(SSmlSTableSchema* schema) {
|
||||||
taosHashCleanup(schema->tagHash);
|
taosHashCleanup(schema->tagHash);
|
||||||
taosHashCleanup(schema->fieldHash);
|
taosHashCleanup(schema->fieldHash);
|
||||||
taosArrayDestroy(schema->tags);
|
taosArrayDestroy(schema->tags);
|
||||||
|
@ -435,7 +435,7 @@ static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) {
|
||||||
|
|
||||||
pointSchema->precision = dbSchema.precision;
|
pointSchema->precision = dbSchema.precision;
|
||||||
|
|
||||||
destorySmlSTableSchema(&dbSchema);
|
destroySmlSTableSchema(&dbSchema);
|
||||||
} else if (code == TSDB_CODE_SUCCESS) {
|
} else if (code == TSDB_CODE_SUCCESS) {
|
||||||
size_t pointTagSize = taosArrayGetSize(pointSchema->tags);
|
size_t pointTagSize = taosArrayGetSize(pointSchema->tags);
|
||||||
size_t pointFieldSize = taosArrayGetSize(pointSchema->fields);
|
size_t pointFieldSize = taosArrayGetSize(pointSchema->fields);
|
||||||
|
@ -469,7 +469,7 @@ static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) {
|
||||||
|
|
||||||
pointSchema->precision = dbSchema.precision;
|
pointSchema->precision = dbSchema.precision;
|
||||||
|
|
||||||
destorySmlSTableSchema(&dbSchema);
|
destroySmlSTableSchema(&dbSchema);
|
||||||
} else {
|
} else {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -565,42 +565,47 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
|
||||||
}
|
}
|
||||||
snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ")");
|
snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ")");
|
||||||
|
|
||||||
TAOS_STMT* stmt = taos_stmt_init(taos);
|
int32_t code = 0;
|
||||||
int32_t code;
|
int32_t try = 0;
|
||||||
code = taos_stmt_prepare(stmt, sql, strlen(sql));
|
do {
|
||||||
if (code != 0) {
|
TAOS_STMT* stmt = taos_stmt_init(taos);
|
||||||
printf("%s", taos_stmt_errstr(stmt));
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = taos_stmt_set_tbname(stmt, cTableName);
|
code = taos_stmt_prepare(stmt, sql, strlen(sql));
|
||||||
if (code != 0) {
|
|
||||||
printf("%s", taos_stmt_errstr(stmt));
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t rows = taosArrayGetSize(rowsBind);
|
|
||||||
for (int32_t i = 0; i < rows; ++i) {
|
|
||||||
TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i);
|
|
||||||
code = taos_stmt_bind_param(stmt, colsBinds);
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
printf("%s", taos_stmt_errstr(stmt));
|
printf("%s", taos_stmt_errstr(stmt));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
code = taos_stmt_add_batch(stmt);
|
|
||||||
|
code = taos_stmt_set_tbname(stmt, cTableName);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
printf("%s", taos_stmt_errstr(stmt));
|
printf("%s", taos_stmt_errstr(stmt));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
code = taos_stmt_execute(stmt);
|
size_t rows = taosArrayGetSize(rowsBind);
|
||||||
if (code != 0) {
|
for (int32_t i = 0; i < rows; ++i) {
|
||||||
printf("%s", taos_stmt_errstr(stmt));
|
TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i);
|
||||||
return code;
|
code = taos_stmt_bind_param(stmt, colsBinds);
|
||||||
}
|
if (code != 0) {
|
||||||
|
printf("%s", taos_stmt_errstr(stmt));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
code = taos_stmt_add_batch(stmt);
|
||||||
|
if (code != 0) {
|
||||||
|
printf("%s", taos_stmt_errstr(stmt));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = taos_stmt_execute(stmt);
|
||||||
|
if (code != 0) {
|
||||||
|
printf("%s", taos_stmt_errstr(stmt));
|
||||||
|
taos_stmt_close(stmt);
|
||||||
|
} else {
|
||||||
|
taos_stmt_close(stmt);
|
||||||
|
}
|
||||||
|
} while (code == TSDB_CODE_TDB_TABLE_RECONFIGURE && try++ < TSDB_MAX_REPLICA);
|
||||||
|
|
||||||
taos_stmt_close(stmt);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <taos.h>
|
#include <taos.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <tconfig.h>
|
|
||||||
|
|
||||||
static void prepare_data(TAOS* taos) {
|
static void prepare_data(TAOS* taos) {
|
||||||
TAOS_RES *result;
|
TAOS_RES *result;
|
||||||
|
@ -972,9 +971,9 @@ int32_t verify_schema_less(TAOS* taos) {
|
||||||
"ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532"
|
"ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532"
|
||||||
};
|
};
|
||||||
|
|
||||||
int code = taos_insert_by_lines(taos, lines , 5);
|
// int code = taos_insert_by_lines(taos, lines , 5);
|
||||||
//int code = taos_insert_by_lines(taos, &lines[0], 1);
|
int code = taos_insert_by_lines(taos, &lines[0], 1);
|
||||||
//code = taos_insert_by_lines(taos, &lines[1], 1);
|
code = taos_insert_by_lines(taos, &lines[1], 1);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -985,7 +984,6 @@ int main(int argc, char *argv[]) {
|
||||||
const char* passwd = "taosdata";
|
const char* passwd = "taosdata";
|
||||||
|
|
||||||
taos_options(TSDB_OPTION_TIMEZONE, "GMT-8");
|
taos_options(TSDB_OPTION_TIMEZONE, "GMT-8");
|
||||||
taosDumpGlobalCfg();
|
|
||||||
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
||||||
if (taos == NULL) {
|
if (taos == NULL) {
|
||||||
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
|
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
|
||||||
|
|
Loading…
Reference in New Issue