drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.51k stars 1.1k forks source link

request is not finished yet again!!! #779

Closed SGD9919 closed 3 years ago

SGD9919 commented 3 years ago

this time is getFastDbClient code: orm::DbClientPtr db_client= app().getFastDbClient(); Mapper mp(db_client); auto query =mp.findFutureOne(Criteria(user::User::Cols::_account_name,CompareOperator::EQ,name)); auto user = query.get(); config: "db_clients": [ { //name: Name of the client,'default' by default //"name":"", //rdbms: Server type, postgresql,mysql or sqlite3, "postgresql" by default "rdbms": "mysql", //filename: Sqlite3 db file name //"filename":"", //host: Server address,localhost by default "host": "127.0.0.1", //port: Server port, 5432 by default "port": 5306, //dbname: Database name "dbname": "user", //user: 'postgres' by default "user": "root", //passwd: '' by default "passwd": "123456", //is_fast: false by default, if it is true, the client is faster but user can't call //any synchronous interface of it. "is_fast": true, //client_encoding: The character set used by the client. it is empty string by default which //means use the default character set. //"client_encoding": "", //number_of_connections: 1 by default, if the 'is_fast' is true, the number is the number of
//connections per IO thread, otherwise it is the total number of all connections.
"number_of_connections": 1 } ], after call auto user = query.get(); ,requst will be stucked in it; this problem is not happen in no fast DbClient; just like those works well : orm::DbClientPtr db_client= app().getDbClient(); Mapper mp(db_client); auto query =mp.findFutureOne(Criteria(user::User::Cols::_account_name,CompareOperator::EQ,name)); auto user = query.get();

an-tao commented 3 years ago

For FastDbClient, the current thread must not be blocked to wait for the result, because the thread is also used to handle the database connections IO. You should only use the async interfaces or coroutine interfaces of FastDbClient.

an-tao commented 3 years ago

Please refer to wiki

SGD9919 commented 3 years ago

ok,I will try

SGD9919 commented 3 years ago

I call findone async method was ok ,I suggest use Async to divide the override may be better