Commit a5f4e79d authored by unknown's avatar unknown

WL#3072 Maria Recovery

* added replaying of REDO_REPAIR_TABLE, but disabled it as
mysterious linker errors appear.
* after replaying RENAME/REPAIR, we must bump create_rename_lsn
for idempotency of maria_read_log.


sql/mysqld.cc:
  typo
storage/maria/ma_checkpoint.c:
  silence compiler warning
storage/maria/ma_recovery.c:
  * added replaying of REDO_REPAIR_TABLE, but disabled it as
  mysterious linker errors appear.
  * after replaying RENAME/REPAIR, we must bump create_rename_lsn
  for idempotency of maria_read_log.
parent cec8ac3e
...@@ -6240,7 +6240,7 @@ The minimum value for this variable is 4096.", ...@@ -6240,7 +6240,7 @@ The minimum value for this variable is 4096.",
(uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, (uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
300, 100, ~0L, 0, 100, 0}, 300, 100, ~0L, 0, 100, 0},
{"pagecache_buffer_size", OPT_KEY_BUFFER_SIZE, {"pagecache_buffer_size", OPT_KEY_BUFFER_SIZE,
"The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", "The size of the buffer used for index blocks for Maria tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.",
(uchar**) &maria_pagecache_var.param_buff_size, (uchar**) &maria_pagecache_var.param_buff_size,
(uchar**) 0, 0, (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG, (uchar**) 0, 0, (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG,
KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD, IO_SIZE, 0}, KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD, IO_SIZE, 0},
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
Background page flushing is not used. Background page flushing is not used.
So, needed pagecache functions for doing this flushing are not yet pushed. So, needed pagecache functions for doing this flushing are not yet pushed.
*/ */
#define flush_pagecache_blocks_with_filter(A,B,C,D,E) (((int)D) * 0) #define flush_pagecache_blocks_with_filter(A,B,C,D,E) (int)(((ulong)D) * 0)
/** /**
filter has to return 0, 1 or 2: 0 means "don't flush this page", 1 means filter has to return 0, 1 or 2: 0 means "don't flush this page", 1 means
"flush it", 2 means "don't flush this page and following pages". "flush it", 2 means "don't flush this page and following pages".
......
...@@ -64,6 +64,7 @@ prototype_redo_exec_hook(LONG_TRANSACTION_ID); ...@@ -64,6 +64,7 @@ prototype_redo_exec_hook(LONG_TRANSACTION_ID);
prototype_redo_exec_hook_dummy(CHECKPOINT); prototype_redo_exec_hook_dummy(CHECKPOINT);
prototype_redo_exec_hook(REDO_CREATE_TABLE); prototype_redo_exec_hook(REDO_CREATE_TABLE);
prototype_redo_exec_hook(REDO_RENAME_TABLE); prototype_redo_exec_hook(REDO_RENAME_TABLE);
prototype_redo_exec_hook(REDO_REPAIR_TABLE);
prototype_redo_exec_hook(REDO_DROP_TABLE); prototype_redo_exec_hook(REDO_DROP_TABLE);
prototype_redo_exec_hook(FILE_ID); prototype_redo_exec_hook(FILE_ID);
prototype_redo_exec_hook(REDO_INSERT_ROW_HEAD); prototype_redo_exec_hook(REDO_INSERT_ROW_HEAD);
...@@ -537,6 +538,17 @@ prototype_redo_exec_hook(REDO_RENAME_TABLE) ...@@ -537,6 +538,17 @@ prototype_redo_exec_hook(REDO_RENAME_TABLE)
fprintf(tracef, "Failed to rename table\n"); fprintf(tracef, "Failed to rename table\n");
goto end; goto end;
} }
info= maria_open(new_name, O_RDONLY, 0);
if (info == NULL)
{
fprintf(tracef, "Failed to open renamed table\n");
goto end;
}
if (_ma_update_create_rename_lsn(info->s, rec->lsn, TRUE))
goto end;
if (maria_close(info))
goto end;
info= NULL;
error= 0; error= 0;
end: end:
fprintf(tracef, "\n"); fprintf(tracef, "\n");
...@@ -546,6 +558,44 @@ end: ...@@ -546,6 +558,44 @@ end:
} }
/*
The record may come from REPAIR, ALTER TABLE ENABLE KEYS, OPTIMIZE.
*/
prototype_redo_exec_hook(REDO_REPAIR_TABLE)
{
int error= 1;
MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec);
if (info == NULL)
return 0;
/*
Otherwise, the mapping is newer than the table, and our record is newer
than the mapping, so we can repair.
*/
fprintf(tracef, " repairing...\n");
/**
@todo RECOVERY BUG fix this:
the maria_chk_init() call causes a heap of linker errors in ha_maria.cc!
*/
#if 0
HA_CHECK param;
maria_chk_init(&param);
param.isam_file_name= info->s->open_file_name;
param.testflag= uint4korr(rec->header);
if (maria_repair(&param, info, info->s->open_file_name,
param.testflag & T_QUICK))
goto end;
if (_ma_update_create_rename_lsn(info->s, rec->lsn, TRUE))
goto end;
error= 0;
end:
return error;
#else
DBUG_ASSERT("fix this table repairing" == NULL);
return error;
#endif
}
prototype_redo_exec_hook(REDO_DROP_TABLE) prototype_redo_exec_hook(REDO_DROP_TABLE)
{ {
char *name; char *name;
...@@ -691,10 +741,6 @@ static int new_table(uint16 sid, const char *name, ...@@ -691,10 +741,6 @@ static int new_table(uint16 sid, const char *name,
{ {
fprintf(tracef, "Table is crashed, can't apply log records to it\n"); fprintf(tracef, "Table is crashed, can't apply log records to it\n");
goto end; goto end;
/*
we should make an exception for REDO_REPAIR_TABLE records: if we want to
execute them, we should not reject the crashed table here.
*/
} }
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
/* check that we're not already using it */ /* check that we're not already using it */
...@@ -748,6 +794,11 @@ static int new_table(uint16 sid, const char *name, ...@@ -748,6 +794,11 @@ static int new_table(uint16 sid, const char *name,
all_tables[sid].info= info; all_tables[sid].info= info;
all_tables[sid].org_kfile= org_kfile; all_tables[sid].org_kfile= org_kfile;
all_tables[sid].org_dfile= org_dfile; all_tables[sid].org_dfile= org_dfile;
/*
We don't set info->s->id, it would be useless (no logging in REDO phase);
if you change that, know that some records in REDO phase call
_ma_update_create_rename_lsn() which resets info->s->id.
*/
fprintf(tracef, ", opened"); fprintf(tracef, ", opened");
error= 0; error= 0;
end: end:
...@@ -1185,6 +1236,7 @@ static int run_redo_phase(LSN lsn, my_bool apply) ...@@ -1185,6 +1236,7 @@ static int run_redo_phase(LSN lsn, my_bool apply)
install_redo_exec_hook(CHECKPOINT); install_redo_exec_hook(CHECKPOINT);
install_redo_exec_hook(REDO_CREATE_TABLE); install_redo_exec_hook(REDO_CREATE_TABLE);
install_redo_exec_hook(REDO_RENAME_TABLE); install_redo_exec_hook(REDO_RENAME_TABLE);
install_redo_exec_hook(REDO_REPAIR_TABLE);
install_redo_exec_hook(REDO_DROP_TABLE); install_redo_exec_hook(REDO_DROP_TABLE);
install_redo_exec_hook(FILE_ID); install_redo_exec_hook(FILE_ID);
install_redo_exec_hook(REDO_INSERT_ROW_HEAD); install_redo_exec_hook(REDO_INSERT_ROW_HEAD);
...@@ -1728,14 +1780,6 @@ static LSN parse_checkpoint_record(LSN lsn) ...@@ -1728,14 +1780,6 @@ static LSN parse_checkpoint_record(LSN lsn)
sanity check on record (did we screw up with all those "ptr+=", did the sanity check on record (did we screw up with all those "ptr+=", did the
checkpoint write code and checkpoint read code go out of sync?). checkpoint write code and checkpoint read code go out of sync?).
*/ */
/**
@todo This probably presently and hopefully detects that
first_log_write_lsn is not written by the checkpoint record; we need
to add MARIA_SHARE::first_log_write_lsn, fill it with a inwrite-hook of
LOGREC_FILE_ID (note that when we write this record we hold intern_lock,
so Checkpoint will read the LSN correctly), and store it in the
checkpoint record.
*/
if (ptr != (log_record_buffer.str + log_record_buffer.length)) if (ptr != (log_record_buffer.str + log_record_buffer.length))
{ {
fprintf(tracef, "checkpoint record corrupted\n"); fprintf(tracef, "checkpoint record corrupted\n");
......
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