Skip to content

Commit 651a675

Browse files
committed
Make sure we can use local_seqno provided by MySQL as correct
seqno to start replication.
1 parent 2b514b5 commit 651a675

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

mysql-test/suite/galera/r/galera_var_wsrep_start_position.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,13 @@ SET @@global.wsrep_start_position='12345678-1234-1234-1234-123456789012:100,1-1-
157157
ERROR 42000: Variable 'wsrep_start_position' can't be set to the value of '12345678-1234-1234-1234-123456789012:100,1-1-20/abcdefghijklmn'
158158
SHOW WARNINGS;
159159
Level Code Message
160+
Warning 1231 wsrep_start_position incorrect 'abcdefghijklmn', local_seqno incorrect
160161
Error 1231 Variable 'wsrep_start_position' can't be set to the value of '12345678-1234-1234-1234-123456789012:100,1-1-20/abcdefghijklmn'
162+
SET @@global.wsrep_start_position='64de8141-7bf8-11f0-a5e1-2f107ecf09fa:8410/8502/11/57df8fe9-7bf8-11f0-83b8-00e04ca2f8fe';
163+
ERROR 42000: Variable 'wsrep_start_position' can't be set to the value of '64de8141-7bf8-11f0-a5e1-2f107ecf09fa:8410/8502/11/57df8fe9-7bf8-11f0-83b8-00e04ca2f8fe'
164+
SHOW WARNINGS;
165+
Level Code Message
166+
Error 1231 Variable 'wsrep_start_position' can't be set to the value of '64de8141-7bf8-11f0-a5e1-2f107ecf09fa:8410/8502/11/57df8fe9-7bf8-11f0-83b8-00e04ca2f8fe'
161167

162168
# restore the initial value
163169
SET @@global.wsrep_start_position = @wsrep_start_position_global_saved;

mysql-test/suite/galera/t/galera_var_wsrep_start_position.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ SHOW WARNINGS;
109109
--error ER_WRONG_VALUE_FOR_VAR
110110
SET @@global.wsrep_start_position='12345678-1234-1234-1234-123456789012:100,1-1-20/abcdefghijklmn';
111111
SHOW WARNINGS;
112+
# correct format but wrong position
113+
--error ER_WRONG_VALUE_FOR_VAR
114+
SET @@global.wsrep_start_position='64de8141-7bf8-11f0-a5e1-2f107ecf09fa:8410/8502/11/57df8fe9-7bf8-11f0-83b8-00e04ca2f8fe';
115+
SHOW WARNINGS;
112116

113117
--echo
114118
--echo # restore the initial value

sql/wsrep_var.cc

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,25 @@ bool wsrep_start_position_verify (THD* thd, const char* start_str)
321321

322322
// Remaining string was seqno.
323323
if (*endptr == '\0' || *endptr == '/') {
324-
/* In migration MySQL 8.x start position can have additional info */
324+
/* In migration MySQL 8.x start position can have additional info
325+
i.e. local_seqno */
325326
if (*endptr == '/')
326-
*endptr= '\0';
327+
{
328+
endptr++;
329+
startptr= endptr;
330+
uint64_t local_seqno __attribute__((unused))
331+
(parse_value<uint64_t>(&startptr, &endptr));
332+
if (*endptr != '/')
333+
{
334+
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
335+
ER_WRONG_VALUE_FOR_VAR,
336+
"wsrep_start_position incorrect '%s'"
337+
", local_seqno incorrect",
338+
endptr);
339+
return true;
340+
}
341+
342+
}
327343
return false;
328344
}
329345

@@ -345,7 +361,16 @@ bool wsrep_set_local_position(THD* thd, const char* const value,
345361
wsrep_uuid_t uuid;
346362
size_t const uuid_len= wsrep_uuid_scan(value, length, &uuid);
347363
startptr= (char *)value + uuid_len + 1;
348-
wsrep_seqno_t const seqno= parse_value<uint64_t>(&startptr, &endptr);
364+
wsrep_seqno_t seqno= parse_value<uint64_t>(&startptr, &endptr);
365+
366+
/* If this start position is from MySQL we read local_seqno because
367+
it is the correct position to start. */
368+
if (*startptr == '/')
369+
{
370+
startptr++;
371+
wsrep_seqno_t local_seqno= parse_value<uint64_t>(&startptr, &endptr);
372+
seqno= local_seqno;
373+
}
349374

350375
if (*startptr == ',')
351376
{

0 commit comments

Comments
 (0)