MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / Manager

Method Manager

src/jrd/replication/Manager.cpp:99–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97// Replication manager
98
99Manager::Manager(const string& dbId,
100 const Replication::Config* config)
101 : m_config(config),
102 m_replicas(getPool()),
103 m_buffers(getPool()),
104 m_queue(getPool()),
105 m_queueSize(0),
106 m_sequence(0),
107 m_shutdown(false),
108 m_signalled(false)
109{
110 // Startup the journalling
111
112 const auto tdbb = JRD_get_thread_data();
113 const auto dbb = tdbb->getDatabase();
114
115 dbb->ensureGuid(tdbb);
116 const Guid& guid = dbb->dbb_guid;
117
118 if (config->journalDirectory.hasData())
119 {
120 // At this point it is unknown if change log shared memory exists or not.
121 // To avoid race condition with concurrent changing of current replication
122 // sequence, take and hold shared lock on header page while creating
123 // ChangeLog instance.
124
125 WIN window(HEADER_PAGE_NUMBER);
126 CCH_FETCH(tdbb, &window, LCK_read, pag_header);
127
128 Cleanup releaseHeader([&] {
129 CCH_RELEASE(tdbb, &window);
130 });
131
132 // Call below will fetch header page with LCK_read lock, it is allowed and OK.
133 m_sequence = dbb->getReplSequence(tdbb);
134
135 m_changeLog = FB_NEW_POOL(getPool())
136 ChangeLog(getPool(), dbId, guid, m_sequence, config);
137 }
138 else
139 fb_assert(config->syncReplicas.hasData());
140
141 // Attach to synchronous replicas (if any)
142
143 FbLocalStatus localStatus;
144 DispatcherPtr provider;
145
146 for (const auto& iter : m_config->syncReplicas)
147 {
148 ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE);
149 dpb.insertByte(isc_dpb_no_db_triggers, 1);
150
151 if (iter.username.hasData())
152 {
153 dpb.insertString(isc_dpb_user_name, iter.username);
154
155 if (iter.password.hasData())
156 dpb.insertString(isc_dpb_password, iter.password);

Callers

nothing calls this directly

Calls 15

JRD_get_thread_dataFunction · 0.85
CCH_FETCHFunction · 0.85
CCH_RELEASEFunction · 0.85
ChangeLogClass · 0.85
logPrimaryStatusFunction · 0.85
GdsClass · 0.85
getDatabaseMethod · 0.80
ensureGuidMethod · 0.80
getReplSequenceMethod · 0.80
insertByteMethod · 0.80
SyncReplicaClass · 0.70
StatusVectorClass · 0.50

Tested by

no test coverage detected