From 090ed9b78b5a5192d0d35a8cd4f464aa7d9490a4 Mon Sep 17 00:00:00 2001 From: Alexey Gerasimchuck Date: Tue, 15 Apr 2025 05:40:44 +0000 Subject: [PATCH 1/3] Added handleFatalError in handleClosed --- orm_lib/src/postgresql_impl/PgConnection.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/orm_lib/src/postgresql_impl/PgConnection.cc b/orm_lib/src/postgresql_impl/PgConnection.cc index a318a81787..74b0b481df 100644 --- a/orm_lib/src/postgresql_impl/PgConnection.cc +++ b/orm_lib/src/postgresql_impl/PgConnection.cc @@ -133,6 +133,15 @@ void PgConnection::handleClosed() if (status_ == ConnectStatus::Bad) return; status_ = ConnectStatus::Bad; + + if (isWorking_) + { + // Connection was closed unexpectedly during isWorking_ while were true. + isWorking_ = false; + handleFatalError(); + callback_ = nullptr; + } + channel_.disableAll(); channel_.remove(); assert(closeCallback_); @@ -406,10 +415,13 @@ void PgConnection::doAfterPreparing() void PgConnection::handleFatalError() { - auto exceptPtr = - std::make_exception_ptr(Failure(PQerrorMessage(connectionPtr_.get()))); if (exceptionCallback_) + { + auto exceptPtr = std::make_exception_ptr( + Failure(PQerrorMessage(connectionPtr_.get()))); exceptionCallback_(exceptPtr); + } + exceptionCallback_ = nullptr; } From 6a249adb00996556c6a550621f90d5105d691902 Mon Sep 17 00:00:00 2001 From: Alexey Gerasimchuck Date: Tue, 15 Apr 2025 06:26:43 +0000 Subject: [PATCH 2/3] Minor corrections --- orm_lib/src/DbConnection.h | 2 +- orm_lib/src/postgresql_impl/PgConnection.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/orm_lib/src/DbConnection.h b/orm_lib/src/DbConnection.h index c49838a2a0..35e27e72dc 100644 --- a/orm_lib/src/DbConnection.h +++ b/orm_lib/src/DbConnection.h @@ -118,7 +118,7 @@ class DbConnection : public trantor::NonCopyable virtual ~DbConnection() { - LOG_TRACE << "Destruct DbConn" << this; + LOG_TRACE << "Destruct DbConn " << this; } ConnectStatus status() const diff --git a/orm_lib/src/postgresql_impl/PgConnection.cc b/orm_lib/src/postgresql_impl/PgConnection.cc index 74b0b481df..acb99ba38c 100644 --- a/orm_lib/src/postgresql_impl/PgConnection.cc +++ b/orm_lib/src/postgresql_impl/PgConnection.cc @@ -136,7 +136,7 @@ void PgConnection::handleClosed() if (isWorking_) { - // Connection was closed unexpectedly during isWorking_ while were true. + // Connection was closed unexpectedly while isWorking_ were true. isWorking_ = false; handleFatalError(); callback_ = nullptr; From 85500b5c016299c87b07d94e71f9c5035f4d73dc Mon Sep 17 00:00:00 2001 From: Alexey Gerasimchuck Date: Tue, 15 Apr 2025 06:37:20 +0000 Subject: [PATCH 3/3] spelling fix --- orm_lib/src/postgresql_impl/PgConnection.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orm_lib/src/postgresql_impl/PgConnection.cc b/orm_lib/src/postgresql_impl/PgConnection.cc index acb99ba38c..8687159d7c 100644 --- a/orm_lib/src/postgresql_impl/PgConnection.cc +++ b/orm_lib/src/postgresql_impl/PgConnection.cc @@ -136,7 +136,7 @@ void PgConnection::handleClosed() if (isWorking_) { - // Connection was closed unexpectedly while isWorking_ were true. + // Connection was closed unexpectedly while isWorking_ was true. isWorking_ = false; handleFatalError(); callback_ = nullptr;