Skip to content

Commit b4c75f6

Browse files
temeoJan Lindström
authored andcommitted
MDEV-18480 Backwards compatibility in log_view()
Galera versions below 4.x do not generate unique sequence number for view events. Take this into account when writing the SE checkpoint to avoid debug assertion in InnoDB.
1 parent 9b8fc08 commit b4c75f6

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

sql/wsrep_server_service.cc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,12 @@ void Wsrep_server_service::log_view(
176176
{
177177
Wsrep_id id;
178178
Wsrep_view prev_view= wsrep_schema->restore_view(applier->m_thd, id);
179+
bool checkpoint_was_reset= false;
179180
if (prev_view.state_id().id() != view.state_id().id())
180181
{
181182
WSREP_DEBUG("New cluster UUID was generated, resetting position info");
182183
wsrep_set_SE_checkpoint(wsrep::gtid::undefined());
184+
checkpoint_was_reset= true;
183185
}
184186

185187
if (wsrep_debug)
@@ -188,7 +190,7 @@ void Wsrep_server_service::log_view(
188190
os << "Storing cluster view:\n" << view;
189191
WSREP_INFO("%s", os.str().c_str());
190192
DBUG_ASSERT(prev_view.state_id().id() != view.state_id().id() ||
191-
view.state_id().seqno() > prev_view.state_id().seqno());
193+
view.state_id().seqno().get() >= prev_view.state_id().seqno().get());
192194
}
193195

194196
if (trans_begin(applier->m_thd, MYSQL_START_TRANS_OPT_READ_WRITE))
@@ -216,7 +218,21 @@ void Wsrep_server_service::log_view(
216218
applier->m_thd->mdl_context.release_transactional_locks();
217219
}
218220

219-
wsrep_set_SE_checkpoint(view.state_id());
221+
/*
222+
Backwards compatibility: When running in mixed cluster with
223+
Galera 3.x, the provider does not generate unique sequence numbers
224+
for views. This condition can be checked by inspecting last
225+
committed as returned by the provider. If the last_committed
226+
matches to view state_id seqno, the cluster runs in backwards
227+
compatibility mode and we skip setting the checkpoint for
228+
view.
229+
*/
230+
wsrep::seqno last_committed=
231+
Wsrep_server_state::instance().provider().last_committed_gtid().seqno();
232+
if (checkpoint_was_reset || last_committed != view.state_id().seqno())
233+
{
234+
wsrep_set_SE_checkpoint(view.state_id());
235+
}
220236
DBUG_ASSERT(wsrep_get_SE_checkpoint().id() == view.state_id().id());
221237
}
222238
else

0 commit comments

Comments
 (0)