mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 06:44:16 +01:00
Closes #2160 closes[t:2160] Implement forward and backward recovery for fdelete.
fopen forward recovery: file missing (ENOENT) is not considered an error. git-svn-id: file:///svn/toku/tokudb.2037b@15693 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
b3df0166e4
commit
86a917a99d
5 changed files with 29 additions and 13 deletions
|
@ -5126,7 +5126,7 @@ int toku_brt_remove_on_commit(TOKUTXN txn, DBT* iname_dbt_p, DBT* iname_within_c
|
|||
}
|
||||
if (r==0)
|
||||
// make entry in recovery log
|
||||
r = toku_logger_log_fdelete(txn, iname, filenum, was_open);
|
||||
r = toku_logger_log_fdelete(txn, iname);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,8 +112,6 @@ const struct logtype logtypes[] = {
|
|||
{"xbegin", 'b', FA{{"TXNID", "parenttxnid", 0},NULLFIELD}},
|
||||
//TODO: #2037 Add dname
|
||||
{"fdelete", 'U', FA{{"TXNID", "txnid", 0},
|
||||
{"u_int8_t", "file_was_open", 0},
|
||||
{"FILENUM", "filenum", 0},
|
||||
{"BYTESTRING", "iname", 0},
|
||||
NULLFIELD}},
|
||||
//TODO: #2037 Add dname
|
||||
|
|
|
@ -575,12 +575,12 @@ int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, u_
|
|||
|
||||
|
||||
// fname is the iname
|
||||
int toku_logger_log_fdelete (TOKUTXN txn, const char *fname, FILENUM filenum, u_int8_t was_open) {
|
||||
int toku_logger_log_fdelete (TOKUTXN txn, const char *fname) {
|
||||
if (txn==0) return 0;
|
||||
if (txn->logger->is_panicked) return EINVAL;
|
||||
BYTESTRING bs = { .len=strlen(fname), .data = (char *) fname };
|
||||
//No fsync.
|
||||
int r = toku_log_fdelete (txn->logger, (LSN*)0, 0, toku_txn_get_txnid(txn), was_open, filenum, bs);
|
||||
int r = toku_log_fdelete (txn->logger, (LSN*)0, 0, toku_txn_get_txnid(txn), bs);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn);
|
|||
int toku_logger_maybe_trim_log(TOKULOGGER logger, LSN oldest_open_lsn);
|
||||
|
||||
int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, u_int32_t mode, u_int32_t flags, DESCRIPTOR descriptor_p);
|
||||
int toku_logger_log_fdelete (TOKUTXN txn, const char *fname, FILENUM filenum, u_int8_t was_open);
|
||||
int toku_logger_log_fdelete (TOKUTXN txn, const char *fname);
|
||||
int toku_logger_log_fopen (TOKUTXN txn, const char * fname, FILENUM filenum, uint32_t treeflags);
|
||||
|
||||
int toku_fread_u_int8_t (FILE *f, u_int8_t *v, struct x1764 *mm, u_int32_t *len);
|
||||
|
|
|
@ -326,6 +326,8 @@ close_brt:;
|
|||
int rr = toku_close_brt(brt, NULL); assert(rr == 0);
|
||||
toku_free(fixedfname);
|
||||
toku_free(fake_db); //Free memory allocated for the fake db.
|
||||
if (r==ENOENT) //Not an error to simply be missing.
|
||||
r = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -378,16 +380,32 @@ static int toku_recover_backward_fcreate (struct logtype_fcreate *UU(l), RECOVER
|
|||
}
|
||||
|
||||
// fdelete is a transactional file delete.
|
||||
static int toku_recover_fdelete (struct logtype_fdelete *UU(l), RECOVER_ENV UU(renv)) {
|
||||
//TODO: #2037
|
||||
//Put entry in rolltmp.
|
||||
assert(FALSE);
|
||||
static int toku_recover_fdelete (struct logtype_fdelete *l, RECOVER_ENV renv) {
|
||||
TOKUTXN txn = NULL;
|
||||
int r = toku_txnid2txn(renv->logger, l->txnid, &txn);
|
||||
assert(r == 0);
|
||||
//TODO: #??? (insert ticket number) bug that could leave orphaned files here.
|
||||
if (txn == NULL)
|
||||
return 0;
|
||||
char *fixediname = fixup_fname(&l->iname);
|
||||
{ //Skip if does not exist.
|
||||
toku_struct_stat buf;
|
||||
r = toku_stat(fixediname, &buf);
|
||||
if (r==-1 && errno==ENOENT)
|
||||
goto cleanup;
|
||||
}
|
||||
DBT iname_dbt;
|
||||
toku_fill_dbt(&iname_dbt, fixediname, strlen(fixediname)+1);
|
||||
r = toku_brt_remove_on_commit(txn, &iname_dbt, &iname_dbt);
|
||||
assert(r==0);
|
||||
cleanup:
|
||||
toku_free(fixediname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int toku_recover_backward_fdelete (struct logtype_fdelete *UU(l), RECOVER_ENV UU(renv)) {
|
||||
//TODO: #2037
|
||||
//Do we do anything here? Perhaps open it?
|
||||
assert(FALSE);
|
||||
// nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int toku_recover_enq_insert (struct logtype_enq_insert *l, RECOVER_ENV renv) {
|
||||
|
|
Loading…
Add table
Reference in a new issue