mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -11,6 +11,7 @@
|
|||||||
connection default;
|
connection default;
|
||||||
let $default_db=`select database()`;
|
let $default_db=`select database()`;
|
||||||
let $MYSQLD_DATADIR= `SELECT @@datadir`;
|
let $MYSQLD_DATADIR= `SELECT @@datadir`;
|
||||||
|
let $pid_file=`select @@pid_file`;
|
||||||
|
|
||||||
#it will used at end of test for wait_for_status_var.inc primitive
|
#it will used at end of test for wait_for_status_var.inc primitive
|
||||||
#let $status_var= Threads_connected;
|
#let $status_var= Threads_connected;
|
||||||
@ -23,6 +24,7 @@ wait-maria_empty_logs.inc
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
--source include/mysqladmin_shutdown.inc
|
--source include/mysqladmin_shutdown.inc
|
||||||
|
--source include/wait_until_no_pidfile.inc
|
||||||
|
|
||||||
--disable_warnings
|
--disable_warnings
|
||||||
if (!$mel_keep_control_file)
|
if (!$mel_keep_control_file)
|
||||||
|
30
mysql-test/include/wait_until_no_pidfile.inc
Normal file
30
mysql-test/include/wait_until_no_pidfile.inc
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Include this script after a shutdown to wait until the pid file,
|
||||||
|
# stored in $pid_file, has disappered.
|
||||||
|
|
||||||
|
#--echo $pid_file
|
||||||
|
|
||||||
|
--disable_result_log
|
||||||
|
--disable_query_log
|
||||||
|
# Wait one minute
|
||||||
|
let $counter= 600;
|
||||||
|
while ($counter)
|
||||||
|
{
|
||||||
|
--error 0,1
|
||||||
|
--file_exists $pid_file
|
||||||
|
if (!$errno)
|
||||||
|
{
|
||||||
|
dec $counter;
|
||||||
|
--real_sleep 0.1
|
||||||
|
}
|
||||||
|
if ($errno)
|
||||||
|
{
|
||||||
|
let $counter= 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$errno)
|
||||||
|
{
|
||||||
|
--die Pid file "$pid_file" failed to disappear
|
||||||
|
}
|
||||||
|
|
||||||
|
--enable_query_log
|
||||||
|
--enable_result_log
|
@ -8427,34 +8427,41 @@ my_bool translog_is_file(uint file_no)
|
|||||||
|
|
||||||
static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected)
|
static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected)
|
||||||
{
|
{
|
||||||
uint min_file= 0, max_file;
|
uint min_file= 1, max_file;
|
||||||
DBUG_ENTER("translog_first_file");
|
DBUG_ENTER("translog_first_file");
|
||||||
if (!is_protected)
|
if (!is_protected)
|
||||||
mysql_mutex_lock(&log_descriptor.purger_lock);
|
mysql_mutex_lock(&log_descriptor.purger_lock);
|
||||||
if (log_descriptor.min_file_number &&
|
if (log_descriptor.min_file_number)
|
||||||
translog_is_file(log_descriptor.min_file_number))
|
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("cached %lu",
|
min_file= log_descriptor.min_file_number;
|
||||||
(ulong) log_descriptor.min_file_number));
|
if (translog_is_file(log_descriptor.min_file_number))
|
||||||
if (!is_protected)
|
{
|
||||||
mysql_mutex_unlock(&log_descriptor.purger_lock);
|
DBUG_PRINT("info", ("cached %lu",
|
||||||
DBUG_RETURN(log_descriptor.min_file_number);
|
(ulong) log_descriptor.min_file_number));
|
||||||
|
if (!is_protected)
|
||||||
|
mysql_mutex_unlock(&log_descriptor.purger_lock);
|
||||||
|
DBUG_RETURN(log_descriptor.min_file_number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
max_file= LSN_FILE_NO(horizon);
|
max_file= LSN_FILE_NO(horizon);
|
||||||
|
if (!translog_is_file(max_file))
|
||||||
|
{
|
||||||
|
if (!is_protected)
|
||||||
|
mysql_mutex_unlock(&log_descriptor.purger_lock);
|
||||||
|
DBUG_RETURN(max_file); /* For compatibility */
|
||||||
|
}
|
||||||
|
|
||||||
/* binary search for last file */
|
/* binary search for last file */
|
||||||
while (min_file != max_file && min_file != (max_file - 1))
|
while (min_file < max_file)
|
||||||
{
|
{
|
||||||
uint test= (min_file + max_file) / 2;
|
uint test= (min_file + max_file) / 2;
|
||||||
DBUG_PRINT("info", ("min_file: %u test: %u max_file: %u",
|
DBUG_PRINT("info", ("min_file: %u test: %u max_file: %u",
|
||||||
min_file, test, max_file));
|
min_file, test, max_file));
|
||||||
if (test == max_file)
|
|
||||||
test--;
|
|
||||||
if (translog_is_file(test))
|
if (translog_is_file(test))
|
||||||
max_file= test;
|
max_file= test;
|
||||||
else
|
else
|
||||||
min_file= test;
|
min_file= test+1;
|
||||||
}
|
}
|
||||||
log_descriptor.min_file_number= max_file;
|
log_descriptor.min_file_number= max_file;
|
||||||
if (!is_protected)
|
if (!is_protected)
|
||||||
@ -8723,9 +8730,9 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Purges files by stored min need file in case of
|
@brief Purges files by stored min need file in case of
|
||||||
"ondemend" purge type
|
"one demand" purge type
|
||||||
|
|
||||||
@note This function do real work only if it is "ondemend" purge type
|
@note This function do real work only if it is "one demand" purge type
|
||||||
and translog_purge() was called at least once and last time without
|
and translog_purge() was called at least once and last time without
|
||||||
errors
|
errors
|
||||||
|
|
||||||
@ -8764,13 +8771,14 @@ my_bool translog_purge_at_flush()
|
|||||||
|
|
||||||
min_file= translog_first_file(translog_get_horizon(), 1);
|
min_file= translog_first_file(translog_get_horizon(), 1);
|
||||||
DBUG_ASSERT(min_file != 0); /* log is already started */
|
DBUG_ASSERT(min_file != 0); /* log is already started */
|
||||||
for(i= min_file; i < log_descriptor.min_need_file && rc == 0; i++)
|
for(i= min_file; i < log_descriptor.min_need_file ; i++)
|
||||||
{
|
{
|
||||||
char path[FN_REFLEN], *file_name;
|
char path[FN_REFLEN], *file_name;
|
||||||
DBUG_PRINT("info", ("purge file %lu\n", (ulong) i));
|
DBUG_PRINT("info", ("purge file %lu\n", (ulong) i));
|
||||||
file_name= translog_filename_by_fileno(i, path);
|
file_name= translog_filename_by_fileno(i, path);
|
||||||
rc= MY_TEST(mysql_file_delete(key_file_translog,
|
rc|= MY_TEST(mysql_file_delete(key_file_translog,
|
||||||
file_name, MYF(MY_WME)));
|
file_name, MYF(MY_WME)));
|
||||||
|
DBUG_ASSERT(rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_mutex_unlock(&log_descriptor.purger_lock);
|
mysql_mutex_unlock(&log_descriptor.purger_lock);
|
||||||
|
Reference in New Issue
Block a user