summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <guilhem@gbichot4.local>2007-10-16 16:22:13 +0200
committerunknown <guilhem@gbichot4.local>2007-10-16 16:22:13 +0200
commitf2a675b3dd7304c043680ae4816f850bc13e315e (patch)
tree4516c3e947f298892513996df832b4aa4805b51d
parent694c722b6327a4f468e704e181f6adeb4edf310e (diff)
downloadmariadb-git-f2a675b3dd7304c043680ae4816f850bc13e315e.tar.gz
WL#3072 Maria recovery, cleanups, removing some out-of-date @todos
storage/maria/ma_delete_all.c: comment (@todo gone, nothing we can do) storage/maria/ma_recovery.c: - fail if LOGREC_CREATE_TABLE contains some symlink info (that will be handled in a future version) - don't do buffer overrun when parsing a REDO record - out-of-date @todo
-rw-r--r--storage/maria/ma_delete_all.c9
-rw-r--r--storage/maria/ma_recovery.c61
2 files changed, 42 insertions, 28 deletions
diff --git a/storage/maria/ma_delete_all.c b/storage/maria/ma_delete_all.c
index 556ae5ad095..14dfe8cf7e0 100644
--- a/storage/maria/ma_delete_all.c
+++ b/storage/maria/ma_delete_all.c
@@ -67,6 +67,10 @@ int maria_delete_all_rows(MARIA_HA *info)
log_array, log_data, NULL) ||
translog_flush(lsn)))
goto err;
+ /*
+ If we fail in this function after this point, log and table will be
+ inconsistent.
+ */
}
/*
@@ -113,11 +117,6 @@ err:
int save_errno=my_errno;
VOID(_ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
info->update|=HA_STATE_WRITTEN; /* Buffer changed */
- /**
- @todo RECOVERY if we come here, Recovery may later apply the REDO above,
- which may be wrong. Not fixing it now, as anyway this way of deleting
- rows will have to be re-examined when we have versioning.
- */
allow_break(); /* Allow SIGHUP & SIGINT */
DBUG_RETURN(my_errno=save_errno);
}
diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c
index cf3d2a1db04..765be34be14 100644
--- a/storage/maria/ma_recovery.c
+++ b/storage/maria/ma_recovery.c
@@ -404,7 +404,7 @@ static int display_and_apply_record(const LOG_DESC *log_desc,
return 1;
}
if ((error= (*log_desc->record_execute_in_redo_phase)(rec)))
- tprint(tracef, "Got error when executing redo on record\n");
+ tprint(tracef, "Got error when executing record\n");
return error;
}
@@ -557,10 +557,31 @@ prototype_redo_exec_hook(REDO_CREATE_TABLE)
else /* one or two files absent, or header corrupted... */
tprint(tracef, " can't be opened, probably does not exist");
/* if does not exist, or is older, overwrite it */
- /** @todo symlinks */
ptr= name + strlen(name) + 1;
if ((flags= ptr[0] ? HA_DONT_TOUCH_DATA : 0))
tprint(tracef, ", we will only touch index file");
+ ptr++;
+ kfile_size_before_extension= uint2korr(ptr);
+ ptr+= 2;
+ keystart= uint2korr(ptr);
+ ptr+= 2;
+ uchar *kfile_header= ptr;
+ ptr+= kfile_size_before_extension;
+ /* set create_rename_lsn (for maria_read_log to be idempotent) */
+ lsn_store(kfile_header + sizeof(info->s->state.header) + 2, rec->lsn);
+ /* we also set is_of_horizon, like maria_create() does */
+ lsn_store(kfile_header + sizeof(info->s->state.header) + 2 + LSN_STORE_SIZE,
+ rec->lsn);
+ uchar *data_file_name= ptr;
+ ptr+= strlen(data_file_name) + 1;
+ uchar *index_file_name= ptr;
+ ptr+= strlen(index_file_name) + 1;
+ /** @todo handle symlinks */
+ if (data_file_name[0] || index_file_name[0])
+ {
+ tprint(tracef, ", DATA|INDEX DIRECTORY clauses are not handled\n");
+ goto end;
+ }
fn_format(filename, name, "", MARIA_NAME_IEXT,
(MY_UNPACK_FILENAME |
(flags & HA_DONT_TOUCH_DATA) ? MY_RETURN_REAL_PATH : 0) |
@@ -574,17 +595,7 @@ prototype_redo_exec_hook(REDO_CREATE_TABLE)
tprint(tracef, " Failed to create index file\n");
goto end;
}
- ptr++;
- kfile_size_before_extension= uint2korr(ptr);
- ptr+= 2;
- keystart= uint2korr(ptr);
- ptr+= 2;
- /* set create_rename_lsn (for maria_read_log to be idempotent) */
- lsn_store(ptr + sizeof(info->s->state.header) + 2, rec->lsn);
- /* we also set is_of_horizon, like maria_create() does */
- lsn_store(ptr + sizeof(info->s->state.header) + 2 + LSN_STORE_SIZE,
- rec->lsn);
- if (my_pwrite(kfile, ptr,
+ if (my_pwrite(kfile, kfile_header,
kfile_size_before_extension, 0, MYF(MY_NABP|MY_WME)) ||
my_chsize(kfile, keystart, 0, MYF(MY_WME)))
{
@@ -1621,7 +1632,6 @@ static int run_redo_phase(LSN lsn, enum maria_apply_log_way apply)
len= translog_read_record_header(lsn, &rec);
- /** @todo EOF should be detected */
if (len == RECHEADER_READ_ERROR)
{
tprint(tracef, "Failed to read header of the first record.\n");
@@ -1949,15 +1959,20 @@ static MARIA_HA *get_MARIA_HA_from_REDO_record(const
print_redo_phase_progress(rec->lsn);
sid= fileid_korr(rec->header);
page= page_korr(rec->header + FILEID_STORE_SIZE);
- /**
- @todo RECOVERY BUG
- - for REDO_PURGE_BLOCKS, page is not at this pos
- - for DELETE_ALL, record ends here! buffer overrun!
- Solution: caller should pass a param enum { i_am_about_data_file,
- i_am_about_index_file, none }.
- */
- llstr(page, llbuf);
- tprint(tracef, " For page %s of table of short id %u", llbuf, sid);
+ switch(rec->type)
+ {
+ /* not all REDO records have a page: */
+ case LOGREC_REDO_INSERT_ROW_HEAD:
+ case LOGREC_REDO_INSERT_ROW_TAIL:
+ case LOGREC_REDO_PURGE_ROW_HEAD:
+ case LOGREC_REDO_PURGE_ROW_TAIL:
+ llstr(page, llbuf);
+ tprint(tracef, " For page %s of table of short id %u", llbuf, sid);
+ break;
+ /* other types could print their info here too */
+ default:
+ break;
+ }
info= all_tables[sid].info;
if (info == NULL)
{