提交 1408c0c0 编写于 作者: S shenglian zhou

schemaless: fix schema modification error

上级 532fb5f7
......@@ -849,6 +849,8 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
return code;
}
bool tryAgain = false;
do {
code = taos_stmt_set_tbname(stmt, cTableName);
if (code != 0) {
......@@ -878,7 +880,26 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
if (code != 0) {
tscError("SML:0x%"PRIx64" taos_stmt_execute return %d:%s", info->id, code, tstrerror(code));
}
} while (code == TSDB_CODE_TDB_TABLE_RECONFIGURE && try++ < TSDB_MAX_REPLICA);
tryAgain = false;
if ((code == TSDB_CODE_TDB_INVALID_TABLE_ID
|| code == TSDB_CODE_VND_INVALID_VGROUP_ID
|| code == TSDB_CODE_TDB_TABLE_RECONFIGURE) && try++ < TSDB_MAX_REPLICA) {
tryAgain = true;
}
if (code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) {
TAOS_RES* res2 = taos_query(taos, "RESET QUERY CACHE");
int32_t code2 = taos_errno(res2);
if (code2 != TSDB_CODE_SUCCESS) {
tscError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2));
}
taos_free_result(res2);
if (tryAgain) {
taosMsleep(100 * (2 << (try)));
}
}
} while (tryAgain);
if (code != 0) {
tscError("SML:0x%"PRIx64" %d:%s", info->id, code, tstrerror(code));
......@@ -1084,28 +1105,10 @@ static int32_t applyChildTableFields(TAOS* taos, SSmlSTableSchema* sTableSchema,
taosArrayPush(rowsBind, &colBinds);
}
int32_t retry = 0;
bool retryAgain = false;
do {
code = insertChildTableBatch(taos, cTableName, sTableSchema->fields, rowsBind, info);
if (code != 0) {
tscError("SML:0x%" PRIx64 " insert into child table %s failed. error %s, retry %d", info->id, cTableName, tstrerror(code), retry);
if (code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) {
TAOS_RES* res2 = taos_query(taos, "RESET QUERY CACHE");
int32_t code2 = taos_errno(res2);
if (code2 != TSDB_CODE_SUCCESS) {
tscError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2));
}
taos_free_result(res2);
retryAgain = (++retry < TSDB_MAX_REPLICA) ? true : false;
if (retryAgain) {
taosMsleep(100 * (2 << (retry)));
} else {
tscError("SML:0x%" PRIx64 " insert into child table %s reached max retry", info->id, cTableName);
}
}
}
} while (retryAgain);
code = insertChildTableBatch(taos, cTableName, sTableSchema->fields, rowsBind, info);
if (code != 0) {
tscError("SML:0x%"PRIx64" insert into child table %s failed. error %s", info->id, cTableName, tstrerror(code));
}
for (int i = 0; i < rows; ++i) {
TAOS_BIND* colBinds = taosArrayGetP(rowsBind, i);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册