From 26f24955a2c335ccf761fa3b4fb631141b78cfb9 Mon Sep 17 00:00:00 2001 From: Andrey Kravchenko Date: Mon, 4 Aug 2025 14:51:57 +0300 Subject: [PATCH] Add detach replica to shutdown function When apply segment using an external engine (Jaybird/UDR), the replica is not detached by nullifying the variable, because releaseAttachment is not called --- src/remote/server/ReplServer.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/remote/server/ReplServer.cpp b/src/remote/server/ReplServer.cpp index 1e0948d306f..23108edfba0 100644 --- a/src/remote/server/ReplServer.cpp +++ b/src/remote/server/ReplServer.cpp @@ -384,11 +384,11 @@ namespace provider->attachDatabase(&localStatus, m_config->dbName.c_str(), dpb.getBufferLength(), dpb.getBuffer()); localStatus.check(); - m_attachment.assignRefNoIncr(att); + m_attachment = att; const auto repl = m_attachment->createReplicator(&localStatus); localStatus.check(); - m_replicator.assignRefNoIncr(repl); + m_replicator = repl; fb_assert(!m_sequence); @@ -416,8 +416,17 @@ namespace void shutdown() { - m_replicator = nullptr; - m_attachment = nullptr; + FbLocalStatus localStatus; + if (m_replicator) + { + m_replicator->close(&localStatus); + m_replicator = nullptr; + } + if (m_attachment) + { + m_attachment->detach(&localStatus); + m_attachment = nullptr; + } m_sequence = 0; m_connected = false; } @@ -437,7 +446,7 @@ namespace bool isShutdown() const { - return (m_attachment == NULL); + return (m_attachment == nullptr); } const PathName& getDirectory() const @@ -495,8 +504,8 @@ namespace private: AutoPtr m_config; - RefPtr m_attachment; - RefPtr m_replicator; + IAttachment* m_attachment; + IReplicator* m_replicator; FB_UINT64 m_sequence; bool m_connected; string m_lastError;