Skip to content

Commit bf11bd6

Browse files
XaBbl4dyemanov
authored andcommitted
Add detach replica to shutdown function (#8688)
When apply segment using an external engine (Jaybird/UDR), the replica is not detached by nullifying the variable, because releaseAttachment is not called
1 parent bd5ab06 commit bf11bd6

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/remote/server/ReplServer.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,11 @@ namespace
393393
provider->attachDatabase(&localStatus, m_config->dbName.c_str(),
394394
dpb.getBufferLength(), dpb.getBuffer());
395395
localStatus.check();
396-
m_attachment.assignRefNoIncr(att);
396+
m_attachment = att;
397397

398398
const auto repl = m_attachment->createReplicator(&localStatus);
399399
localStatus.check();
400-
m_replicator.assignRefNoIncr(repl);
400+
m_replicator = repl;
401401

402402
fb_assert(!m_sequence);
403403

@@ -425,8 +425,17 @@ namespace
425425

426426
void shutdown()
427427
{
428-
m_replicator = nullptr;
429-
m_attachment = nullptr;
428+
FbLocalStatus localStatus;
429+
if (m_replicator)
430+
{
431+
m_replicator->close(&localStatus);
432+
m_replicator = nullptr;
433+
}
434+
if (m_attachment)
435+
{
436+
m_attachment->detach(&localStatus);
437+
m_attachment = nullptr;
438+
}
430439
m_sequence = 0;
431440
m_connected = false;
432441
}
@@ -446,7 +455,7 @@ namespace
446455

447456
bool isShutdown() const
448457
{
449-
return (m_attachment == NULL);
458+
return (m_attachment == nullptr);
450459
}
451460

452461
const PathName& getDirectory() const
@@ -504,8 +513,8 @@ namespace
504513

505514
private:
506515
AutoPtr<const Replication::Config> m_config;
507-
RefPtr<IAttachment> m_attachment;
508-
RefPtr<IReplicator> m_replicator;
516+
IAttachment* m_attachment;
517+
IReplicator* m_replicator;
509518
FB_UINT64 m_sequence;
510519
bool m_connected;
511520
string m_lastError;

0 commit comments

Comments
 (0)