Commit 10bef9f0 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1443

Re-introduce the behavior that rollback_fcreate removes references to fd from lock tree
before deleting the file

This fixes regressions for windows in transaction abort tests

git-svn-id: file:///svn/toku/tokudb@9239 c7de825b-a66e-492c-adef-691d508d4ae1
parent d96f73e7
......@@ -2879,7 +2879,7 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, const char
if (r != 0) goto died0a;
if (did_create) {
mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO;
r = toku_logger_log_fcreate(txn, fname_in_env, mode);
r = toku_logger_log_fcreate(txn, fname_in_env, toku_cachefile_filenum(t->cf), mode);
if (r != 0) goto died_after_open;
t->txnid_that_created_or_locked_when_empty = toku_txn_get_txnid(txn);
}
......
......@@ -544,13 +544,13 @@ int toku_logger_txn_begin (TOKUTXN parent_tokutxn, TOKUTXN *tokutxn, TOKULOGGER
return 0;
}
int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, int mode) {
int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, int mode) {
if (txn==0) return 0;
if (txn->logger->is_panicked) return EINVAL;
BYTESTRING bs = { .len=strlen(fname), .data = toku_strdup_in_rollback(txn, fname) };
int r = toku_log_fcreate (txn->logger, (LSN*)0, 0, toku_txn_get_txnid(txn), bs, mode);
int r = toku_log_fcreate (txn->logger, (LSN*)0, 0, toku_txn_get_txnid(txn), filenum, bs, mode);
if (r!=0) return r;
r = toku_logger_save_rollback_fcreate(txn, toku_txn_get_txnid(txn), bs);
r = toku_logger_save_rollback_fcreate(txn, toku_txn_get_txnid(txn), filenum, bs);
return r;
}
......
......@@ -54,7 +54,7 @@ int toku_logger_txn_rolltmp_raw_count(TOKUTXN, u_int64_t *count);
int toku_logger_txn_begin (TOKUTXN /*parent*/,TOKUTXN *, TOKULOGGER /*logger*/);
int toku_logger_log_fcreate (TOKUTXN, const char */*fname*/, int /*mode*/);
int toku_logger_log_fcreate (TOKUTXN, const char */*fname*/, FILENUM /*filenum*/, int /*mode*/);
int toku_logger_log_fopen (TOKUTXN, const char * /*fname*/, FILENUM);
......
......@@ -41,6 +41,7 @@ int logformat_version_number = 0;
const struct logtype rollbacks[] = {
{"fcreate", 'F', FA{{"TXNID", "xid", 0},
{"FILENUM", "filenum", 0},
{"BYTESTRING", "fname", 0},
NULLFIELD}},
// cmdinsert is used to insert a key-value pair into a NODUP DB. For rollback we don't need the data.
......@@ -97,6 +98,7 @@ const struct logtype logtypes[] = {
NULLFIELD}},
#endif
{"fcreate", 'F', FA{{"TXNID", "txnid", 0},
{"FILENUM", "filenum", 0},
{"BYTESTRING", "fname", 0},
{"u_int32_t", "mode", "0%o"},
NULLFIELD}},
......
......@@ -83,7 +83,7 @@ create_dir_from_file (const char *fname) {
}
static void
toku_recover_fcreate (LSN UU(lsn), TXNID UU(txnid), BYTESTRING fname,u_int32_t mode) {
toku_recover_fcreate (LSN UU(lsn), TXNID UU(txnid), FILENUM UU(filenum), BYTESTRING fname,u_int32_t mode) {
char *fixed_fname = fixup_fname(&fname);
create_dir_from_file(fixed_fname);
int fd = open(fixed_fname, O_CREAT+O_TRUNC+O_WRONLY+O_BINARY, mode);
......
......@@ -15,6 +15,7 @@ typedef void (*YIELDF)(void*);
int
toku_commit_fcreate (TXNID UU(xid),
FILENUM UU(filenum),
BYTESTRING UU(bs_fname),
TOKUTXN UU(txn),
YIELDF UU(yield),
......@@ -25,8 +26,9 @@ toku_commit_fcreate (TXNID UU(xid),
int
toku_rollback_fcreate (TXNID UU(xid),
FILENUM filenum,
BYTESTRING bs_fname,
TOKUTXN UU(txn),
TOKUTXN txn,
YIELDF UU(yield),
void* UU(yield_v))
{
......@@ -36,8 +38,6 @@ toku_rollback_fcreate (TXNID UU(xid),
char full_fname[full_len];
int l = snprintf(full_fname,full_len, "%s/%s", directory, fname);
assert(l<=full_len);
#if 0
// I don't think this is right. fcreate simply creates the file, and doesn't put it in the cache table.
//Remove reference to the fd in the cachetable
CACHEFILE cf;
int r = toku_cachefile_of_filenum(txn->logger->ct, filenum, &cf);
......@@ -45,8 +45,7 @@ toku_rollback_fcreate (TXNID UU(xid),
r = toku_cachefile_redirect_nullfd(cf);
assert(r==0);
}
#endif
int r = unlink(full_fname);
r = unlink(full_fname);
assert(r==0);
r = toku_graceful_delete(full_fname);
assert(r==0);
......
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