From d7d16682cf22b6c1d44aba714ca23994d5161b7b Mon Sep 17 00:00:00 2001 From: Dmitry Yemanov Date: Fri, 3 Feb 2023 20:15:52 +0300 Subject: [PATCH] More reliable cleanup for the applier. This should fix replicator crashes after replica shutdown. --- src/jrd/jrd.cpp | 10 +++------- src/jrd/replication/Applier.cpp | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index d8506fcaeb..55b161d28b 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -6483,9 +6483,8 @@ void JReplicator::freeEngineData(Firebird::CheckStatusWrapper* user_status) try { - AutoPtr cleanupApplier(applier); - cleanupApplier->shutdown(tdbb); - fb_assert(!applier); + applier->shutdown(tdbb); + applier = nullptr; } catch (const Exception& ex) { @@ -7650,10 +7649,7 @@ void release_attachment(thread_db* tdbb, Jrd::Attachment* attachment, XThreadEns attachment->att_dsql_instance->dbb_statement_cache->shutdown(tdbb); while (attachment->att_repl_appliers.hasData()) - { - AutoPtr cleanupApplier(attachment->att_repl_appliers.pop()); - cleanupApplier->shutdown(tdbb); - } + attachment->att_repl_appliers.pop()->shutdown(tdbb); if (dbb->dbb_crypto_manager) dbb->dbb_crypto_manager->detach(tdbb, attachment); diff --git a/src/jrd/replication/Applier.cpp b/src/jrd/replication/Applier.cpp index de4962dbab..8fa9f3f6cc 100644 --- a/src/jrd/replication/Applier.cpp +++ b/src/jrd/replication/Applier.cpp @@ -285,6 +285,8 @@ void Applier::shutdown(thread_db* tdbb) m_interface->resetHandle(); m_interface = nullptr; } + + delete this; } void Applier::process(thread_db* tdbb, ULONG length, const UCHAR* data)