Merge pull request #29981 from taosdata/fix/3.0/TD-33858-2
fix(stmt2):TD-33858 async bind block bug
This commit is contained in:
commit
9a544eb894
|
@ -2259,10 +2259,6 @@ int taos_stmt2_bind_param_a(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t c
|
|||
}
|
||||
|
||||
STscStmt2 *pStmt = (STscStmt2 *)stmt;
|
||||
if (atomic_load_8((int8_t *)&pStmt->asyncBindParam.asyncBindNum) > 0) {
|
||||
tscError("async bind param is still working, please try again later");
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
}
|
||||
|
||||
ThreadArgs *args = (ThreadArgs *)taosMemoryMalloc(sizeof(ThreadArgs));
|
||||
args->stmt = stmt;
|
||||
|
@ -2270,14 +2266,23 @@ int taos_stmt2_bind_param_a(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t c
|
|||
args->col_idx = col_idx;
|
||||
args->fp = fp;
|
||||
args->param = param;
|
||||
|
||||
(void)taosThreadMutexLock(&(pStmt->asyncBindParam.mutex));
|
||||
if (atomic_load_8((int8_t *)&pStmt->asyncBindParam.asyncBindNum) > 0) {
|
||||
(void)taosThreadMutexUnlock(&(pStmt->asyncBindParam.mutex));
|
||||
tscError("async bind param is still working, please try again later");
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
}
|
||||
(void)atomic_add_fetch_8(&pStmt->asyncBindParam.asyncBindNum, 1);
|
||||
(void)taosThreadMutexUnlock(&(pStmt->asyncBindParam.mutex));
|
||||
|
||||
int code_s = taosStmt2AsyncBind(stmtAsyncBindThreadFunc, (void *)args);
|
||||
if (code_s != TSDB_CODE_SUCCESS) {
|
||||
(void)taosThreadMutexLock(&(pStmt->asyncBindParam.mutex));
|
||||
(void)taosThreadCondSignal(&(pStmt->asyncBindParam.waitCond));
|
||||
(void)atomic_sub_fetch_8(&pStmt->asyncBindParam.asyncBindNum, 1);
|
||||
(void)taosThreadMutexUnlock(&(pStmt->asyncBindParam.mutex));
|
||||
// terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tscError("async bind failed, code:%d , %s", code_s, tstrerror(code_s));
|
||||
}
|
||||
|
||||
return code_s;
|
||||
|
|
|
@ -1926,7 +1926,7 @@ TEST(stmt2Case, async_order) {
|
|||
auto start_time = std::chrono::steady_clock::now();
|
||||
while (!stop_task) {
|
||||
auto elapsed_time = std::chrono::steady_clock::now() - start_time;
|
||||
if (std::chrono::duration_cast<std::chrono::seconds>(elapsed_time).count() > 60) {
|
||||
if (std::chrono::duration_cast<std::chrono::seconds>(elapsed_time).count() > 100) {
|
||||
FAIL() << "Test[stmt2_async_test] timed out";
|
||||
t.detach();
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue