drogonframework / drogonframework/drogon

Usage of Mapper after CoroMapper result in Deadlock

Open
#2,331 5 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 12h
Merged PRs (30d)
15

Description

**Describe the bug**
After using co_awaiting CoroMapper, program does not return in IOLoop, but stays in DbLoop. Therefore usage of Mapper after that results in deadlock

**To Reproduce**
Steps to reproduce the behavior:
1. Set in config number_of_connections to 1 for your dbclient
2. Execute this code in AsyncTask:
```cpp
orm::CoroMapper coromp(app().getDbClient("reader"));
drogon_model::hw_db::ServerConfig version = co_await coromp.findByPrimaryKey("FRONT_VERSION");
orm::Mapper mp(app().getDbClient("reader"));
drogon_model::hw_db::ServerConfig version = mp.findByPrimaryKey("FRONT_VERSION");
```
3. In debug you should see, that after `co_await coromp.findByPrimaryKey("FRONT_VERSION");` you will be in DBLoop, but before that you were in IOLoop
4. On last line you will have deadlock

**Expected behavior**
After CoroMapper co_awaiting we should return to IOLoop.

**Desktop:**
- OS: Ubuntu 24.04
- Drogon Version 1.9.9

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.