Commit 60af50f6 authored by unknown's avatar unknown

Merge abelkin@bk-internal.mysql.com:/home/bk/mysql-maria

into  desktop.sanja.is.com.ua:/home/bell/tmp/work-maria-bug35036

parents 86fc80d5 9f59c098
...@@ -388,7 +388,7 @@ sub mtr_report_stats ($) { ...@@ -388,7 +388,7 @@ sub mtr_report_stats ($) {
(/Slave: Can\'t find record in \'user\' Error_code: 1032/ (/Slave: Can\'t find record in \'user\' Error_code: 1032/
)) or )) or
# maria-recovery.test has warning about missing log file # maria-recovery.test has warning about missing log file
/Can't get stat of '.*maria_log.00/ or /File '.*maria_log.000.*' not found \(Errcode: 2\)/ or
# and about marked-corrupted table # and about marked-corrupted table
/Table '.\/mysqltest\/t1' is crashed, skipping it. Please repair it with maria_chk -r/ /Table '.\/mysqltest\/t1' is crashed, skipping it. Please repair it with maria_chk -r/
) )
......
...@@ -888,6 +888,7 @@ static File open_logfile_by_number_no_cache(uint32 file_no) ...@@ -888,6 +888,7 @@ static File open_logfile_by_number_no_cache(uint32 file_no)
@param file_no Number of the log we want to open @param file_no Number of the log we want to open
retval # file descriptor retval # file descriptor
retval NULL file is not opened
*/ */
static TRANSLOG_FILE *get_logfile_by_number(uint32 file_no) static TRANSLOG_FILE *get_logfile_by_number(uint32 file_no)
...@@ -895,12 +896,17 @@ static TRANSLOG_FILE *get_logfile_by_number(uint32 file_no) ...@@ -895,12 +896,17 @@ static TRANSLOG_FILE *get_logfile_by_number(uint32 file_no)
TRANSLOG_FILE *file; TRANSLOG_FILE *file;
DBUG_ENTER("get_logfile_by_number"); DBUG_ENTER("get_logfile_by_number");
rw_rdlock(&log_descriptor.open_files_lock); rw_rdlock(&log_descriptor.open_files_lock);
if (log_descriptor.max_file - file_no >=
log_descriptor.open_files.elements)
{
DBUG_PRINT("info", ("File #%u is not opened", file_no));
DBUG_RETURN(NULL);
}
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 == DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements); log_descriptor.open_files.elements);
DBUG_ASSERT(log_descriptor.max_file >= file_no); DBUG_ASSERT(log_descriptor.max_file >= file_no);
DBUG_ASSERT(log_descriptor.min_file <= file_no); DBUG_ASSERT(log_descriptor.min_file <= file_no);
DBUG_ASSERT(log_descriptor.max_file - file_no <
log_descriptor.open_files.elements);
file= *dynamic_element(&log_descriptor.open_files, file= *dynamic_element(&log_descriptor.open_files,
log_descriptor.max_file - file_no, TRANSLOG_FILE **); log_descriptor.max_file - file_no, TRANSLOG_FILE **);
rw_unlock(&log_descriptor.open_files_lock); rw_unlock(&log_descriptor.open_files_lock);
...@@ -2931,6 +2937,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer, ...@@ -2931,6 +2937,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer,
translog_unlock(); translog_unlock();
} }
file= get_logfile_by_number(file_no); file= get_logfile_by_number(file_no);
DBUG_ASSERT(file != NULL);
buffer= buffer=
(uchar*) pagecache_read(log_descriptor.pagecache, &file->handler, (uchar*) pagecache_read(log_descriptor.pagecache, &file->handler,
LSN_OFFSET(addr) / TRANSLOG_PAGE_SIZE, LSN_OFFSET(addr) / TRANSLOG_PAGE_SIZE,
...@@ -2986,23 +2993,53 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr, ...@@ -2986,23 +2993,53 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
my_bool *last_page_ok, my_bool *last_page_ok,
my_bool no_errors) my_bool no_errors)
{ {
MY_STAT stat_buff, *local_stat;
char path[FN_REFLEN]; char path[FN_REFLEN];
uint32 rec_offset, file_size; uint32 rec_offset;
my_off_t file_size;
uint32 file_no= LSN_FILE_NO(*addr); uint32 file_no= LSN_FILE_NO(*addr);
TRANSLOG_FILE *file;
#ifndef DBUG_OFF
char buff[21];
#endif
DBUG_ENTER("translog_get_last_page_addr"); DBUG_ENTER("translog_get_last_page_addr");
if (!(local_stat= my_stat(translog_filename_by_fileno(file_no, path), if (likely((file= get_logfile_by_number(file_no)) != NULL))
&stat_buff, {
(no_errors ? MYF(0) : MYF(MY_WME))))) /*
This function used only during initialization of loghandler or in
scanner (which mean we need read that part of the log), so the
requested log file have to be opened and can't be freed after
returning pointer on it (file_size).
*/
file_size= my_seek(file->handler.file, 0, SEEK_END, MYF(0));
}
else
{
/*
This branch is used only during very early initialization
when files are not opened.
*/
File fd;
if ((fd= my_open(translog_filename_by_fileno(file_no, path),
O_RDONLY, (no_errors ? MYF(0) : MYF(MY_WME)))) < 0)
{
my_errno= errno;
DBUG_PRINT("error", ("Error %d during opening file #%d",
errno, file_no));
DBUG_RETURN(1);
}
file_size= my_seek(fd, 0, SEEK_END, MYF(0));
my_close(fd, MYF(0));
}
DBUG_PRINT("info", ("File size: %s", llstr(file_size, buff)));
if (file_size == MY_FILEPOS_ERROR)
DBUG_RETURN(1); DBUG_RETURN(1);
DBUG_PRINT("info", ("File size: %lu", (ulong) local_stat->st_size)); DBUG_ASSERT(file_size < ULL(0xffffffff));
file_size= (uint32)local_stat->st_size; /* st_size can be 'long' on Windows*/ if (((uint32)file_size) > TRANSLOG_PAGE_SIZE)
if (file_size > TRANSLOG_PAGE_SIZE)
{ {
rec_offset= (((file_size / TRANSLOG_PAGE_SIZE) - 1) * rec_offset= (((((uint32)file_size) / TRANSLOG_PAGE_SIZE) - 1) *
TRANSLOG_PAGE_SIZE); TRANSLOG_PAGE_SIZE);
*last_page_ok= (file_size == rec_offset + TRANSLOG_PAGE_SIZE); *last_page_ok= (((uint32)file_size) == rec_offset + TRANSLOG_PAGE_SIZE);
} }
else else
{ {
...@@ -3446,9 +3483,13 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3446,9 +3483,13 @@ my_bool translog_init_with_table(const char *directory,
*/ */
TRANSLOG_FILE *file= (TRANSLOG_FILE *)my_malloc(sizeof(TRANSLOG_FILE), TRANSLOG_FILE *file= (TRANSLOG_FILE *)my_malloc(sizeof(TRANSLOG_FILE),
MYF(0)); MYF(0));
compile_time_assert(MY_FILEPOS_ERROR > ULL(0xffffffff));
if (file == NULL || if (file == NULL ||
(file->handler.file= (file->handler.file=
open_logfile_by_number_no_cache(i)) < 0) open_logfile_by_number_no_cache(i)) < 0 ||
my_seek(file->handler.file, 0, SEEK_END, MYF(0)) >=
ULL(0xffffffff))
{ {
int j; int j;
for (j= i - log_descriptor.min_file - 1; j > 0; j--) for (j= i - log_descriptor.min_file - 1; j > 0; j--)
...@@ -7398,6 +7439,7 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn) ...@@ -7398,6 +7439,7 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn)
uint32 fn= LSN_FILE_NO(buffer->offset); uint32 fn= LSN_FILE_NO(buffer->offset);
prev_file= fn; prev_file= fn;
file= get_logfile_by_number(fn); file= get_logfile_by_number(fn);
DBUG_ASSERT(file != NULL);
if (!file->is_sync) if (!file->is_sync)
{ {
current_file_handler++; current_file_handler++;
...@@ -8134,14 +8176,15 @@ static void get_options(int *argc,char ***argv) ...@@ -8134,14 +8176,15 @@ static void get_options(int *argc,char ***argv)
static void dump_header_page(uchar *buff) static void dump_header_page(uchar *buff)
{ {
LOGHANDLER_FILE_INFO desc; LOGHANDLER_FILE_INFO desc;
char strbuff[21];
translog_interpret_file_header(&desc, buff); translog_interpret_file_header(&desc, buff);
printf(" This can be header page:\n" printf(" This can be header page:\n"
" Timestamp: %llu\n" " Timestamp: %s\n"
" Maria log version: %lu\n" " Maria log version: %lu\n"
" Server version: %lu\n" " Server version: %lu\n"
" Server id %lu\n" " Server id %lu\n"
" Page size %lu\n", " Page size %lu\n",
desc.timestamp, llstr(desc.timestamp, strbuff),
desc.maria_version, desc.maria_version,
desc.mysql_version, desc.mysql_version,
desc.server_id, desc.server_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment