drogonframework / drogonframework/drogon
执行sql语句偶发卡死,导致不能继续进行业务逻辑
- Dominant language
- C++
- Stars
- 14.3k
- Forks
- 1.4k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 14
Description
**Notice**
If you need support or clarification regarding the usage of Drogon in your project, visit the official Drogon support channel at [gitter](https://gitter.im/drogon-web/community)
Please create a new issue only if you think you have found a bug or if have a feature request/enhancement.
**Describe the bug**
1. 在不停执行sql语句的时候,突然某条sql语句会卡住。 感觉像是在切换connection的时候卡的?
2. 数据库查询`select * from information_schema.innodb_trx ;`
返回结果为:
```
{
"select * from information_schema.innodb_trx ": [
{
"trx_id" : "283751164962608",
"trx_state" : "RUNNING",
"trx_started" : "2025-08-15 17:13:31",
"trx_requested_lock_id" : null,
"trx_wait_started" : null,
"trx_weight" : 0,
"trx_mysql_thread_id" : 368,
"trx_query" : null,
"trx_operation_state" : null,
"trx_tables_in_use" : 0,
"trx_tables_locked" : 0,
"trx_lock_structs" : 0,
"trx_lock_memory_bytes" : 1136,
"trx_rows_locked" : 0,
"trx_rows_modified" : 0,
"trx_concurrency_tickets" : 0,
"trx_isolation_level" : "REPEATABLE READ",
"trx_unique_checks" : 1,
"trx_foreign_key_checks" : 1,
"trx_last_foreign_key_error" : null,
"trx_adaptive_hash_latched" : 0,
"trx_adaptive_hash_timeout" : 0,
"trx_is_read_only" : 0,
"trx_autocommit_non_locking" : 0
}
]}
```
4. 查询`SELECT * FROM information_schema.innodb_lock_waits;`数据为空
5. 查询`select *from performance_schema.threads where PROCESSLIST_ID = 368; `为:
```
{
"select *from performance_schema.threads where PROCESSLIST_ID = 368": [
{
"THREAD_ID" : 393,
"NAME" : "thread/sql/one_connection",
"TYPE" : "FOREGROUND",
"PROCESSLIST_ID" : 368,
"PROCESSLIST_COMMAND" : "Sleep",
"PROCESSLIST_TIME" : 2246,
"PROCESSLIST_STATE" : null,
"PROCESSLIST_INFO" : null,
"PARENT_THREAD_ID" : null,
"ROLE" : null,
"INSTRUMENTED" : "YES",
"HISTORY" : "YES",
"CONNECTION_TYPE" : "TCP\/IP",
"THREAD_OS_ID" : 40628
}
]}
```
**基本配置:**
操作系统:win10
drogon版本:1.9.1
sql :mysql
数据库设置为:connectionNum为5:
drogon 放子线程中了:
```
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::thread t([] {
drogon::app().addListener("0.0.0.0", 6006);
drogon::app().createDbClient(dbType,
DBCenter::getDBIP(),
port,
DB::kIngresDbName,
userName,
pwd,
5);
drogon::app().setLogLevel( trantor::Logger::LogLevel::kTrace);
drogon::app().run();
});
int r = a.exec();
t.join();
return r;
}
```
相关issue
- https://github.com/drogonframework/drogon/issues/2324
**To Reproduce**
单线程重复执行sql语句,正常情况log 如下:
```
MessageConsumer: Request message received, routerKey= /ingres/v1/capture/coloroptimize/update
MessageConsumer: Request body= {"postBody":"{\"captureID\":\"0240ffe60a664a1b802deed75e8f3143\",\"colorAdjustment\":{\"Brightness\":12,\"Contrast\":-22,\"Saturation\":-2,\"Gamma\":2.25,\"Radius\":7,\"Weight\":0.4,\"Denoise\":1}}","userToken":"B95FFCA063519AC0D5E9C41BCA7DAEEB"}
20250815 09:13:31.048 UTC 30300 TRACE [execSqlInLoop] begin - MysqlConnection.cc:422
20250815 09:13:31.048 UTC 30300 TRACE [startQuery] real_query:1 - MysqlConnection.cc:547
20250815 09:13:31.048 UTC 30300 TRACE [handleCmd] real_query:0 - MysqlConnection.cc:241
20250815 09:13:31.048 UTC 30300 TRACE [startStoreResult] store_result:0 - MysqlConnection.cc:567
20250815 09:13:31.048 UTC 30300 TRACE [operator ()] Transaction begin! - TransactionImpl.cc:288
20250815 09:13:31.048 UTC 30300 TRACE [execSqlInLoop] select * from captureextension where CaptureID ='0240ffe60a664a1b802deed75e8f3143' - MysqlConnection.cc:422
20250815 09:13:31.048 UTC 30300 TRACE [startQuery] real_query:1 - MysqlConnection.cc:547
20250815 09:13:31.049 UTC 30300 TRACE [handleCmd] real_query:0 - MysqlConnection.cc:241
20250815 09:13:31.049 UTC 30300 TRACE [startStoreResult] store_result:0 - MysqlConnection.cc:567
20250815 09:13:31.049 UTC 30300 TRACE [execSqlInLoop] update captureextension set ID = ?,ColorOptimize = ? where ID = ? - MysqlConnection.cc:422
20250815 09:13:31.049 UTC 30300 TRACE [startQuery] real_query:1 - MysqlConnection.cc:547
20250815 09:13:31.049 UTC 30300 TRACE [handleCmd] real_query:0 - MysqlConnection.cc:241
20250815 09:13:31.049 UTC 30300 TRACE [startStoreResult] store_result:0 - MysqlConnection.cc:567
20250815 09:13:31.049 UTC 37660 TRACE [~TransactionImpl] Destruct - TransactionImpl.cc:37
20250815 09:13:31.049 UTC 30300 TRACE [execSqlInLoop] commit - MysqlConnection.cc:422
MessageConsumer: Request execute finished, routerKey= /ingres/v1/capture/coloroptimize/update , Elapsed time 2 ms
20250815 09:13:31.049 UTC 30300 TRACE [startQuery] real_query:1 - MysqlConnection.cc:547
20250815 09:13:31.050 UTC 30300 TRACE [handleCmd] real_query:0 - MysqlConnection.cc:241
20250815 09:13:31.050 UTC 30300 TRACE [startStoreResult] store_result:0 - MysqlConnection.cc:567
20250815 09:13:31.050 UTC 30300 TRACE [operator ()] Transaction committed! - TransactionImpl.cc:56
```
卡住时,执行如下
```
MessageConsumer: Request message received, routerKey= /ingres/v1/capture/coloroptimize/update
MessageConsumer: Request body= {"postBody":"{\"captureID\":\"0240ffe60a664a1b802deed75e8f3143\",\"colorAdjustment\":{\"Brightness\":14,\"Contrast\":-22,\"Saturation\":-2,\"Gamma\":2.25,\"Radius\":7,\"Weight\":0.4,\"Denoise\":1}}","userToken":"B95FFCA063519AC0D5E9C41BCA7DAEEB"}
20250815 09:13:31.112 UTC 30300 TRACE [execSqlInLoop] begin - MysqlConnection.cc:422
20250815 09:13:31.113 UTC 30300 TRACE [startQuery] real_query:0 - MysqlConnection.cc:547
20250815 09:13:31.113 UTC 30300 TRACE [startStoreResult] store_result:0 - MysqlConnection.cc:567
20250815 09:13:31.113 UTC 30300 TRACE [operator ()] Transaction begin! - TransactionImpl.cc:288
20250815 09:13:31.113 UTC 30300 TRACE [execSqlInLoop] select * from captureextension where CaptureID ='0240ffe60a664a1b802deed75e8f3143' - MysqlConnection.cc:422
20250815 09:13:31.113 UTC 30300 TRACE [startQuery] real_query:1 - MysqlConnection.cc:547
20250815 09:13:32.116 UTC 30300 TRACE [operator ()] connected! - DbClientImpl.cc:448
```
Contributor guide
Assessment
This issue has not been assessed yet.