Commit fabdf6df authored by unknown's avatar unknown

Postmerge fix.


storage/maria/ma_loghandler.c:
  Postmerge fix.
  New state of the log added to proicess correctly shutdown.
storage/maria/ma_loghandler.h:
  New state of the log added to proicess correctly shutdown.
parent 98a2c5e3
...@@ -59,7 +59,7 @@ void maria_end(void) ...@@ -59,7 +59,7 @@ void maria_end(void)
ft_free_stopwords(); ft_free_stopwords();
ma_checkpoint_end(); ma_checkpoint_end();
trnman_destroy(); trnman_destroy();
if (translog_inited) if (translog_status == TRANSLOG_OK)
translog_destroy(); translog_destroy();
end_pagecache(maria_log_pagecache, TRUE); end_pagecache(maria_log_pagecache, TRUE);
end_pagecache(maria_pagecache, TRUE); end_pagecache(maria_pagecache, TRUE);
......
...@@ -688,7 +688,9 @@ static void translog_check_cursor(struct st_buffer_cursor *cursor ...@@ -688,7 +688,9 @@ static void translog_check_cursor(struct st_buffer_cursor *cursor
void translog_stop_writing() void translog_stop_writing()
{ {
translog_status= TRANSLOG_READONLY; translog_status= (translog_status == TRANSLOG_SHUTDOWN ?
TRANSLOG_UNINITED :
TRANSLOG_READONLY);
log_descriptor.open_flags= O_BINARY | O_RDONLY; log_descriptor.open_flags= O_BINARY | O_RDONLY;
} }
...@@ -736,20 +738,22 @@ static File create_logfile_by_number_no_cache(uint32 file_no) ...@@ -736,20 +738,22 @@ static File create_logfile_by_number_no_cache(uint32 file_no)
DBUG_ENTER("create_logfile_by_number_no_cache"); DBUG_ENTER("create_logfile_by_number_no_cache");
if (translog_status != TRANSLOG_OK) if (translog_status != TRANSLOG_OK)
return -1; DBUG_RETURN(-1);
/* TODO: add O_DIRECT to open flags (when buffer is aligned) */ /* TODO: add O_DIRECT to open flags (when buffer is aligned) */
if ((file= my_create(translog_filename_by_fileno(file_no, path), if ((file= my_create(translog_filename_by_fileno(file_no, path),
0, O_BINARY | O_RDWR, MYF(MY_WME))) < 0) 0, O_BINARY | O_RDWR, MYF(MY_WME))) < 0)
{ {
UNRECOVERABLE_ERROR(("Error %d during creating file '%s'", errno, path)); DBUG_PRINT("error", ("Error %d during creating file '%s'", errno, path));
translog_stop_writing();
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (sync_log_dir >= TRANSLOG_SYNC_DIR_NEWFILE && if (sync_log_dir >= TRANSLOG_SYNC_DIR_NEWFILE &&
my_sync(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD))) my_sync(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD)))
{ {
UNRECOVERABLE_ERROR(("Error %d during syncing directory '%s'", DBUG_PRINT("error", ("Error %d during syncing directory '%s'",
errno, log_descriptor.directory)); errno, log_descriptor.directory));
translog_stop_writing();
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
DBUG_PRINT("info", ("File: '%s' handler: %d", path, file)); DBUG_PRINT("info", ("File: '%s' handler: %d", path, file));
...@@ -2142,7 +2146,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) ...@@ -2142,7 +2146,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer)
data.addr= &addr; data.addr= &addr;
DBUG_ASSERT(log_descriptor.pagecache->block_size == TRANSLOG_PAGE_SIZE); DBUG_ASSERT(log_descriptor.pagecache->block_size == TRANSLOG_PAGE_SIZE);
DBUG_ASSERT(i + TRANSLOG_PAGE_SIZE <= buffer->size); DBUG_ASSERT(i + TRANSLOG_PAGE_SIZE <= buffer->size);
if (translog_status != TRANSLOG_OK) if (translog_status != TRANSLOG_OK && translog_status != TRANSLOG_SHUTDOWN)
DBUG_RETURN(1); DBUG_RETURN(1);
if (pagecache_inject(log_descriptor.pagecache, if (pagecache_inject(log_descriptor.pagecache,
&file, pg, 3, &file, pg, 3,
...@@ -2853,7 +2857,12 @@ my_bool translog_init_with_table(const char *directory, ...@@ -2853,7 +2857,12 @@ my_bool translog_init_with_table(const char *directory,
uint old_flags= flags; uint old_flags= flags;
TRANSLOG_ADDRESS sure_page, last_page, last_valid_page; TRANSLOG_ADDRESS sure_page, last_page, last_valid_page;
my_bool version_changed= 0; my_bool version_changed= 0;
DBUG_ENTER("translog_init"); DBUG_ENTER("translog_init_with_table");
id_to_share= NULL;
(*init_table_func)();
if (readonly) if (readonly)
log_descriptor.open_flags= O_BINARY | O_RDONLY; log_descriptor.open_flags= O_BINARY | O_RDONLY;
else else
...@@ -2957,9 +2966,12 @@ my_bool translog_init_with_table(const char *directory, ...@@ -2957,9 +2966,12 @@ my_bool translog_init_with_table(const char *directory,
*/ */
logs_found= (last_logno != FILENO_IMPOSSIBLE); logs_found= (last_logno != FILENO_IMPOSSIBLE);
translog_status= (readonly ? TRANSLOG_READONLY : TRANSLOG_OK);
if (logs_found) if (logs_found)
{ {
my_bool pageok; my_bool pageok;
DBUG_PRINT("info", ("log found..."));
/* /*
TODO: scan directory for maria_log.XXXXXXXX files and find TODO: scan directory for maria_log.XXXXXXXX files and find
highest XXXXXXXX & set logs_found highest XXXXXXXX & set logs_found
...@@ -2988,6 +3000,7 @@ my_bool translog_init_with_table(const char *directory, ...@@ -2988,6 +3000,7 @@ my_bool translog_init_with_table(const char *directory,
if (LSN_FILE_NO(last_page) == 1) if (LSN_FILE_NO(last_page) == 1)
{ {
logs_found= 0; /* file #1 has no pages */ logs_found= 0; /* file #1 has no pages */
DBUG_PRINT("info", ("log found. But is is empty => no log assumed"));
} }
else else
{ {
...@@ -3009,6 +3022,7 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3009,6 +3022,7 @@ my_bool translog_init_with_table(const char *directory,
TRANSLOG_ADDRESS current_page= sure_page; TRANSLOG_ADDRESS current_page= sure_page;
my_bool pageok; my_bool pageok;
DBUG_PRINT("info", ("The log is really present"));
DBUG_ASSERT(sure_page <= last_page); DBUG_ASSERT(sure_page <= last_page);
/* TODO: check page size */ /* TODO: check page size */
...@@ -3145,6 +3159,7 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3145,6 +3159,7 @@ my_bool translog_init_with_table(const char *directory,
logs_found, old_log_was_recovered)); logs_found, old_log_was_recovered));
if (!logs_found) if (!logs_found)
{ {
DBUG_PRINT("info", ("The log is not found => we will create new log"));
/* Start new log system from scratch */ /* Start new log system from scratch */
/* Used space */ /* Used space */
log_descriptor.horizon= MAKE_LSN(1, TRANSLOG_PAGE_SIZE); /* header page */ log_descriptor.horizon= MAKE_LSN(1, TRANSLOG_PAGE_SIZE); /* header page */
...@@ -3205,7 +3220,6 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3205,7 +3220,6 @@ my_bool translog_init_with_table(const char *directory,
DBUG_RETURN(1); DBUG_RETURN(1);
id_to_share--; /* min id is 1 */ id_to_share--; /* min id is 1 */
translog_status= (readonly ? TRANSLOG_READONLY : TRANSLOG_OK);
/* Check the last LSN record integrity */ /* Check the last LSN record integrity */
if (logs_found) if (logs_found)
{ {
...@@ -3393,9 +3407,12 @@ void translog_destroy() ...@@ -3393,9 +3407,12 @@ void translog_destroy()
uint i; uint i;
DBUG_ENTER("translog_destroy"); DBUG_ENTER("translog_destroy");
DBUG_ASSERT(translog_inited); DBUG_ASSERT(translog_status == TRANSLOG_OK ||
translog_status == TRANSLOG_READONLY);
translog_lock(); translog_lock();
translog_status= TRANSLOG_UNINITED; translog_status= (translog_status == TRANSLOG_READONLY ?
TRANSLOG_UNINITED :
TRANSLOG_SHUTDOWN);
if (log_descriptor.bc.buffer->file != -1) if (log_descriptor.bc.buffer->file != -1)
translog_finish_page(&log_descriptor.horizon, &log_descriptor.bc); translog_finish_page(&log_descriptor.horizon, &log_descriptor.bc);
translog_unlock(); translog_unlock();
...@@ -3405,6 +3422,7 @@ void translog_destroy() ...@@ -3405,6 +3422,7 @@ void translog_destroy()
struct st_translog_buffer *buffer= log_descriptor.buffers + i; struct st_translog_buffer *buffer= log_descriptor.buffers + i;
translog_buffer_destroy(buffer); translog_buffer_destroy(buffer);
} }
translog_status= TRANSLOG_UNINITED;
/* close files */ /* close files */
for (i= 0; i < OPENED_FILES_NUM; i++) for (i= 0; i < OPENED_FILES_NUM; i++)
...@@ -7188,7 +7206,14 @@ my_bool translog_purge_at_flush() ...@@ -7188,7 +7206,14 @@ my_bool translog_purge_at_flush()
uint32 i, min_file; uint32 i, min_file;
int rc= 0; int rc= 0;
DBUG_ENTER("translog_purge_at_flush"); DBUG_ENTER("translog_purge_at_flush");
DBUG_ASSERT(translog_inited == 1); DBUG_ASSERT(translog_status == TRANSLOG_OK ||
translog_status == TRANSLOG_READONLY);
if (unlikely(translog_status == TRANSLOG_READONLY))
{
DBUG_PRINT("info", ("The log is read onlyu => exit"));
DBUG_RETURN(0);
}
if (log_purge_type != TRANSLOG_PURGE_ONDEMAND) if (log_purge_type != TRANSLOG_PURGE_ONDEMAND)
{ {
......
...@@ -316,7 +316,8 @@ enum enum_translog_status ...@@ -316,7 +316,8 @@ enum enum_translog_status
{ {
TRANSLOG_UNINITED, /* no initialization done or error during initialization */ TRANSLOG_UNINITED, /* no initialization done or error during initialization */
TRANSLOG_OK, /* transaction log is functioning */ TRANSLOG_OK, /* transaction log is functioning */
TRANSLOG_READONLY /* read only mode due to write errors */ TRANSLOG_READONLY, /* read only mode due to write errors */
TRANSLOG_SHUTDOWN /* going to shutdown the loghandler */
}; };
extern enum enum_translog_status translog_status; extern enum enum_translog_status translog_status;
......
...@@ -114,7 +114,7 @@ int main(int argc, char **argv) ...@@ -114,7 +114,7 @@ int main(int argc, char **argv)
TRANSLOG_PAGE_SIZE, MY_WME) == 0 || TRANSLOG_PAGE_SIZE, MY_WME) == 0 ||
translog_init(maria_data_root, TRANSLOG_FILE_SIZE, translog_init(maria_data_root, TRANSLOG_FILE_SIZE,
0, 0, maria_log_pagecache, 0, 0, maria_log_pagecache,
TRANSLOG_DEFAULT_FLAGS))) TRANSLOG_DEFAULT_FLAGS, 0)))
{ {
_ma_check_print_error(&check_param, _ma_check_print_error(&check_param,
"Can't initialize transaction logging. Run " "Can't initialize transaction logging. Run "
......
...@@ -83,7 +83,7 @@ int main(int argc, char **argv) ...@@ -83,7 +83,7 @@ int main(int argc, char **argv)
TRANSLOG_PAGE_SIZE, MY_WME) == 0 || TRANSLOG_PAGE_SIZE, MY_WME) == 0 ||
translog_init(maria_data_root, TRANSLOG_FILE_SIZE, translog_init(maria_data_root, TRANSLOG_FILE_SIZE,
0, 0, maria_log_pagecache, TRANSLOG_DEFAULT_FLAGS, 0, 0, maria_log_pagecache, TRANSLOG_DEFAULT_FLAGS,
opt_only_display)) opt_display_only))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
goto err; goto err;
......
...@@ -27,7 +27,7 @@ static LOG_DESC INIT_LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE= ...@@ -27,7 +27,7 @@ static LOG_DESC INIT_LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE=
"variable2example", LOGREC_NOT_LAST_IN_GROUP, NULL, NULL}; "variable2example", LOGREC_NOT_LAST_IN_GROUP, NULL, NULL};
void example_loghandler_init() void translog_example_table_init()
{ {
int i; int i;
log_record_type_descriptor[LOGREC_FIXED_RECORD_0LSN_EXAMPLE]= log_record_type_descriptor[LOGREC_FIXED_RECORD_0LSN_EXAMPLE]=
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
extern void example_loghandler_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
extern void example_loghandler_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
extern void example_loghandler_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
extern void example_loghandler_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
extern void example_loghandler_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
extern void example_loghandler_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove();
extern void example_loghandler_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
......
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