@@ -8427,34 +8427,41 @@ my_bool translog_is_file(uint file_no)
8427
8427
8428
8428
static uint32 translog_first_file (TRANSLOG_ADDRESS horizon , int is_protected )
8429
8429
{
8430
- uint min_file = 0 , max_file ;
8430
+ uint min_file = 1 , max_file ;
8431
8431
DBUG_ENTER ("translog_first_file" );
8432
8432
if (!is_protected )
8433
8433
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 )
8436
8435
{
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
+ }
8442
8445
}
8443
8446
8444
8447
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
+ }
8445
8454
8446
8455
/* binary search for last file */
8447
- while (min_file != max_file && min_file != ( max_file - 1 ) )
8456
+ while (min_file < max_file )
8448
8457
{
8449
8458
uint test = (min_file + max_file ) / 2 ;
8450
8459
DBUG_PRINT ("info" , ("min_file: %u test: %u max_file: %u" ,
8451
8460
min_file , test , max_file ));
8452
- if (test == max_file )
8453
- test -- ;
8454
8461
if (translog_is_file (test ))
8455
8462
max_file = test ;
8456
8463
else
8457
- min_file = test ;
8464
+ min_file = test + 1 ;
8458
8465
}
8459
8466
log_descriptor .min_file_number = max_file ;
8460
8467
if (!is_protected )
@@ -8723,9 +8730,9 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
8723
8730
8724
8731
/**
8725
8732
@brief Purges files by stored min need file in case of
8726
- "ondemend " purge type
8733
+ "one demand " purge type
8727
8734
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
8729
8736
and translog_purge() was called at least once and last time without
8730
8737
errors
8731
8738
@@ -8764,13 +8771,14 @@ my_bool translog_purge_at_flush()
8764
8771
8765
8772
min_file = translog_first_file (translog_get_horizon (), 1 );
8766
8773
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 ++ )
8768
8775
{
8769
8776
char path [FN_REFLEN ], * file_name ;
8770
8777
DBUG_PRINT ("info" , ("purge file %lu\n" , (ulong ) i ));
8771
8778
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 ,
8773
8780
file_name , MYF (MY_WME )));
8781
+ DBUG_ASSERT (rc == 0 );
8774
8782
}
8775
8783
8776
8784
mysql_mutex_unlock (& log_descriptor .purger_lock );
0 commit comments