Skip to content

Commit 185591c

Browse files
committed
MDEV-31349 test maria.maria-purge failed on 'aria_log.00000002 not found'
The bug was in the test case. The problem was that maria_empty_logs.inc deleted aria log files before the server was properly shutdown. Fixed by waiting for pid file to disappear before starting to delete log files. Other things: - Fixed that translog_purge_at_flush() will not stop deleting files even if one file could not be deleted.
1 parent 424a7a2 commit 185591c

File tree

3 files changed

+56
-16
lines changed

3 files changed

+56
-16
lines changed

mysql-test/include/maria_empty_logs.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
connection default;
1212
let $default_db=`select database()`;
1313
let $MYSQLD_DATADIR= `SELECT @@datadir`;
14+
let $pid_file=`select @@pid_file`;
1415

1516
#it will used at end of test for wait_for_status_var.inc primitive
1617
#let $status_var= Threads_connected;
@@ -23,6 +24,7 @@ wait-maria_empty_logs.inc
2324
EOF
2425

2526
--source include/mysqladmin_shutdown.inc
27+
--source include/wait_until_no_pidfile.inc
2628

2729
--disable_warnings
2830
if (!$mel_keep_control_file)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Include this script after a shutdown to wait until the pid file,
2+
# stored in $pid_file, has disappered.
3+
4+
#--echo $pid_file
5+
6+
--disable_result_log
7+
--disable_query_log
8+
# Wait one minute
9+
let $counter= 600;
10+
while ($counter)
11+
{
12+
--error 0,1
13+
--file_exists $pid_file
14+
if (!$errno)
15+
{
16+
dec $counter;
17+
--real_sleep 0.1
18+
}
19+
if ($errno)
20+
{
21+
let $counter= 0;
22+
}
23+
}
24+
if (!$errno)
25+
{
26+
--die Pid file "$pid_file" failed to disappear
27+
}
28+
29+
--enable_query_log
30+
--enable_result_log

storage/maria/ma_loghandler.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8427,34 +8427,41 @@ my_bool translog_is_file(uint file_no)
84278427

84288428
static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected)
84298429
{
8430-
uint min_file= 0, max_file;
8430+
uint min_file= 1, max_file;
84318431
DBUG_ENTER("translog_first_file");
84328432
if (!is_protected)
84338433
mysql_mutex_lock(&log_descriptor.purger_lock);
8434-
if (log_descriptor.min_file_number &&
8435-
translog_is_file(log_descriptor.min_file_number))
8434+
if (log_descriptor.min_file_number)
84368435
{
8437-
DBUG_PRINT("info", ("cached %lu",
8438-
(ulong) log_descriptor.min_file_number));
8439-
if (!is_protected)
8440-
mysql_mutex_unlock(&log_descriptor.purger_lock);
8441-
DBUG_RETURN(log_descriptor.min_file_number);
8436+
min_file= log_descriptor.min_file_number;
8437+
if (translog_is_file(log_descriptor.min_file_number))
8438+
{
8439+
DBUG_PRINT("info", ("cached %lu",
8440+
(ulong) log_descriptor.min_file_number));
8441+
if (!is_protected)
8442+
mysql_mutex_unlock(&log_descriptor.purger_lock);
8443+
DBUG_RETURN(log_descriptor.min_file_number);
8444+
}
84428445
}
84438446

84448447
max_file= LSN_FILE_NO(horizon);
8448+
if (!translog_is_file(max_file))
8449+
{
8450+
if (!is_protected)
8451+
mysql_mutex_unlock(&log_descriptor.purger_lock);
8452+
DBUG_RETURN(max_file); /* For compatibility */
8453+
}
84458454

84468455
/* binary search for last file */
8447-
while (min_file != max_file && min_file != (max_file - 1))
8456+
while (min_file < max_file)
84488457
{
84498458
uint test= (min_file + max_file) / 2;
84508459
DBUG_PRINT("info", ("min_file: %u test: %u max_file: %u",
84518460
min_file, test, max_file));
8452-
if (test == max_file)
8453-
test--;
84548461
if (translog_is_file(test))
84558462
max_file= test;
84568463
else
8457-
min_file= test;
8464+
min_file= test+1;
84588465
}
84598466
log_descriptor.min_file_number= max_file;
84608467
if (!is_protected)
@@ -8723,9 +8730,9 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
87238730

87248731
/**
87258732
@brief Purges files by stored min need file in case of
8726-
"ondemend" purge type
8733+
"one demand" purge type
87278734
8728-
@note This function do real work only if it is "ondemend" purge type
8735+
@note This function do real work only if it is "one demand" purge type
87298736
and translog_purge() was called at least once and last time without
87308737
errors
87318738
@@ -8764,13 +8771,14 @@ my_bool translog_purge_at_flush()
87648771

87658772
min_file= translog_first_file(translog_get_horizon(), 1);
87668773
DBUG_ASSERT(min_file != 0); /* log is already started */
8767-
for(i= min_file; i < log_descriptor.min_need_file && rc == 0; i++)
8774+
for(i= min_file; i < log_descriptor.min_need_file ; i++)
87688775
{
87698776
char path[FN_REFLEN], *file_name;
87708777
DBUG_PRINT("info", ("purge file %lu\n", (ulong) i));
87718778
file_name= translog_filename_by_fileno(i, path);
8772-
rc= MY_TEST(mysql_file_delete(key_file_translog,
8779+
rc|= MY_TEST(mysql_file_delete(key_file_translog,
87738780
file_name, MYF(MY_WME)));
8781+
DBUG_ASSERT(rc == 0);
87748782
}
87758783

87768784
mysql_mutex_unlock(&log_descriptor.purger_lock);

0 commit comments

Comments
 (0)