Commit 2788c919 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#4685 get the hot indexer to work with txn's in the preparing state closes[t:4685]

git-svn-id: file:///svn/toku/tokudb@41614 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7db30802
...@@ -127,14 +127,7 @@ int toku_txn_ignore_add(TOKUTXN txn, FILENUM filenum); ...@@ -127,14 +127,7 @@ int toku_txn_ignore_add(TOKUTXN txn, FILENUM filenum);
int toku_txn_ignore_remove(TOKUTXN txn, FILENUM filenum); int toku_txn_ignore_remove(TOKUTXN txn, FILENUM filenum);
int toku_txn_ignore_contains(TOKUTXN txn, FILENUM filenum); int toku_txn_ignore_contains(TOKUTXN txn, FILENUM filenum);
enum tokutxn_state { #include "txn_state.h"
TOKUTXN_LIVE, // initial txn state
TOKUTXN_PREPARING, // txn is preparing (or prepared)
TOKUTXN_COMMITTING, // txn in the process of committing
TOKUTXN_ABORTING, // txn in the process of aborting
TOKUTXN_RETIRED, // txn no longer exists
};
typedef enum tokutxn_state TOKUTXN_STATE;
TOKUTXN_STATE toku_txn_get_state(TOKUTXN txn); TOKUTXN_STATE toku_txn_get_state(TOKUTXN txn);
......
#if !defined(TOKUTXN_STATE_H)
#define TOKUTXN_STATE_H
// this is a separate file so that the hotindexing tests can see the txn states
enum tokutxn_state {
TOKUTXN_LIVE, // initial txn state
TOKUTXN_PREPARING, // txn is preparing (or prepared)
TOKUTXN_COMMITTING, // txn in the process of committing
TOKUTXN_ABORTING, // txn in the process of aborting
TOKUTXN_RETIRED, // txn no longer exists
};
typedef enum tokutxn_state TOKUTXN_STATE;
#endif
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#ifndef TOKU_INDEXER_INTERNAL_H #ifndef TOKU_INDEXER_INTERNAL_H
#define TOKU_INDEXER_INTERNAL_H #define TOKU_INDEXER_INTERNAL_H
#include "txn_state.h"
// the indexer_commit_keys is an ordered set of keys described by a DBT in the keys array. // the indexer_commit_keys is an ordered set of keys described by a DBT in the keys array.
// the array is a resizeable array with max size "max_keys" and current size "current_keys". // the array is a resizeable array with max size "max_keys" and current size "current_keys".
// the ordered set is used by the hotindex undo function to collect the commit keys. // the ordered set is used by the hotindex undo function to collect the commit keys.
...@@ -42,7 +44,7 @@ struct __toku_indexer_internal { ...@@ -42,7 +44,7 @@ struct __toku_indexer_internal {
// test functions // test functions
int (*undo_do)(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule); int (*undo_do)(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule);
int (*test_xid_state)(DB_INDEXER *indexer, TXNID xid); TOKUTXN_STATE (*test_xid_state)(DB_INDEXER *indexer, TXNID xid);
int (*test_lock_key)(DB_INDEXER *indexer, TXNID xid, DB *hotdb, DBT *key); int (*test_lock_key)(DB_INDEXER *indexer, TXNID xid, DB *hotdb, DBT *key);
int (*test_delete_provisional)(DB_INDEXER *indexer, DB *hotdb, DBT *hotkey, XIDS xids); int (*test_delete_provisional)(DB_INDEXER *indexer, DB *hotdb, DBT *hotkey, XIDS xids);
int (*test_delete_committed)(DB_INDEXER *indexer, DB *hotdb, DBT *hotkey, XIDS xids); int (*test_delete_committed)(DB_INDEXER *indexer, DB *hotdb, DBT *hotkey, XIDS xids);
......
This diff is collapsed.
/* -*- mode: C; c-basic-offset: 4 -*- */
/*
* Copyright (c) 2010-2012 Tokutek Inc. All rights reserved.
* The technology is licensed by the Massachusetts Institute of Technology,
* Rutgers State University of New Jersey, and the Research Foundation of
* State University of New York at Stony Brook under United States of America
* Serial No. 11/760379 and to the patents and/or patent applications resulting from it.
*/
#ident "$Id$"
// test the hotindexer undo do function // test the hotindexer undo do function
// read a description of the live transactions and a leafentry from a test file, run the undo do function, // read a description of the live transactions and a leafentry from a test file, run the undo do function,
// and print out the actions taken by the undo do function while processing the leafentry // and print out the actions taken by the undo do function while processing the leafentry
...@@ -15,10 +25,6 @@ ...@@ -15,10 +25,6 @@
#include "indexer-internal.h" #include "indexer-internal.h"
#include "xids-internal.h" #include "xids-internal.h"
typedef enum {
TOKUTXN_LIVE, TOKUTXN_COMMITTING, TOKUTXN_ABORTING, TOKUTXN_RETIRED,
} TOKUTXN_STATE; // see txn.h
struct txn { struct txn {
TXNID xid; TXNID xid;
TOKUTXN_STATE state; TOKUTXN_STATE state;
...@@ -53,7 +59,7 @@ live_add(struct live *live, TXNID xid, TOKUTXN_STATE state) { ...@@ -53,7 +59,7 @@ live_add(struct live *live, TXNID xid, TOKUTXN_STATE state) {
} }
static int static int
txn_state(struct live *live, TXNID xid) { lookup_txn_state(struct live *live, TXNID xid) {
int r = TOKUTXN_RETIRED; int r = TOKUTXN_RETIRED;
for (int i = 0; i < live->o; i++) { for (int i = 0; i < live->o; i++) {
if (live->txns[i].xid == xid) { if (live->txns[i].xid == xid) {
...@@ -196,10 +202,10 @@ put_callback(DB *dest_db, DB *src_db, DBT *dest_key, DBT *dest_data, const DBT * ...@@ -196,10 +202,10 @@ put_callback(DB *dest_db, DB *src_db, DBT *dest_key, DBT *dest_data, const DBT *
static DB_INDEXER *test_indexer = NULL; static DB_INDEXER *test_indexer = NULL;
static DB *test_hotdb = NULL; static DB *test_hotdb = NULL;
static int static TOKUTXN_STATE
test_xid_state(DB_INDEXER *indexer, TXNID xid) { test_xid_state(DB_INDEXER *indexer, TXNID xid) {
invariant(indexer == test_indexer); invariant(indexer == test_indexer);
int r = txn_state(&live_xids, xid); TOKUTXN_STATE r = lookup_txn_state(&live_xids, xid);
return r; return r;
} }
...@@ -207,7 +213,8 @@ static int ...@@ -207,7 +213,8 @@ static int
test_lock_key(DB_INDEXER *indexer, TXNID xid, DB *hotdb, DBT *key) { test_lock_key(DB_INDEXER *indexer, TXNID xid, DB *hotdb, DBT *key) {
invariant(indexer == test_indexer); invariant(indexer == test_indexer);
invariant(hotdb == test_hotdb); invariant(hotdb == test_hotdb);
invariant(test_xid_state(indexer, xid) == TOKUTXN_LIVE); TOKUTXN_STATE txn_state = test_xid_state(indexer, xid);
invariant(txn_state == TOKUTXN_LIVE || txn_state == TOKUTXN_PREPARING);
printf("lock [%lu] ", xid); printf("lock [%lu] ", xid);
print_dbt(key); print_dbt(key);
printf("\n"); printf("\n");
...@@ -342,6 +349,8 @@ read_test(char *testname, ULE ule) { ...@@ -342,6 +349,8 @@ read_test(char *testname, ULE ule) {
TOKUTXN_STATE state = TOKUTXN_RETIRED; TOKUTXN_STATE state = TOKUTXN_RETIRED;
if (strcmp(fields[2], "live") == 0) if (strcmp(fields[2], "live") == 0)
state = TOKUTXN_LIVE; state = TOKUTXN_LIVE;
else if (strcmp(fields[2], "preparing") == 0)
state = TOKUTXN_PREPARING;
else if (strcmp(fields[2], "committing") == 0) else if (strcmp(fields[2], "committing") == 0)
state = TOKUTXN_COMMITTING; state = TOKUTXN_COMMITTING;
else if (strcmp(fields[2], "aborting") == 0) else if (strcmp(fields[2], "aborting") == 0)
......
...@@ -37,7 +37,7 @@ live <XIDLIST> ...@@ -37,7 +37,7 @@ live <XIDLIST>
the live transaction set is initially empty the live transaction set is initially empty
xid <XID> [live|committing|aborting] xid <XID> [live|preparing|committing|aborting]
== push a delete transaction record onto the leaf entry stack == == push a delete transaction record onto the leaf entry stack ==
delete [committed|provisional] <XID> delete [committed|provisional] <XID>
......
insert_provisional [100] v100 k1
lock [100] v100
xid 100 preparing
key k1
delete committed 0
insert provisional 100 v100
insert_provisional [200] v200 k1
lock [200] v200
delete_provisional [200] v200
lock [200] v200
insert_provisional [200] v201 k1
lock [200] v201
xid 200 preparing
key k1
delete committed 0
insert provisional 200 v200
insert provisional 201 v201
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
tests="" tests=""
verbose=0 verbose=0
valgrind="" valgrind=""
exitcode=0
for arg in $* ; do for arg in $* ; do
if [[ $arg =~ --(.*)=(.*) ]] ; then if [[ $arg =~ --(.*)=(.*) ]] ; then
......
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