Commit bc26f652 authored by Yoni Fogel's avatar Yoni Fogel

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
parent a1897cb6
...@@ -5126,7 +5126,7 @@ int toku_brt_remove_on_commit(TOKUTXN txn, DBT* iname_dbt_p, DBT* iname_within_c ...@@ -5126,7 +5126,7 @@ int toku_brt_remove_on_commit(TOKUTXN txn, DBT* iname_dbt_p, DBT* iname_within_c
} }
if (r==0) if (r==0)
// make entry in recovery log // make entry in recovery log
r = toku_logger_log_fdelete(txn, iname, filenum, was_open); r = toku_logger_log_fdelete(txn, iname);
return r; return r;
} }
......
...@@ -112,8 +112,6 @@ const struct logtype logtypes[] = { ...@@ -112,8 +112,6 @@ const struct logtype logtypes[] = {
{"xbegin", 'b', FA{{"TXNID", "parenttxnid", 0},NULLFIELD}}, {"xbegin", 'b', FA{{"TXNID", "parenttxnid", 0},NULLFIELD}},
//TODO: #2037 Add dname //TODO: #2037 Add dname
{"fdelete", 'U', FA{{"TXNID", "txnid", 0}, {"fdelete", 'U', FA{{"TXNID", "txnid", 0},
{"u_int8_t", "file_was_open", 0},
{"FILENUM", "filenum", 0},
{"BYTESTRING", "iname", 0}, {"BYTESTRING", "iname", 0},
NULLFIELD}}, NULLFIELD}},
//TODO: #2037 Add dname //TODO: #2037 Add dname
......
...@@ -575,12 +575,12 @@ int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, u_ ...@@ -575,12 +575,12 @@ int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, u_
// fname is the iname // 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==0) return 0;
if (txn->logger->is_panicked) return EINVAL; if (txn->logger->is_panicked) return EINVAL;
BYTESTRING bs = { .len=strlen(fname), .data = (char *) fname }; BYTESTRING bs = { .len=strlen(fname), .data = (char *) fname };
//No fsync. //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; return r;
} }
......
...@@ -43,7 +43,7 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn); ...@@ -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_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_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_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); 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:; ...@@ -326,6 +326,8 @@ close_brt:;
int rr = toku_close_brt(brt, NULL); assert(rr == 0); int rr = toku_close_brt(brt, NULL); assert(rr == 0);
toku_free(fixedfname); toku_free(fixedfname);
toku_free(fake_db); //Free memory allocated for the fake db. 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; return r;
} }
...@@ -378,16 +380,32 @@ static int toku_recover_backward_fcreate (struct logtype_fcreate *UU(l), RECOVER ...@@ -378,16 +380,32 @@ static int toku_recover_backward_fcreate (struct logtype_fcreate *UU(l), RECOVER
} }
// fdelete is a transactional file delete. // fdelete is a transactional file delete.
static int toku_recover_fdelete (struct logtype_fdelete *UU(l), RECOVER_ENV UU(renv)) { static int toku_recover_fdelete (struct logtype_fdelete *l, RECOVER_ENV renv) {
//TODO: #2037 TOKUTXN txn = NULL;
//Put entry in rolltmp. int r = toku_txnid2txn(renv->logger, l->txnid, &txn);
assert(FALSE); 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)) { static int toku_recover_backward_fdelete (struct logtype_fdelete *UU(l), RECOVER_ENV UU(renv)) {
//TODO: #2037 // nothing
//Do we do anything here? Perhaps open it? return 0;
assert(FALSE);
} }
static int toku_recover_enq_insert (struct logtype_enq_insert *l, RECOVER_ENV renv) { static int toku_recover_enq_insert (struct logtype_enq_insert *l, RECOVER_ENV renv) {
......
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