Closed BurievSardor closed 5 months ago
I have the same problem
我遇到过相同的错误,这是在pg的ip无法连接的情况下,可能是尝试打开了很多次,导致系统打开的文件过多出错
补充一下,遇到这种情况,是在服务启动后20s内(如果IP连不上的话)
I can't reproduce this issue, please contact me with QQ, @lldxflwb
Hello @an-tao Is there any progress on this issue?
The problem may be located in these lines: https://github.com/drogonframework/drogon/blob/96919df488e0ebaa0ed304bbd76bba33508df3cc/orm_lib/src/postgresql_impl/PgBatchConnection.cc#L80-L97
Here we do exit(1)
.
It is possible to reproduce the issue using these steps:
1) Open connection to Postgres using DbClient
2) Stop Postgres database service.
3) Drogon will try to reconnect to the Postgres database after 1 second, but the connection will not be established. and exit(1)
will be called
Reconnection to the Postgres database happens here: https://github.com/drogonframework/drogon/blob/96919df488e0ebaa0ed304bbd76bba33508df3cc/orm_lib/src/DbClientImpl.cc#L424-L446
This diagram shows the workflow of an application using Drogon code:
This scheme shows that application stops working on the database shutdown.
Here is proposed solution scheme with 1 second interval reconnection:
In this case, if Drogon loses connection to the database then framework will try to reconnect to the database with 1 second interval until connection is established. After connection is established, all queued SQL queries will be executed.
This diagram shows the workflow of an application using Drogon code:
This scheme shows that application stops working on the database shutdown.
Here is proposed solution scheme with 1 second interval reconnection:
In this case, if Drogon loses connection to the database then framework will try to reconnect to the database with 1 second interval until connection is established. After connection is established, all queued SQL queries will be executed.
Thank you very much for your detailed feedback, I'll take some time to figure it out.
If I restart postgres server manually, my drogon project quits and I get the following error: "FATAL Socket fd < 0, Usually this is because the number of files opened by the program exceeds the system limit. Please use the ulimit command to check".
VirtualBox 6.1.38 Ubuntu 20.04.2 LTS QtCreator 5.0.2 GCC11 Drogon version 1.7.5