Commit ad7a172d authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

refs #5500 getting a txnid does not fail


git-svn-id: file:///svn/toku/tokudb@48239 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3e6373c5
...@@ -1138,10 +1138,8 @@ TOKULOGGER toku_txn_logger (TOKUTXN txn) { ...@@ -1138,10 +1138,8 @@ TOKULOGGER toku_txn_logger (TOKUTXN txn) {
return txn ? txn->logger : 0; return txn ? txn->logger : 0;
} }
int toku_txnid2txn (TOKULOGGER logger, TXNID txnid, TOKUTXN *result) { void toku_txnid2txn(TOKULOGGER logger, TXNID txnid, TOKUTXN *result) {
if (logger==NULL) return -1;
toku_txn_manager_id2txn(logger->txn_manager, txnid, result); toku_txn_manager_id2txn(logger->txn_manager, txnid, result);
return 0;
} }
// Find the earliest LSN in a log. No locks are needed. // Find the earliest LSN in a log. No locks are needed.
......
...@@ -89,7 +89,8 @@ TXNID toku_txn_get_txnid (TOKUTXN txn); ...@@ -89,7 +89,8 @@ TXNID toku_txn_get_txnid (TOKUTXN txn);
LSN toku_logger_last_lsn(TOKULOGGER logger); LSN toku_logger_last_lsn(TOKULOGGER logger);
TOKULOGGER toku_txn_logger (TOKUTXN txn); TOKULOGGER toku_txn_logger (TOKUTXN txn);
int toku_txnid2txn (TOKULOGGER logger, TXNID txnid, TOKUTXN *result); void toku_txnid2txn (TOKULOGGER logger, TXNID txnid, TOKUTXN *result);
//int toku_logger_log_checkpoint (TOKULOGGER); //int toku_logger_log_checkpoint (TOKULOGGER);
//int toku_set_func_fsync (int (*fsync_function)(int)); //int toku_set_func_fsync (int (*fsync_function)(int));
int toku_logger_log_archive (TOKULOGGER logger, char ***logs_p, int flags); int toku_logger_log_archive (TOKULOGGER logger, char ***logs_p, int flags);
......
...@@ -461,8 +461,7 @@ recover_transaction(TOKUTXN *txnp, TXNID xid, TXNID parentxid, TOKULOGGER logger ...@@ -461,8 +461,7 @@ recover_transaction(TOKUTXN *txnp, TXNID xid, TXNID parentxid, TOKULOGGER logger
// lookup the parent // lookup the parent
TOKUTXN parent = NULL; TOKUTXN parent = NULL;
if (parentxid != TXNID_NONE) { if (parentxid != TXNID_NONE) {
r = toku_txnid2txn(logger, parentxid, &parent); toku_txnid2txn(logger, parentxid, &parent);
assert(r == 0);
assert(parent!=NULL); assert(parent!=NULL);
} }
...@@ -470,8 +469,7 @@ recover_transaction(TOKUTXN *txnp, TXNID xid, TXNID parentxid, TOKULOGGER logger ...@@ -470,8 +469,7 @@ recover_transaction(TOKUTXN *txnp, TXNID xid, TXNID parentxid, TOKULOGGER logger
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
{ {
//Verify it does not yet exist. //Verify it does not yet exist.
r = toku_txnid2txn(logger, xid, &txn); toku_txnid2txn(logger, xid, &txn);
assert(r == 0);
assert(txn==NULL); assert(txn==NULL);
} }
r = toku_txn_begin_with_xid(parent, &txn, logger, xid, TXN_SNAPSHOT_NONE, NULL, true); r = toku_txn_begin_with_xid(parent, &txn, logger, xid, TXN_SNAPSHOT_NONE, NULL, true);
...@@ -549,8 +547,7 @@ static int recover_xstillopen_internal (TOKUTXN *txnp, ...@@ -549,8 +547,7 @@ static int recover_xstillopen_internal (TOKUTXN *txnp,
case FORWARD_NEWER_CHECKPOINT_END: { case FORWARD_NEWER_CHECKPOINT_END: {
// assert that the transaction exists // assert that the transaction exists
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, xid, &txn); toku_txnid2txn(renv->logger, xid, &txn);
assert(r == 0 && txn != NULL);
r = 0; r = 0;
*txnp = txn; *txnp = txn;
break; break;
...@@ -633,8 +630,7 @@ static int toku_recover_suppress_rollback (struct logtype_suppress_rollback *UU( ...@@ -633,8 +630,7 @@ static int toku_recover_suppress_rollback (struct logtype_suppress_rollback *UU(
if (r==0) { if (r==0) {
//File is open //File is open
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
FT ft = tuple->ft_handle->ft; FT ft = tuple->ft_handle->ft;
toku_ft_suppress_rollbacks(ft, txn); toku_ft_suppress_rollbacks(ft, txn);
...@@ -660,16 +656,13 @@ static int toku_recover_backward_xbegin (struct logtype_xbegin *UU(l), RECOVER_E ...@@ -660,16 +656,13 @@ static int toku_recover_backward_xbegin (struct logtype_xbegin *UU(l), RECOVER_E
} }
static int toku_recover_xcommit (struct logtype_xcommit *l, RECOVER_ENV renv) { static int toku_recover_xcommit (struct logtype_xcommit *l, RECOVER_ENV renv) {
int r;
// find the transaction by transaction id // find the transaction by transaction id
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
// commit the transaction // commit the transaction
r = toku_txn_commit_with_lsn(txn, true, l->lsn, int r = toku_txn_commit_with_lsn(txn, true, l->lsn,
NULL, NULL); NULL, NULL);
assert(r == 0); assert(r == 0);
...@@ -685,12 +678,9 @@ static int toku_recover_backward_xcommit (struct logtype_xcommit *UU(l), RECOVER ...@@ -685,12 +678,9 @@ static int toku_recover_backward_xcommit (struct logtype_xcommit *UU(l), RECOVER
} }
static int toku_recover_xprepare (struct logtype_xprepare *l, RECOVER_ENV renv) { static int toku_recover_xprepare (struct logtype_xprepare *l, RECOVER_ENV renv) {
int r;
// find the transaction by transaction id // find the transaction by transaction id
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
// Save the transaction // Save the transaction
...@@ -711,8 +701,7 @@ static int toku_recover_xabort (struct logtype_xabort *l, RECOVER_ENV renv) { ...@@ -711,8 +701,7 @@ static int toku_recover_xabort (struct logtype_xabort *l, RECOVER_ENV renv) {
// find the transaction by transaction id // find the transaction by transaction id
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
// abort the transaction // abort the transaction
...@@ -735,8 +724,7 @@ static int toku_recover_fcreate (struct logtype_fcreate *l, RECOVER_ENV renv) { ...@@ -735,8 +724,7 @@ static int toku_recover_fcreate (struct logtype_fcreate *l, RECOVER_ENV renv) {
int r; int r;
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
// assert that filenum is closed // assert that filenum is closed
struct file_map_tuple *tuple = NULL; struct file_map_tuple *tuple = NULL;
...@@ -804,8 +792,7 @@ static int toku_recover_change_fdescriptor (struct logtype_change_fdescriptor *l ...@@ -804,8 +792,7 @@ static int toku_recover_change_fdescriptor (struct logtype_change_fdescriptor *l
if (r==0) { if (r==0) {
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
//Maybe do the descriptor (lsn filter) //Maybe do the descriptor (lsn filter)
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
DBT old_descriptor, new_descriptor; DBT old_descriptor, new_descriptor;
toku_fill_dbt( toku_fill_dbt(
&old_descriptor, &old_descriptor,
...@@ -860,8 +847,7 @@ static int toku_recover_backward_fclose (struct logtype_fclose *UU(l), RECOVER_E ...@@ -860,8 +847,7 @@ static int toku_recover_backward_fclose (struct logtype_fclose *UU(l), RECOVER_E
// fdelete is a transactional file delete. // fdelete is a transactional file delete.
static int toku_recover_fdelete (struct logtype_fdelete *l, RECOVER_ENV renv) { static int toku_recover_fdelete (struct logtype_fdelete *l, RECOVER_ENV renv) {
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
int r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn != NULL); assert(txn != NULL);
// if the forward scan in recovery found this file and opened it, we // if the forward scan in recovery found this file and opened it, we
...@@ -869,7 +855,7 @@ static int toku_recover_fdelete (struct logtype_fdelete *l, RECOVER_ENV renv) { ...@@ -869,7 +855,7 @@ static int toku_recover_fdelete (struct logtype_fdelete *l, RECOVER_ENV renv) {
// not found and not opened, we don't need to do anything - the ft // not found and not opened, we don't need to do anything - the ft
// is already gone, so we're happy. // is already gone, so we're happy.
struct file_map_tuple *tuple; struct file_map_tuple *tuple;
r = file_map_find(&renv->fmap, l->filenum, &tuple); int r = file_map_find(&renv->fmap, l->filenum, &tuple);
if (r == 0) { if (r == 0) {
toku_ft_unlink_on_commit(tuple->ft_handle, txn); toku_ft_unlink_on_commit(tuple->ft_handle, txn);
} }
...@@ -884,8 +870,7 @@ static int toku_recover_backward_fdelete (struct logtype_fdelete *UU(l), RECOVER ...@@ -884,8 +870,7 @@ static int toku_recover_backward_fdelete (struct logtype_fdelete *UU(l), RECOVER
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) {
int r; int r;
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
struct file_map_tuple *tuple = NULL; struct file_map_tuple *tuple = NULL;
r = file_map_find(&renv->fmap, l->filenum, &tuple); r = file_map_find(&renv->fmap, l->filenum, &tuple);
...@@ -908,8 +893,7 @@ static int toku_recover_backward_enq_insert (struct logtype_enq_insert *UU(l), R ...@@ -908,8 +893,7 @@ static int toku_recover_backward_enq_insert (struct logtype_enq_insert *UU(l), R
static int toku_recover_enq_insert_no_overwrite (struct logtype_enq_insert_no_overwrite *l, RECOVER_ENV renv) { static int toku_recover_enq_insert_no_overwrite (struct logtype_enq_insert_no_overwrite *l, RECOVER_ENV renv) {
int r; int r;
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
struct file_map_tuple *tuple = NULL; struct file_map_tuple *tuple = NULL;
r = file_map_find(&renv->fmap, l->filenum, &tuple); r = file_map_find(&renv->fmap, l->filenum, &tuple);
...@@ -931,8 +915,7 @@ static int toku_recover_backward_enq_insert_no_overwrite (struct logtype_enq_ins ...@@ -931,8 +915,7 @@ static int toku_recover_backward_enq_insert_no_overwrite (struct logtype_enq_ins
static int toku_recover_enq_delete_any (struct logtype_enq_delete_any *l, RECOVER_ENV renv) { static int toku_recover_enq_delete_any (struct logtype_enq_delete_any *l, RECOVER_ENV renv) {
int r; int r;
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
struct file_map_tuple *tuple = NULL; struct file_map_tuple *tuple = NULL;
r = file_map_find(&renv->fmap, l->filenum, &tuple); r = file_map_find(&renv->fmap, l->filenum, &tuple);
...@@ -953,8 +936,7 @@ static int toku_recover_backward_enq_delete_any (struct logtype_enq_delete_any * ...@@ -953,8 +936,7 @@ static int toku_recover_backward_enq_delete_any (struct logtype_enq_delete_any *
static int toku_recover_enq_insert_multiple (struct logtype_enq_insert_multiple *l, RECOVER_ENV renv) { static int toku_recover_enq_insert_multiple (struct logtype_enq_insert_multiple *l, RECOVER_ENV renv) {
int r; int r;
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
DB *src_db = NULL; DB *src_db = NULL;
bool do_inserts = true; bool do_inserts = true;
...@@ -1014,8 +996,7 @@ static int toku_recover_backward_enq_insert_multiple (struct logtype_enq_insert_ ...@@ -1014,8 +996,7 @@ static int toku_recover_backward_enq_insert_multiple (struct logtype_enq_insert_
static int toku_recover_enq_delete_multiple (struct logtype_enq_delete_multiple *l, RECOVER_ENV renv) { static int toku_recover_enq_delete_multiple (struct logtype_enq_delete_multiple *l, RECOVER_ENV renv) {
int r; int r;
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
DB *src_db = NULL; DB *src_db = NULL;
bool do_deletes = true; bool do_deletes = true;
...@@ -1069,8 +1050,7 @@ static int toku_recover_backward_enq_delete_multiple (struct logtype_enq_delete_ ...@@ -1069,8 +1050,7 @@ static int toku_recover_backward_enq_delete_multiple (struct logtype_enq_delete_
static int toku_recover_enq_update(struct logtype_enq_update *l, RECOVER_ENV renv) { static int toku_recover_enq_update(struct logtype_enq_update *l, RECOVER_ENV renv) {
int r; int r;
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn != NULL); assert(txn != NULL);
struct file_map_tuple *tuple = NULL; struct file_map_tuple *tuple = NULL;
r = file_map_find(&renv->fmap, l->filenum, &tuple); r = file_map_find(&renv->fmap, l->filenum, &tuple);
...@@ -1087,8 +1067,7 @@ static int toku_recover_enq_update(struct logtype_enq_update *l, RECOVER_ENV ren ...@@ -1087,8 +1067,7 @@ static int toku_recover_enq_update(struct logtype_enq_update *l, RECOVER_ENV ren
static int toku_recover_enq_updatebroadcast(struct logtype_enq_updatebroadcast *l, RECOVER_ENV renv) { static int toku_recover_enq_updatebroadcast(struct logtype_enq_updatebroadcast *l, RECOVER_ENV renv) {
int r; int r;
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn != NULL); assert(txn != NULL);
struct file_map_tuple *tuple = NULL; struct file_map_tuple *tuple = NULL;
r = file_map_find(&renv->fmap, l->filenum, &tuple); r = file_map_find(&renv->fmap, l->filenum, &tuple);
...@@ -1144,8 +1123,7 @@ static int toku_recover_backward_shutdown (struct logtype_shutdown *UU(l), RECOV ...@@ -1144,8 +1123,7 @@ static int toku_recover_backward_shutdown (struct logtype_shutdown *UU(l), RECOV
static int toku_recover_load(struct logtype_load *UU(l), RECOVER_ENV UU(renv)) { static int toku_recover_load(struct logtype_load *UU(l), RECOVER_ENV UU(renv)) {
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
int r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
char *new_iname = fixup_fname(&l->new_iname); char *new_iname = fixup_fname(&l->new_iname);
...@@ -1163,8 +1141,7 @@ static int toku_recover_backward_load(struct logtype_load *UU(l), RECOVER_ENV UU ...@@ -1163,8 +1141,7 @@ static int toku_recover_backward_load(struct logtype_load *UU(l), RECOVER_ENV UU
// #2954 // #2954
static int toku_recover_hot_index(struct logtype_hot_index *UU(l), RECOVER_ENV UU(renv)) { static int toku_recover_hot_index(struct logtype_hot_index *UU(l), RECOVER_ENV UU(renv)) {
TOKUTXN txn = NULL; TOKUTXN txn = NULL;
int r = toku_txnid2txn(renv->logger, l->xid, &txn); toku_txnid2txn(renv->logger, l->xid, &txn);
assert(r == 0);
assert(txn!=NULL); assert(txn!=NULL);
// just make an entry in the rollback log // just make an entry in the rollback log
// - set do_log = 0 -> don't write to recovery log // - set do_log = 0 -> don't write to recovery log
......
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