1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-8134: The relay-log is not flushed after the slave-relay-log.999999 showed

Problem:
========
Auto purge of relaylogs stops when relay-log-file is
'slave-relay-log.999999' and slave_parallel_threads is enabled.

Analysis:
=========
The problem is that in Relay_log_info::inc_group_relay_log_pos() function,
when two log names are compared via strcmp() function, it gives correct
result, when log name sequence numbers are of same digits(6 digits), But
when the number goes to 7 digits, a 999999 compares greater than
1000000, which is wrong, hence the bug.

Fix:
====
Extract the numeric extension part of the file name, convert it into
unsigned long and compare.

Thanks to David Zhao for the contribution.
This commit is contained in:
Sujatha
2021-01-07 17:34:57 +05:30
parent 53acd1c1d8
commit eb75e8705d
6 changed files with 169 additions and 4 deletions

View File

@ -4541,5 +4541,22 @@ rpl_gtid_pos_update(THD *thd, char *str, size_t len)
return false;
}
int compare_log_name(const char *log_1, const char *log_2) {
int res= 1;
const char *ext1_str= strrchr(log_1, '.');
const char *ext2_str= strrchr(log_2, '.');
char file_name_1[255], file_name_2[255];
strmake(file_name_1, log_1, (ext1_str - log_1));
strmake(file_name_2, log_2, (ext2_str - log_2));
char *endptr = NULL;
res= strcmp(file_name_1, file_name_2);
if (!res)
{
ulong ext1= strtoul(++ext1_str, &endptr, 10);
ulong ext2= strtoul(++ext2_str, &endptr, 10);
res= (ext1 > ext2 ? 1 : ((ext1 == ext2) ? 0 : -1));
}
return res;
}
#endif /* HAVE_REPLICATION */