Commit af2c25d5 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4768], [t:4829], [t:4834], [t:4511], [t:4513], merge fixes to main

git-svn-id: file:///svn/toku/tokudb@43396 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5c5c5a55
......@@ -176,7 +176,6 @@ static void print_defines (void) {
#endif
printf("#define DB_BADFORMAT -30500\n"); // private tokudb
printf("#define DB_DELETE_ANY %d\n", 1<<16); // private tokudb
printf("#define DB_TRUNCATE_WITHCURSORS %d\n", 1<<17); // private tokudb
dodefine(DB_FIRST);
//dodefine(DB_GET_BOTH); No longer supported #2862.
......@@ -409,13 +408,10 @@ static void print_db_struct (void) {
STRUCT_SETUP(DB, key_range, "int (*%s) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t)");
STRUCT_SETUP(DB, open, "int (*%s) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int)");
STRUCT_SETUP(DB, put, "int (*%s) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t)");
STRUCT_SETUP(DB, remove, "int (*%s) (DB *, const char *, const char *, u_int32_t)");
STRUCT_SETUP(DB, rename, "int (*%s) (DB *, const char *, const char *, const char *, u_int32_t)");
STRUCT_SETUP(DB, set_errfile, "void (*%s) (DB *, FILE*)");
STRUCT_SETUP(DB, set_flags, "int (*%s) (DB *, u_int32_t)");
STRUCT_SETUP(DB, set_pagesize, "int (*%s) (DB *, u_int32_t)");
STRUCT_SETUP(DB, stat, "int (*%s) (DB *, void *, u_int32_t)");
STRUCT_SETUP(DB, truncate, "int (*%s) (DB *, DB_TXN *, u_int32_t *, u_int32_t)");
STRUCT_SETUP(DB, verify, "int (*%s) (DB *, const char *, const char *, FILE *, u_int32_t)");
const char *extra[]={"int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact)",
"int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *)",
......
......@@ -605,23 +605,6 @@ toku_free_blocknum(BLOCK_TABLE bt, BLOCKNUM *bp, struct brt_header * h, BOOL for
unlock_for_blocktable(bt);
}
//fd is protected (must be holding fdlock)
void
toku_block_translation_truncate_unlocked(BLOCK_TABLE bt, int fd, struct brt_header *h) {
assert(bt->is_locked);
u_int64_t allocated_limit_at_start = block_allocator_allocated_limit(bt->block_allocator);
brtheader_set_dirty(h, FALSE);
//Free all regular/data blocks (non reserved)
//Meta data is stored in reserved blocks
struct translation *t = &bt->current;
int64_t i;
for (i=RESERVED_BLOCKNUMS; i<t->smallest_never_used_blocknum.b; i++) {
BLOCKNUM b = make_blocknum(i);
if (t->block_translation[i].size >= 0) free_blocknum_unlocked(bt, &b, h, FALSE);
}
maybe_truncate_cachefile(bt, fd, h, allocated_limit_at_start);
}
//Verify there are no free blocks.
void
toku_block_verify_no_free_blocknums(BLOCK_TABLE bt) {
......
......@@ -33,7 +33,6 @@ void toku_block_translation_note_start_checkpoint_unlocked(BLOCK_TABLE bt);
void toku_block_translation_note_end_checkpoint(BLOCK_TABLE bt, int fd, struct brt_header *h);
void toku_block_translation_note_failed_checkpoint(BLOCK_TABLE bt);
void toku_block_translation_note_skipped_checkpoint(BLOCK_TABLE bt);
void toku_block_translation_truncate_unlocked(BLOCK_TABLE bt, int fd, struct brt_header *h);
void toku_maybe_truncate_cachefile_on_open(BLOCK_TABLE bt, int fd, struct brt_header *h);
//Blocknums
......
......@@ -135,7 +135,7 @@ toku_pin_brtnode(
void *node_v;
*msgs_applied = FALSE;
int r = toku_cachetable_get_and_pin_nonblocking(
brt->cf,
brt->h->cf,
blocknum,
fullhash,
&node_v,
......
......@@ -255,9 +255,7 @@ toku_brt_hot_optimize(BRT brt,
(void) __sync_fetch_and_add(&STATUS_VALUE(BRT_HOT_NUM_STARTED), 1);
{
toku_cachetable_call_ydb_lock(brt->h->cf);
toku_brt_header_note_hot_begin(brt);
toku_cachetable_call_ydb_unlock(brt->h->cf);
}
// Higher level logic prevents a dictionary from being deleted or
......@@ -356,9 +354,7 @@ toku_brt_hot_optimize(BRT brt,
if (r == 0) { success = true; }
{
toku_cachetable_call_ydb_lock(brt->h->cf);
toku_brt_header_note_hot_complete(brt, success, msn_at_start_of_hot);
toku_cachetable_call_ydb_unlock(brt->h->cf);
}
if (success) {
......
......@@ -391,7 +391,8 @@ struct brt_header {
TXNID txnid_that_suppressed_recovery_logs;
TXNID root_xid_that_created;
struct toku_list live_brts;
struct toku_list zombie_brts;
OMT txns; // transactions that are using this header
bool pinned_by_checkpoint; //Keep this heaer around for checkpoint, like a transaction
brt_compare_func compare_fun;
brt_update_func update_fun;
......@@ -410,31 +411,30 @@ struct brt_header {
MSN highest_unused_msn_for_upgrade;
};
// Copy the descriptor into a temporary variable, and tell DRD that subsequent code happens after reading that pointer.
// In combination with the annotation in toku_update_descriptor, this seems to be enough to convince test_4015 that all is well.
// Otherwise, drd complains that the newly malloc'd descriptor string is touched later by some comparison operation.
static const struct __toku_db zero_db; // it's static, so it's all zeros. icc needs this to be a global
static inline void setup_fake_db (DB *fake_db, DESCRIPTOR orig_desc) {
*fake_db = zero_db;
fake_db->cmp_descriptor = orig_desc;
}
#define FAKE_DB(db, desc) struct __toku_db db; setup_fake_db(&db, (desc))
struct brt {
CACHEFILE cf;
// The header is shared. It is also ephemeral.
struct brt_header *h;
toku_spinlock_t cursors_lock;
struct toku_list cursors;
unsigned int nodesize;
unsigned int basementnodesize;
unsigned int flags;
BOOL did_set_flags;
brt_compare_func compare_fun;
brt_update_func update_fun;
DB *db; // To pass to the compare fun, and close once transactions are done.
OMT txns; // transactions that are using this OMT (note that the transaction checks the cf also)
int pinned_by_checkpoint; //Keep this brt around for checkpoint, like a transaction
int was_closed; //True when this brt was closed, but is being kept around for transactions (or checkpoint).
int (*close_db)(DB*, u_int32_t, bool oplsn_valid, LSN oplsn);
u_int32_t close_flags;
on_redirect_callback redirect_callback;;
void* redirect_callback_extra;
struct toku_list live_brt_link;
struct toku_list zombie_brt_link;
};
// FIXME needs toku prefix
......@@ -963,7 +963,7 @@ void brtnode_put_cmd (
OMT live_root_txns
);
void toku_reset_root_xid_that_created(BRT brt, TXNID new_root_xid_that_created);
void toku_reset_root_xid_that_created(struct brt_header* h, TXNID new_root_xid_that_created);
// Reset the root_xid_that_created field to the given value.
// This redefines which xid created the dictionary.
void toku_flusher_thread_set_callback(void (*callback_f)(int, void*), void* extra);
......
......@@ -2892,7 +2892,8 @@ deserialize_brtheader_versioned(int fd, struct rbuf *rb, struct brt_header **brt
h->panic = 0;
h->panic_string = 0;
toku_list_init(&h->live_brts);
toku_list_init(&h->zombie_brts);
int r = toku_omt_create(&h->txns);
assert_zero(r);
//version MUST be in network order on disk regardless of disk order
h->layout_version_read_from_disk = rbuf_network_int(rb);
......@@ -3039,7 +3040,7 @@ deserialize_brtheader_versioned(int fd, struct rbuf *rb, struct brt_header **brt
// version if it gets written out, we need to write the descriptor in
// the new format (without those bytes) before that happens.
if (version <= BRT_LAYOUT_VERSION_13) {
int r = toku_update_descriptor(h, &h->cmp_descriptor, fd);
r = toku_update_descriptor(h, &h->cmp_descriptor, fd);
if (r != 0) {
errno = r;
e = DS_ERRNO;
......
......@@ -35,7 +35,7 @@ BOOL ignore_if_was_already_open;
int toku_testsetup_leaf(BRT brt, BLOCKNUM *blocknum, int n_children, char **keys, int *keylens) {
BRTNODE node;
assert(testsetup_initialized);
int r = toku_read_brt_header_and_store_in_cachefile(brt, brt->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
int r = toku_read_brt_header_and_store_in_cachefile(brt, brt->h->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
if (r!=0) return r;
toku_create_new_brtnode(brt, &node, 0, n_children);
int i;
......@@ -58,7 +58,7 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *blocknum, int n_child
BRTNODE node;
assert(testsetup_initialized);
assert(n_children<=BRT_FANOUT);
int r = toku_read_brt_header_and_store_in_cachefile(brt, brt->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
int r = toku_read_brt_header_and_store_in_cachefile(brt, brt->h->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
if (r!=0) return r;
toku_create_new_brtnode(brt, &node, height, n_children);
int i;
......@@ -77,7 +77,7 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *blocknum, int n_child
int toku_testsetup_root(BRT brt, BLOCKNUM blocknum) {
assert(testsetup_initialized);
int r = toku_read_brt_header_and_store_in_cachefile(brt, brt->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
int r = toku_read_brt_header_and_store_in_cachefile(brt, brt->h->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
if (r!=0) return r;
brt->h->root_blocknum = blocknum;
return 0;
......@@ -90,8 +90,8 @@ int toku_testsetup_get_sersize(BRT brt, BLOCKNUM diskoff) // Return the size on
struct brtnode_fetch_extra bfe;
fill_bfe_for_full_read(&bfe, brt->h);
int r = toku_cachetable_get_and_pin(
brt->cf, diskoff,
toku_cachetable_hash(brt->cf, diskoff),
brt->h->cf, diskoff,
toku_cachetable_hash(brt->h->cf, diskoff),
&node_v,
NULL,
get_write_callbacks_for_node(brt->h),
......@@ -116,9 +116,9 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
struct brtnode_fetch_extra bfe;
fill_bfe_for_full_read(&bfe, brt->h);
r = toku_cachetable_get_and_pin(
brt->cf,
brt->h->cf,
blocknum,
toku_cachetable_hash(brt->cf, blocknum),
toku_cachetable_hash(brt->h->cf, blocknum),
&node_v,
NULL,
get_write_callbacks_for_node(brt->h),
......@@ -191,9 +191,9 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t
struct brtnode_fetch_extra bfe;
fill_bfe_for_full_read(&bfe, brt->h);
r = toku_cachetable_get_and_pin(
brt->cf,
brt->h->cf,
blocknum,
toku_cachetable_hash(brt->cf, blocknum),
toku_cachetable_hash(brt->h->cf, blocknum),
&node_v,
NULL,
get_write_callbacks_for_node(brt->h),
......
......@@ -18,7 +18,8 @@
static int
compare_pairs (BRT brt, struct kv_pair *a, struct kv_pair *b) {
DBT x,y;
int cmp = brt->compare_fun(brt->db,
FAKE_DB(db, &brt->h->cmp_descriptor);
int cmp = brt->compare_fun(&db,
toku_fill_dbt(&x, kv_pair_key(a), kv_pair_keylen(a)),
toku_fill_dbt(&y, kv_pair_key(b), kv_pair_keylen(b)));
return cmp;
......@@ -27,7 +28,8 @@ compare_pairs (BRT brt, struct kv_pair *a, struct kv_pair *b) {
static int
compare_leafentries (BRT brt, LEAFENTRY a, LEAFENTRY b) {
DBT x,y;
int cmp = brt->compare_fun(brt->db,
FAKE_DB(db, &brt->h->cmp_descriptor);
int cmp = brt->compare_fun(&db,
toku_fill_dbt(&x, le_key(a), le_keylen(a)),
toku_fill_dbt(&y, le_key(b), le_keylen(b)));
return cmp;
......@@ -36,7 +38,8 @@ compare_leafentries (BRT brt, LEAFENTRY a, LEAFENTRY b) {
static int
compare_pair_to_leafentry (BRT brt, struct kv_pair *a, LEAFENTRY b) {
DBT x,y;
int cmp = brt->compare_fun(brt->db,
FAKE_DB(db, &brt->h->cmp_descriptor);
int cmp = brt->compare_fun(&db,
toku_fill_dbt(&x, kv_pair_key(a), kv_pair_keylen(a)),
toku_fill_dbt(&y, le_key(b), le_keylen(b)));
return cmp;
......@@ -45,7 +48,8 @@ compare_pair_to_leafentry (BRT brt, struct kv_pair *a, LEAFENTRY b) {
static int
compare_pair_to_key (BRT brt, struct kv_pair *a, bytevec key, ITEMLEN keylen) {
DBT x, y;
int cmp = brt->compare_fun(brt->db,
FAKE_DB(db, &brt->h->cmp_descriptor);
int cmp = brt->compare_fun(&db,
toku_fill_dbt(&x, kv_pair_key(a), kv_pair_keylen(a)),
toku_fill_dbt(&y, key, keylen));
return cmp;
......@@ -106,7 +110,7 @@ struct count_msgs_extra {
DBT *key;
MSN msn;
FIFO fifo;
DB *cmp_extra;
DESCRIPTOR desc;
brt_compare_func cmp;
};
......@@ -118,7 +122,8 @@ count_msgs(OMTVALUE v, u_int32_t UU(idx), void *ve)
const struct fifo_entry *entry = toku_fifo_get_entry(e->fifo, offset);
DBT dbt;
const DBT *buffer_key = fill_dbt_for_fifo_entry(&dbt, entry);
if (entry->msn.msn == e->msn.msn && e->cmp(e->cmp_extra, e->key, buffer_key) == 0) {
FAKE_DB(db, e->desc);
if (entry->msn.msn == e->msn.msn && e->cmp(&db, e->key, buffer_key) == 0) {
e->count++;
}
return 0;
......@@ -207,7 +212,7 @@ toku_get_node_for_verify(
BRTNODE* nodep
)
{
u_int32_t fullhash = toku_cachetable_hash(brt->cf, blocknum);
u_int32_t fullhash = toku_cachetable_hash(brt->h->cf, blocknum);
struct brtnode_fetch_extra bfe;
fill_bfe_for_full_read(&bfe, brt->h);
toku_pin_brtnode_off_client_thread(
......@@ -312,7 +317,7 @@ toku_verify_brtnode (BRT brt,
DBT keydbt;
struct count_msgs_extra extra = { .count = 0, .key = toku_fill_dbt(&keydbt, key, keylen),
.msn = msn, .fifo = bnc->buffer,
.cmp_extra = brt->db, .cmp = brt->compare_fun };
.desc = &brt->h->cmp_descriptor, .cmp = brt->compare_fun };
extra.count = 0;
toku_omt_iterate(bnc->broadcast_list, count_msgs, &extra);
if (brt_msg_type_applies_all(type) || brt_msg_type_does_nothing(type)) {
......@@ -379,9 +384,9 @@ toku_verify_brtnode (BRT brt,
done:
{
int r = toku_cachetable_unpin(
brt->cf,
brt->h->cf,
node->thisnodename,
toku_cachetable_hash(brt->cf, node->thisnodename),
toku_cachetable_hash(brt->h->cf, node->thisnodename),
CACHETABLE_CLEAN,
make_brtnode_pair_attr(node)
);
......
This diff is collapsed.
......@@ -28,7 +28,7 @@
// When lock_only is true, the callback only does optional lock tree locking.
typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra, bool lock_only);
int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, int basementnodesize, CACHETABLE, TOKUTXN, int(*)(DB *,const DBT*,const DBT*), DB*) __attribute__ ((warn_unused_result));
int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, int basementnodesize, CACHETABLE, TOKUTXN, int(*)(DB *,const DBT*,const DBT*)) __attribute__ ((warn_unused_result));
int toku_brt_change_descriptor(BRT t, const DBT* old_descriptor, const DBT* new_descriptor, BOOL do_log, TOKUTXN txn, BOOL update_cmp_descriptor);
int toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd);
// Note: See the locking discussion in brt.c for toku_brt_change_descriptor and toku_update_descriptor.
......@@ -53,6 +53,8 @@ int toku_brt_get_compression_method(BRT, enum toku_compression_method *) __attri
int toku_brt_set_bt_compare(BRT, brt_compare_func) __attribute__ ((warn_unused_result));
brt_compare_func toku_brt_get_bt_compare (BRT brt);
void toku_brt_set_redirect_callback(BRT brt, on_redirect_callback redir_cb, void* extra);
// How updates (update/insert/deletes) work:
// There are two flavers of upsertdels: Singleton and broadcast.
// When a singleton upsertdel message arrives it contains a key and an extra DBT.
......@@ -98,9 +100,9 @@ int toku_brt_broadcast_update(BRT brt, TOKUTXN txn, const DBT *extra) __attribut
int brt_set_cachetable(BRT, CACHETABLE);
int toku_brt_open(BRT, const char *fname_in_env,
int is_create, int only_create, CACHETABLE ct, TOKUTXN txn, DB *db) __attribute__ ((warn_unused_result));
int is_create, int only_create, CACHETABLE ct, TOKUTXN txn) __attribute__ ((warn_unused_result));
int toku_brt_open_recovery(BRT, const char *fname_in_env, int is_create, int only_create, CACHETABLE ct, TOKUTXN txn,
DB *db, FILENUM use_filenum, LSN max_acceptable_lsn) __attribute__ ((warn_unused_result));
FILENUM use_filenum, LSN max_acceptable_lsn) __attribute__ ((warn_unused_result));
int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags) __attribute__ ((warn_unused_result));
......@@ -149,13 +151,10 @@ int toku_brt_send_insert(BRT brt, DBT *key, DBT *val, XIDS xids, enum brt_msg_ty
int toku_brt_send_delete(BRT brt, DBT *key, XIDS xids) __attribute__ ((warn_unused_result));
int toku_brt_send_commit_any(BRT brt, DBT *key, XIDS xids) __attribute__ ((warn_unused_result));
int toku_brt_db_delay_closed (BRT brt, DB* db, int (*close_db)(DB*, u_int32_t, bool oplsn_valid, LSN oplsn), u_int32_t close_flags, bool oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result));
// Effect: Arrange to really (eventually) close a zombie DB. When it is closed the CLOSE_DB function will be alled.
// Requires: close_db needs to call toku_close_brt to delete the final reference.
int toku_brt_close (BRT brt, bool oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result));
int toku_close_brt_nolsn (BRT, char **error_string) __attribute__ ((warn_unused_result));
int toku_close_brt_lsn (BRT brt, char **error_string, BOOL oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result));
int toku_remove_brtheader (struct brt_header* h, char **error_string, BOOL oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result));
int toku_brt_set_panic(BRT brt, int panic, char *panic_string) __attribute__ ((warn_unused_result));
......@@ -164,20 +163,7 @@ int toku_dump_brt (FILE *,BRT brt) __attribute__ ((warn_unused_result));
void brt_fsync (BRT); /* fsync, but don't clear the caches. */
void brt_flush (BRT); /* fsync and clear the caches. */
int toku_brt_get_cursor_count (BRT brt) __attribute__ ((warn_unused_result));
// get the number of cursors in the tree
// returns: the number of cursors.
// asserts: the number of cursors >= 0.
int toku_brt_flush (BRT brt) __attribute__ ((warn_unused_result));
// effect: the tree's cachefile is flushed
// returns: 0 if success
int toku_brt_truncate (BRT brt) __attribute__ ((warn_unused_result));
// effect: remove everything from the tree
// returns: 0 if success
LSN toku_brt_checkpoint_lsn(BRT brt) __attribute__ ((warn_unused_result));
LSN toku_brt_checkpoint_lsn(struct brt_header* h) __attribute__ ((warn_unused_result));
// create and initialize a cache table
// cachesize is the upper limit on the size of the size of the values in the table
......@@ -226,9 +212,6 @@ int brtenv_checkpoint (BRTENV env) __attribute__ ((warn_unused_result));
extern int toku_brt_do_push_cmd; // control whether push occurs eagerly.
// TODO: Get rid of this
int toku_brt_dbt_set(DBT* key, DBT* key_source);
DICTIONARY_ID toku_brt_get_dictionary_id(BRT);
int toku_brt_height_of_root(BRT, int *height) __attribute__ ((warn_unused_result)); // for an open brt, return the current height.
......@@ -259,8 +242,7 @@ int
toku_brt_stat64 (BRT, TOKUTXN, struct brtstat64_s *stat) __attribute__ ((warn_unused_result));
int toku_brt_init(void (*ydb_lock_callback)(void),
void (*ydb_unlock_callback)(void),
void (*db_set_brt)(DB*,BRT))
void (*ydb_unlock_callback)(void))
__attribute__ ((warn_unused_result));
int toku_brt_destroy(void) __attribute__ ((warn_unused_result));
int toku_brt_serialize_init(void) __attribute__ ((warn_unused_result));
......@@ -287,7 +269,7 @@ void toku_brt_suppress_recovery_logs (BRT brt, TOKUTXN txn);
// implies: txnid_that_created_or_locked_when_empty matches txn
// implies: toku_txn_note_brt(brt, txn) has been called
int toku_brt_zombie_needed (BRT brt) __attribute__ ((warn_unused_result));
int toku_brt_header_needed(struct brt_header* h);
int toku_brt_get_fragmentation(BRT brt, TOKU_DB_FRAGMENTATION report) __attribute__ ((warn_unused_result));
int toku_brt_header_set_panic(struct brt_header *h, int panic, char *panic_string) __attribute__ ((warn_unused_result));
......
......@@ -235,7 +235,7 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp,
CACHETABLE cachetable,
generate_row_for_put_func g,
DB *src_db,
int N, BRT brts[/*N*/],
int N, BRT brts[/*N*/], DB* dbs[/*N*/],
const char *new_fnames_in_env[/*N*/],
brt_compare_func bt_compare_functions[/*N*/],
const char *temp_file_template,
......
......@@ -486,7 +486,7 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp,
CACHETABLE cachetable,
generate_row_for_put_func g,
DB *src_db,
int N, BRT brts[/*N*/],
int N, BRT brts[/*N*/], DB* dbs[/*N*/],
const char *new_fnames_in_env[/*N*/],
brt_compare_func bt_compare_functions[/*N*/],
const char *temp_file_template,
......@@ -528,7 +528,7 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp,
MY_CALLOC_N(N, bl->root_xids_that_created);
for (int i=0; i<N; i++) if (brts[i]) bl->root_xids_that_created[i]=brts[i]->h->root_xid_that_created;
MY_CALLOC_N(N, bl->dbs);
for (int i=0; i<N; i++) if (brts[i]) bl->dbs[i]=brts[i]->db;
for (int i=0; i<N; i++) if (brts[i]) bl->dbs[i]=dbs[i];
MY_CALLOC_N(N, bl->descriptors);
for (int i=0; i<N; i++) if (brts[i]) bl->descriptors[i]=&brts[i]->h->descriptor;
MY_CALLOC_N(N, bl->new_fnames_in_env);
......@@ -594,7 +594,7 @@ int toku_brt_loader_open (/* out */ BRTLOADER *blp,
CACHETABLE cachetable,
generate_row_for_put_func g,
DB *src_db,
int N, BRT brts[/*N*/],
int N, BRT brts[/*N*/], DB* dbs[/*N*/],
const char *new_fnames_in_env[/*N*/],
brt_compare_func bt_compare_functions[/*N*/],
const char *temp_file_template,
......@@ -615,7 +615,7 @@ int toku_brt_loader_open (/* out */ BRTLOADER *blp,
int result = 0;
{
int r = toku_brt_loader_internal_init(blp, cachetable, g, src_db,
N, brts,
N, brts, dbs,
new_fnames_in_env,
bt_compare_functions,
temp_file_template,
......
......@@ -19,7 +19,7 @@ int toku_brt_loader_open (BRTLOADER *bl,
generate_row_for_put_func g,
DB *src_db,
int N,
BRT brts[/*N*/],
BRT brts[/*N*/], DB* dbs[/*N*/],
const char * new_fnames_in_env[/*N*/],
brt_compare_func bt_compare_functions[/*N*/],
const char *temp_file_template,
......
......@@ -241,6 +241,7 @@ typedef const struct brt_msg *BRT_MSG;
typedef int (*brt_compare_func)(DB *, const DBT *, const DBT *);
typedef void (*setval_func)(const DBT *, void *);
typedef int (*brt_update_func)(DB *, const DBT *, const DBT *, const DBT *, setval_func, void *);
typedef void (*on_redirect_callback)(BRT, void*);
#define UU(x) x __attribute__((__unused__))
......
This diff is collapsed.
......@@ -101,10 +101,6 @@ void toku_cachetable_unreserve_filenum (CACHETABLE ct, FILENUM reserved_filenum)
uint64_t toku_cachetable_reserve_memory(CACHETABLE, double fraction);
void toku_cachetable_release_reserved_memory(CACHETABLE, uint64_t);
// Get access to the asynchronous work queue
// Returns: a pointer to the work queue
WORKQUEUE toku_cachetable_get_workqueue (CACHETABLE);
// cachefile operations
void toku_cachefile_get_workqueue_load (CACHEFILE, int *n_in_queue, int *n_threads);
......@@ -521,12 +517,6 @@ void toku_cachetable_set_env_dir(CACHETABLE ct, const char *env_dir);
char * toku_construct_full_name(int count, ...);
char * toku_cachetable_get_fname_in_cwd(CACHETABLE ct, const char * fname_in_env);
void toku_cachetable_set_lock_unlock_for_io (CACHETABLE ct, void (*ydb_lock_callback)(void), void (*ydb_unlock_callback)(void));
// Effect: When we do I/O we may need to release locks (e.g., the ydb lock). These functions release the lock acquire the lock.
void toku_cachetable_call_ydb_lock(CACHEFILE cf);
void toku_cachetable_call_ydb_unlock(CACHEFILE cf);
void cachefile_kibbutz_enq (CACHEFILE cf, void (*f)(void*), void *extra);
// Effect: Add a job to the cachetable's collection of work to do. Note that function f must call remove_background_job()
......
......@@ -36,6 +36,11 @@ int le_cursor_next(LE_CURSOR le_cursor, DBT *le);
// The LE_CURSOR position is intialized to -infinity. Any key comparision with -infinity returns TRUE.
// When the cursor runs off the right edge of the tree, the LE_CURSOR position is set to +infinity. Any key comparision with +infinity
// returns FALSE.
// TODO: review the DB parameter. it probably makes sense to get rid of it
// to reduce complexity. instead, we can get the descriptor from:
// lecursor->brtcursor->brt->h->desc
// or:
// some flavor of toku_brtheader_get_desc() etc
BOOL is_key_right_of_le_cursor(LE_CURSOR le_cursor, const DBT *key, DB *keycompare_db);
#endif
......@@ -138,7 +138,7 @@ struct tokutxn {
time_t starttime; // timestamp in seconds of transaction start
u_int64_t rollentry_raw_count; // the total count of every byte in the transaction and all its children.
OMT open_brts; // a collection of the brts that we touched. Indexed by filenum.
OMT open_brt_headers; // a collection of the brts that we touched. Indexed by filenum.
TXN_SNAPSHOT_TYPE snapshot_type;
OMT live_root_txn_list; // the root txns live when the root ancestor (self if a root) started
XIDS xids; //Represents the xid list
......@@ -188,7 +188,7 @@ struct tokutxn {
struct txninfo {
uint64_t rollentry_raw_count; // the total count of every byte in the transaction and all its children.
uint32_t num_brts;
BRT *open_brts;
struct brt_header** open_brt_headers;
BOOL force_fsync_on_commit; //This transaction NEEDS an fsync once (if) it commits. (commit means root txn)
uint64_t num_rollback_nodes;
uint64_t num_rollentries;
......
......@@ -103,7 +103,7 @@ const struct logtype logtypes[] = {
{"BYTESTRING", "iname", 0}, // pathname of file
NULLFIELD}},
//We do not use a TXNINFO struct since recovery log has
//FILENUMS and TOKUTXN has BRTs (for open_brts)
//FILENUMS and TOKUTXN has BRTs (for open_brt_headers)
{"xstillopen", 's', FA{{"TXNID", "xid", 0},
{"TXNID", "parentxid", 0},
{"u_int64_t", "rollentry_raw_count", 0},
......
......@@ -191,9 +191,9 @@ toku_logger_open_rollback(TOKULOGGER logger, CACHETABLE cachetable, BOOL create)
r = toku_brt_create(&t);
assert_zero(r);
r = toku_brt_open(t, ROLLBACK_CACHEFILE_NAME, create, create, cachetable, NULL_TXN, NULL);
r = toku_brt_open(t, ROLLBACK_CACHEFILE_NAME, create, create, cachetable, NULL_TXN);
assert_zero(r);
logger->rollback_cachefile = t->cf;
logger->rollback_cachefile = t->h->cf;
toku_brtheader_lock(t->h);
//Verify it is empty
assert(!t->h->panic);
......
This diff is collapsed.
......@@ -18,19 +18,13 @@ extern "C" {
#endif
typedef void (*prepared_txn_callback_t)(DB_ENV*, TOKUTXN);
typedef void (*keep_zombie_callback_t)(DB_ENV*, BRT, char *iname, bool oplsn_valid, LSN oplsn);
typedef void (*keep_cachetable_callback_t)(DB_ENV*, CACHETABLE);
typedef int (*setup_db_callback_t)(DB **, DB_ENV *, u_int32_t db_create_flags, BRT, bool /*is_open*/) __attribute__ ((warn_unused_result));
typedef int (*close_db_callback_t)(DB *, bool oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result));
// Run tokudb recovery from the log
// Returns 0 if success
int tokudb_recover (DB_ENV *env,
keep_zombie_callback_t keep_zombie_callback,
prepared_txn_callback_t prepared_txn_callback,
keep_cachetable_callback_t keep_cachetable_callback,
setup_db_callback_t setup_db_callback,
close_db_callback_t close_db_callback,
TOKULOGGER logger,
const char *env_dir, const char *log_dir,
brt_compare_func bt_compare,
......@@ -59,11 +53,7 @@ int toku_recover_lock (const char *lock_dir, int *lockfd);
int toku_recover_unlock(int lockfd);
static const prepared_txn_callback_t NULL_prepared_txn_callback __attribute__((__unused__)) = NULL;
static const keep_zombie_callback_t NULL_keep_zombie_callback __attribute__((__unused__)) = NULL;
static const keep_cachetable_callback_t NULL_keep_cachetable_callback __attribute__((__unused__)) = NULL;
static const setup_db_callback_t NULL_setup_db_callback __attribute__((__unused__)) = NULL;
static const close_db_callback_t NULL_close_db_callback __attribute__((__unused__)) = NULL;
#if defined(__cplusplus) || defined(__cilkplusplus)
};
......
......@@ -133,8 +133,7 @@ toku_rollback_fcreate (FILENUM filenum,
goto done;
}
// file must be open, because the txn that created it opened it and
// noted it, so another client trying to close it would force it
// to become a zombie.
// noted it,
assert(r == 0);
{
(void)toku_cachefile_get_and_pin_fd(cf);
......@@ -162,8 +161,8 @@ done:
static int find_brt_from_filenum (OMTVALUE v, void *filenumvp) {
FILENUM *filenump=filenumvp;
BRT brt = v;
FILENUM thisfnum = toku_cachefile_filenum(brt->cf);
struct brt_header* h = v;
FILENUM thisfnum = toku_cachefile_filenum(h->cf);
if (thisfnum.fileid<filenump->fileid) return -1;
if (thisfnum.fileid>filenump->fileid) return +1;
return 0;
......@@ -191,13 +190,13 @@ static int do_insertion (enum brt_msg_type type, FILENUM filenum, BYTESTRING key
(void)toku_cachefile_get_and_pin_fd(cf);
if (!toku_cachefile_is_dev_null_unlocked(cf)) {
OMTVALUE brtv=NULL;
r = toku_omt_find_zero(txn->open_brts, find_brt_from_filenum, &filenum, &brtv, NULL);
OMTVALUE hv=NULL;
r = toku_omt_find_zero(txn->open_brt_headers, find_brt_from_filenum, &filenum, &hv, NULL);
assert(r==0);
BRT brt = brtv;
struct brt_header* h = hv;
if (oplsn.lsn != 0) { // if we are executing the recovery algorithm
LSN treelsn = toku_brt_checkpoint_lsn(brt);
LSN treelsn = toku_brt_checkpoint_lsn(h);
if (oplsn.lsn <= treelsn.lsn) { // if operation was already applied to tree ...
r = 0; // ... do not apply it again.
goto cleanup;
......@@ -214,10 +213,10 @@ static int do_insertion (enum brt_msg_type type, FILENUM filenum, BYTESTRING key
? toku_fill_dbt(&data_dbt, data->data, data->len)
: toku_init_dbt(&data_dbt) }};
r = toku_brt_root_put_cmd(brt->h, &brtcmd);
r = toku_brt_root_put_cmd(h, &brtcmd);
if (r == 0 && reset_root_xid_that_created) {
TXNID new_root_xid_that_created = xids_get_outermost_xid(xids);
toku_reset_root_xid_that_created(brt, new_root_xid_that_created);
toku_reset_root_xid_that_created(h, new_root_xid_that_created);
}
}
cleanup:
......@@ -614,20 +613,19 @@ toku_rollback_change_fdescriptor(FILENUM filenum,
goto done;
}
// file must be open, because the txn that created it opened it and
// noted it, so another client trying to close it would force it
// to become a zombie.
// noted it,
assert(r==0);
fd = toku_cachefile_get_and_pin_fd(cf);
if (!toku_cachefile_is_dev_null_unlocked(cf)) {
OMTVALUE brtv=NULL;
r = toku_omt_find_zero(txn->open_brts, find_brt_from_filenum, &filenum, &brtv, NULL);
OMTVALUE hv=NULL;
r = toku_omt_find_zero(txn->open_brt_headers, find_brt_from_filenum, &filenum, &hv, NULL);
assert(r==0);
BRT brt = brtv;
struct brt_header* h = hv;
DESCRIPTOR_S d;
toku_fill_dbt(&d.dbt, old_descriptor.data, old_descriptor.len);
r = toku_update_descriptor(brt->h, &d, fd);
r = toku_update_descriptor(h, &d, fd);
assert(r == 0);
}
toku_cachefile_unpin_fd(cf);
......
......@@ -243,37 +243,39 @@ static int find_xid (OMTVALUE v, void *txnv) {
}
static int remove_txn (OMTVALUE brtv, u_int32_t UU(idx), void *txnv)
static int remove_txn (OMTVALUE hv, u_int32_t UU(idx), void *txnv)
// Effect: This function is called on every open BRT that a transaction used.
// This function removes the transaction from that BRT.
{
BRT brt = brtv;
struct brt_header* h = hv;
TOKUTXN txn = txnv;
OMTVALUE txnv_again=NULL;
u_int32_t index;
int r = toku_omt_find_zero(brt->txns, find_xid, txn, &txnv_again, &index);
int r = toku_omt_find_zero(h->txns, find_xid, txn, &txnv_again, &index);
assert(r==0);
assert(txnv_again == txnv);
r = toku_omt_delete_at(brt->txns, index);
r = toku_omt_delete_at(h->txns, index);
assert(r==0);
if (txn->txnid64==brt->h->txnid_that_created_or_locked_when_empty) {
brt->h->txnid_that_created_or_locked_when_empty = TXNID_NONE;
brt->h->root_that_created_or_locked_when_empty = TXNID_NONE;
if (txn->txnid64==h->txnid_that_created_or_locked_when_empty) {
h->txnid_that_created_or_locked_when_empty = TXNID_NONE;
h->root_that_created_or_locked_when_empty = TXNID_NONE;
}
if (txn->txnid64==brt->h->txnid_that_suppressed_recovery_logs) {
brt->h->txnid_that_suppressed_recovery_logs = TXNID_NONE;
if (txn->txnid64==h->txnid_that_suppressed_recovery_logs) {
h->txnid_that_suppressed_recovery_logs = TXNID_NONE;
}
if (!toku_brt_zombie_needed(brt) && brt->was_closed) {
if (!toku_brt_header_needed(h)) {
//Close immediately.
assert(brt->close_db);
r = brt->close_db(brt->db, brt->close_flags, false, ZERO_LSN);
// I have no idea how this error string business works
char *error_string = NULL;
r = toku_remove_brtheader(h, &error_string, false, ZERO_LSN);
lazy_assert_zero(r);
}
return r;
}
// for every BRT in txn, remove it.
static void note_txn_closing (TOKUTXN txn) {
toku_omt_iterate(txn->open_brts, remove_txn, txn);
toku_omt_iterate(txn->open_brt_headers, remove_txn, txn);
}
void toku_rollback_txn_close (TOKUTXN txn) {
......@@ -367,20 +369,20 @@ void *toku_memdup_in_rollback(ROLLBACK_LOG_NODE log, const void *v, size_t len)
return r;
}
static int note_brt_used_in_txns_parent(OMTVALUE brtv, u_int32_t UU(index), void*txnv) {
static int note_brt_used_in_txns_parent(OMTVALUE hv, u_int32_t UU(index), void*txnv) {
TOKUTXN child = txnv;
TOKUTXN parent = child->parent;
BRT brt = brtv;
int r = toku_txn_note_brt(parent, brt);
struct brt_header* h = hv;
int r = toku_txn_note_brt(parent, h);
if (r==0 &&
brt->h->txnid_that_created_or_locked_when_empty == toku_txn_get_txnid(child)) {
h->txnid_that_created_or_locked_when_empty == toku_txn_get_txnid(child)) {
//Pass magic "no rollback needed" flag to parent.
brt->h->txnid_that_created_or_locked_when_empty = toku_txn_get_txnid(parent);
h->txnid_that_created_or_locked_when_empty = toku_txn_get_txnid(parent);
}
if (r==0 &&
brt->h->txnid_that_suppressed_recovery_logs == toku_txn_get_txnid(child)) {
h->txnid_that_suppressed_recovery_logs == toku_txn_get_txnid(child)) {
//Pass magic "no recovery needed" flag to parent.
brt->h->txnid_that_suppressed_recovery_logs = toku_txn_get_txnid(parent);
h->txnid_that_suppressed_recovery_logs = toku_txn_get_txnid(parent);
}
return r;
}
......@@ -452,7 +454,7 @@ int toku_rollback_commit(TOKUTXN txn, YIELDF yield, void*yieldv, LSN lsn) {
}
// Note the open brts, the omts must be merged
r = toku_omt_iterate(txn->open_brts, note_brt_used_in_txns_parent, txn);
r = toku_omt_iterate(txn->open_brt_headers, note_brt_used_in_txns_parent, txn);
assert(r==0);
// Merge the list of headers that must be checkpointed before commit
......@@ -683,24 +685,22 @@ void toku_maybe_spill_rollbacks(TOKUTXN txn, ROLLBACK_LOG_NODE log) {
}
}
static int find_filenum (OMTVALUE v, void *brtv) {
BRT brt = v;
BRT brtfind = brtv;
FILENUM fnum = toku_cachefile_filenum(brt ->cf);
FILENUM fnumfind = toku_cachefile_filenum(brtfind->cf);
static int find_filenum (OMTVALUE v, void *hv) {
struct brt_header* h = v;
struct brt_header* hfind = hv;
FILENUM fnum = toku_cachefile_filenum(h->cf);
FILENUM fnumfind = toku_cachefile_filenum(hfind->cf);
if (fnum.fileid<fnumfind.fileid) return -1;
if (fnum.fileid>fnumfind.fileid) return +1;
if (brt < brtfind) return -1;
if (brt > brtfind) return +1;
return 0;
}
//Notify a transaction that it has touched a brt.
int toku_txn_note_brt (TOKUTXN txn, BRT brt) {
int toku_txn_note_brt (TOKUTXN txn, struct brt_header* h) {
OMTVALUE txnv;
u_int32_t index;
// Does brt already know about transaction txn?
int r = toku_omt_find_zero(brt->txns, find_xid, txn, &txnv, &index);
int r = toku_omt_find_zero(h->txns, find_xid, txn, &txnv, &index);
if (r==0) {
// It's already there.
assert((TOKUTXN)txnv==txn);
......@@ -708,74 +708,10 @@ int toku_txn_note_brt (TOKUTXN txn, BRT brt) {
}
// Otherwise it's not there.
// Insert reference to transaction into brt
r = toku_omt_insert_at(brt->txns, txn, index);
r = toku_omt_insert_at(h->txns, txn, index);
assert(r==0);
// Insert reference to brt into transaction
r = toku_omt_insert(txn->open_brts, brt, find_filenum, brt, 0);
assert(r==0);
return 0;
}
struct swap_brt_extra {
BRT live;
BRT zombie;
};
static int swap_brt (OMTVALUE txnv, u_int32_t UU(idx), void *extra) {
struct swap_brt_extra *info = extra;
TOKUTXN txn = txnv;
OMTVALUE zombie_again=NULL;
u_int32_t index;
int r;
r = toku_txn_note_brt(txn, info->live); //Add new brt.
assert(r==0);
r = toku_omt_find_zero(txn->open_brts, find_filenum, info->zombie, &zombie_again, &index);
assert(r==0);
assert((void*)zombie_again==info->zombie);
r = toku_omt_delete_at(txn->open_brts, index); //Delete old brt.
assert(r==0);
return 0;
}
int toku_txn_note_swap_brt (BRT live, BRT zombie) {
if (zombie->pinned_by_checkpoint) {
//Swap checkpoint responsibility.
assert(!live->pinned_by_checkpoint); //Pin only uses one brt.
live->pinned_by_checkpoint = 1;
zombie->pinned_by_checkpoint = 0;
}
struct swap_brt_extra swap = {.live = live, .zombie = zombie};
int r = toku_omt_iterate(zombie->txns, swap_brt, &swap);
assert(r==0);
toku_omt_clear(zombie->txns);
//Close immediately.
assert(zombie->close_db);
assert(!toku_brt_zombie_needed(zombie));
r = zombie->close_db(zombie->db, zombie->close_flags, false, ZERO_LSN);
return r;
}
static int remove_brt (OMTVALUE txnv, u_int32_t UU(idx), void *brtv) {
TOKUTXN txn = txnv;
BRT brt = brtv;
OMTVALUE brtv_again=NULL;
u_int32_t index;
int r = toku_omt_find_zero(txn->open_brts, find_filenum, brt, &brtv_again, &index);
assert(r==0);
assert((void*)brtv_again==brtv);
r = toku_omt_delete_at(txn->open_brts, index);
assert(r==0);
return 0;
}
int toku_txn_note_close_brt (BRT brt) {
assert(toku_omt_size(brt->txns)==0);
int r = toku_omt_iterate(brt->txns, remove_brt, brt);
r = toku_omt_insert(txn->open_brt_headers, h, find_filenum, h, 0);
assert(r==0);
return 0;
}
......
......@@ -55,9 +55,7 @@ void *toku_memdup_in_rollback(ROLLBACK_LOG_NODE log, const void *v, size_t len);
// if necessary.
void toku_maybe_spill_rollbacks(TOKUTXN txn, ROLLBACK_LOG_NODE log);
int toku_txn_note_brt (TOKUTXN txn, BRT brt);
int toku_txn_note_swap_brt (BRT live, BRT zombie);
int toku_txn_note_close_brt (BRT brt);
int toku_txn_note_brt (TOKUTXN txn, struct brt_header* h);
int toku_logger_txn_rollback_raw_count(TOKUTXN txn, u_int64_t *raw_count);
int toku_find_pair_by_xid (OMTVALUE v, void *txnv);
......
......@@ -14,12 +14,11 @@
static int recovery_main(int argc, const char *const argv[]);
static void dummy(void) {}
static void dummy_set_brt(DB *db UU(), BRT brt UU()) {}
int
main(int argc, const char *const argv[]) {
{
int rr = toku_brt_init(dummy, dummy, dummy_set_brt);
int rr = toku_brt_init(dummy, dummy);
assert(rr==0);
}
int r = recovery_main(argc, argv);
......@@ -43,11 +42,8 @@ int recovery_main (int argc, const char *const argv[]) {
}
int r = tokudb_recover(NULL,
NULL_keep_zombie_callback,
NULL_prepared_txn_callback,
NULL_keep_cachetable_callback,
NULL_setup_db_callback,
NULL_close_db_callback,
NULL_logger,
data_dir, log_dir, NULL, NULL, NULL, NULL, 0);
if (r!=0) {
......
......@@ -34,7 +34,7 @@ static void setup (void) {
int r;
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, ct, NULL_TXN, toku_builtin_compare_fun, (DB*)0); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, ct, NULL_TXN, toku_builtin_compare_fun); assert(r==0);
}
static void toku_shutdown (void) {
......
......@@ -17,7 +17,6 @@ static void test_sub_block(int n) {
const int basementnodesize = 128*1024;
TOKUTXN const null_txn = 0;
DB * const null_db = 0;
int error;
CACHETABLE ct;
......@@ -29,7 +28,7 @@ static void test_sub_block(int n) {
error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(error == 0);
error = toku_open_brt(fname, TRUE, &brt, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun, null_db);
error = toku_open_brt(fname, TRUE, &brt, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun);
assert(error == 0);
// insert keys 0, 1, 2, .. (n-1)
......@@ -48,7 +47,7 @@ static void test_sub_block(int n) {
assert(error == 0);
// verify the brt by walking a cursor through the rows
error = toku_open_brt(fname, FALSE, &brt, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun, null_db);
error = toku_open_brt(fname, FALSE, &brt, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun);
assert(error == 0);
BRT_CURSOR cursor;
......
......@@ -8,7 +8,6 @@
static const char fname[]= __FILE__ ".brt";
static TOKUTXN const null_txn = 0;
static DB * const null_db = 0;
static int
save_data (ITEMLEN UU(keylen), bytevec UU(key), ITEMLEN vallen, bytevec val, void *v, bool lock_only) {
......@@ -23,8 +22,8 @@ save_data (ITEMLEN UU(keylen), bytevec UU(key), ITEMLEN vallen, bytevec val, voi
// Verify that different cursors return different data items when a DBT is initialized to all zeros (no flags)
// Note: The BRT test used to implement DBTs with per-cursor allocated space, but there isn't any such thing any more
// so this test is a little bit obsolete.
static void test_multiple_brt_cursor_dbts(int n, DB *db) {
if (verbose) printf("test_multiple_brt_cursors:%d %p\n", n, db);
static void test_multiple_brt_cursor_dbts(int n) {
if (verbose) printf("test_multiple_brt_cursors:%d\n", n);
int r;
CACHETABLE ct;
......@@ -36,7 +35,7 @@ static void test_multiple_brt_cursor_dbts(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, db);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
int i;
......@@ -90,20 +89,17 @@ static void test_multiple_brt_cursor_dbts(int n, DB *db) {
assert(r==0);
}
static void test_brt_cursor(DB *db) {
test_multiple_brt_cursor_dbts(1, db);
test_multiple_brt_cursor_dbts(2, db);
test_multiple_brt_cursor_dbts(3, db);
static void test_brt_cursor(void) {
test_multiple_brt_cursor_dbts(1);
test_multiple_brt_cursor_dbts(2);
test_multiple_brt_cursor_dbts(3);
}
int
test_main (int argc , const char *argv[]) {
default_parse_args(argc, argv);
DB a_db;
DB *db = &a_db;
test_brt_cursor(db);
test_brt_cursor();
if (verbose) printf("test ok\n");
return 0;
}
This diff is collapsed.
......@@ -10,7 +10,6 @@
static TOKUTXN const null_txn = 0;
static DB * const null_db = 0;
static void test_header (void) {
BRT t;
......@@ -22,7 +21,7 @@ static void test_header (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
// now insert some info into the header
struct brt_header *h = t->h;
......@@ -40,7 +39,7 @@ static void test_header (void) {
// Now read dictionary back into memory and examine some header fields
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 0, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
r = toku_open_brt(fname, 0, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
h = t->h;
......
This diff is collapsed.
......@@ -19,7 +19,7 @@ static void test0 (void) {
assert(r==0);
if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__);
unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
//printf("%s:%d test0\n", __FILE__, __LINE__);
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
......
......@@ -18,7 +18,7 @@ static void test1 (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
r = toku_brt_insert(t, toku_fill_dbt(&k, "hello", 6), toku_fill_dbt(&v, "there", 6), null_txn);
assert(r==0);
......
......@@ -18,7 +18,7 @@ static void test2 (int limit) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
if (verbose) printf("%s:%d did setup\n", __FILE__, __LINE__);
assert(r==0);
for (i=0; i<limit; i++) { // 4096
......@@ -30,10 +30,6 @@ static void test2 (int limit) {
assert(r==0);
r = toku_verify_brt(t); assert(r==0);
//printf("%s:%d did insert %d\n", __FILE__, __LINE__, i);
if (0) {
r = toku_brt_flush(t);
assert(r==0);
}
}
if (verbose) printf("%s:%d inserted\n", __FILE__, __LINE__);
r = toku_verify_brt(t); assert(r==0);
......
......@@ -21,7 +21,7 @@ static void test3 (int nodesize, int basementnodesize, int count) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
gettimeofday(&t0, 0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun, null_db);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
for (i=0; i<count; i++) {
char key[100],val[100];
......
......@@ -21,7 +21,7 @@ static void test4 (int nodesize, int count) {
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, nodesize / 8, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, nodesize / 8, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
for (i=0; i<count; i++) {
char key[100],val[100];
int rv = random();
......
......@@ -21,7 +21,7 @@ static void test5 (void) {
for (i=0; i<limit; i++) values[i]=-1;
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
for (i=0; i<limit/2; i++) {
char key[100],val[100];
int rk = random()%limit;
......
......@@ -76,16 +76,18 @@ static void test_extractor(int nrows, int nrowsets, BOOL expect_fail) {
// open the brtloader. this runs the extractor.
const int N = 1;
BRT brts[N];
DB* dbs[N];
const char *fnames[N];
brt_compare_func compares[N];
for (int i = 0; i < N; i++) {
brts[i] = NULL;
dbs[i] = NULL;
fnames[i] = "";
compares[i] = compare_int;
}
BRTLOADER loader;
r = toku_brt_loader_open(&loader, NULL, generate, NULL, N, brts, fnames, compares, "tempXXXXXX", ZERO_LSN, TXNID_NONE);
r = toku_brt_loader_open(&loader, NULL, generate, NULL, N, brts, dbs, fnames, compares, "tempXXXXXX", ZERO_LSN, TXNID_NONE);
assert(r == 0);
struct rowset *rowset[nrowsets];
......
......@@ -88,10 +88,12 @@ static void test_extractor(int nrows, int nrowsets, BOOL expect_fail, const char
// open the brtloader. this runs the extractor.
const int N = 1;
BRT brts[N];
DB* dbs[N];
const char *fnames[N];
brt_compare_func compares[N];
for (int i = 0; i < N; i++) {
brts[i] = NULL;
dbs[i] = NULL;
fnames[i] = "";
compares[i] = compare_int;
}
......@@ -100,7 +102,7 @@ static void test_extractor(int nrows, int nrowsets, BOOL expect_fail, const char
sprintf(temp, "%s/%s", testdir, "tempXXXXXX");
BRTLOADER loader;
r = toku_brt_loader_open(&loader, NULL, generate, NULL, N, brts, fnames, compares, "tempXXXXXX", ZERO_LSN, TXNID_NONE);
r = toku_brt_loader_open(&loader, NULL, generate, NULL, N, brts, dbs, fnames, compares, "tempXXXXXX", ZERO_LSN, TXNID_NONE);
assert(r == 0);
struct rowset *rowset[nrowsets];
......
......@@ -308,10 +308,12 @@ static void test_extractor(int nrows, int nrowsets, const char *testdir) {
// open the brtloader. this runs the extractor.
const int N = 1;
BRT brts[N];
DB* dbs[N];
const char *fnames[N];
brt_compare_func compares[N];
for (int i = 0; i < N; i++) {
brts[i] = NULL;
dbs[i] = NULL;
fnames[i] = "";
compares[i] = compare_int;
}
......@@ -320,7 +322,7 @@ static void test_extractor(int nrows, int nrowsets, const char *testdir) {
sprintf(temp, "%s/%s", testdir, "tempXXXXXX");
BRTLOADER loader;
r = toku_brt_loader_open(&loader, NULL, generate, NULL, N, brts, fnames, compares, temp, ZERO_LSN, TXNID_NONE);
r = toku_brt_loader_open(&loader, NULL, generate, NULL, N, brts, dbs, fnames, compares, temp, ZERO_LSN, TXNID_NONE);
assert(r == 0);
struct rowset *rowset[nrowsets];
......
......@@ -299,6 +299,7 @@ static void test (const char *directory, BOOL is_error) {
BRTLOADER bl;
BRT *XCALLOC_N(N_DEST_DBS, brts);
DB* *XCALLOC_N(N_DEST_DBS, dbs);
const char **XMALLOC_N(N_DEST_DBS, new_fnames_in_env);
for (int i=0; i<N_DEST_DBS; i++) {
char s[100];
......@@ -320,7 +321,7 @@ static void test (const char *directory, BOOL is_error) {
ct,
(generate_row_for_put_func)NULL,
(DB*)NULL,
N_DEST_DBS, brts,
N_DEST_DBS, brts, dbs,
new_fnames_in_env,
bt_compare_functions,
"tempxxxxxx",
......@@ -437,6 +438,7 @@ static void test (const char *directory, BOOL is_error) {
toku_free(fnames);
toku_free(fds);
toku_free(brts);
toku_free(dbs);
toku_free(new_fnames_in_env);
toku_free(bt_compare_functions);
toku_free(lsnp);
......
......@@ -43,10 +43,12 @@ static void test_loader_open(int ndbs) {
// open the brtloader. this runs the extractor.
BRT brts[ndbs];
DB* dbs[ndbs];
const char *fnames[ndbs];
brt_compare_func compares[ndbs];
for (int i = 0; i < ndbs; i++) {
brts[i] = NULL;
dbs[i] = NULL;
fnames[i] = "";
compares[i] = my_compare;
}
......@@ -57,7 +59,7 @@ static void test_loader_open(int ndbs) {
for (i = 0; ; i++) {
set_my_malloc_trigger(i+1);
r = toku_brt_loader_open(&loader, NULL, NULL, NULL, ndbs, brts, fnames, compares, "", ZERO_LSN, TXNID_NONE);
r = toku_brt_loader_open(&loader, NULL, NULL, NULL, ndbs, brts, dbs, fnames, compares, "", ZERO_LSN, TXNID_NONE);
if (r == 0)
break;
}
......
......@@ -52,7 +52,7 @@ static void verify_dbfile(int n, const char *name) {
r = toku_brt_create(&t); assert(r == 0);
r = toku_brt_set_bt_compare(t, compare_ints);
assert(r==0);
r = toku_brt_open(t, name, 0, 0, ct, null_txn, 0); assert(r==0);
r = toku_brt_open(t, name, 0, 0, ct, null_txn); assert(r==0);
if (verbose) traceit("Verifying brt internals");
r = toku_verify_brt(t);
......
......@@ -248,7 +248,7 @@ static void verify_dbfile(int n, int sorted_keys[], const char *sorted_vals[], c
BRT t = NULL;
r = toku_brt_create(&t); assert(r == 0);
r = toku_brt_set_bt_compare(t, compare_ints); assert(r==0);
r = toku_brt_open(t, name, 0, 0, ct, null_txn, 0); assert(r==0);
r = toku_brt_open(t, name, 0, 0, ct, null_txn); assert(r==0);
BRT_CURSOR cursor = NULL;
r = toku_brt_cursor(t, &cursor, NULL, FALSE, FALSE); assert(r == 0);
......
......@@ -86,7 +86,7 @@ run_test (void) {
assert(r==0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -59,7 +59,7 @@ cachetable_test (void) {
assert_zero(r);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -84,7 +84,7 @@ cachetable_test (void) {
r = toku_cachetable_unpin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), CACHETABLE_CLEAN, make_pair_attr(2));
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -80,7 +80,7 @@ cachetable_test (void) {
assert(flush_called);
assert(pf_called);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
......@@ -50,7 +50,7 @@ cachetable_test (void) {
//r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -172,7 +172,7 @@ static void checkpoint_pending(void) {
assert(r == 0);
assert(n_flush == 0 && n_write_me == 0 && n_keep_me == 0);
r = toku_cachefile_close(&cf, 0, FALSE, ZERO_LSN); assert(r == 0 && cf == 0);
r = toku_cachefile_close(&cf, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -107,7 +107,7 @@ cachetable_test (void) {
check_me = FALSE;
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -108,7 +108,7 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -135,7 +135,7 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
assert(r == 0);
assert(n_flush == 0 && n_write_me == 0 && n_keep_me == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 );
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -93,7 +93,7 @@ cachetable_test (void) {
assert(r==0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -93,7 +93,7 @@ cachetable_test (void) {
assert(r==0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -74,7 +74,7 @@ cachetable_test (void) {
toku_cleaner_thread(ct);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
......@@ -126,7 +126,7 @@ run_test (void) {
assert(STATUS_VALUE(CT_SIZE_CACHEPRESSURE) == (uint64_t) expect.cache_pressure_size);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
......@@ -34,7 +34,7 @@ cachetable_test (void) {
assert(r==0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
......@@ -60,7 +60,7 @@ run_test (void) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
......@@ -58,7 +58,7 @@ run_test (void) {
usleep(4000000);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
......@@ -78,7 +78,7 @@ run_test (void) {
assert(my_cleaner_callback_called);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 );
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
......@@ -33,7 +33,7 @@ cachetable_test (void) {
}
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 );
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -92,7 +92,7 @@ cachetable_test (void) {
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(4));
check_flush = FALSE;
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 );
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -143,7 +143,7 @@ cachetable_test (void) {
assert(expected_bytes_to_free == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -171,7 +171,7 @@ cachetable_test (void) {
assert(expected_bytes_to_free == 3);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -131,7 +131,7 @@ cachetable_test (void) {
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(4));
check_flush = FALSE;
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 );
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -97,7 +97,7 @@ cachetable_test (void) {
assert(clone_flush_started && clone_flush_completed);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
......@@ -99,7 +99,7 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -99,7 +99,7 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -79,7 +79,7 @@ cachetable_test (enum cachetable_dirty dirty, BOOL cloneable) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -88,7 +88,7 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -44,7 +44,7 @@ cachetable_count_pinned_test (int n) {
assert(toku_cachefile_count_pinned(f1, 1) == 0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -49,7 +49,7 @@ cachetable_debug_test (int n) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -130,7 +130,7 @@ static void cachetable_eviction_full_test (void) {
// close with the eviction in progress. the close should block until
// all of the reads and writes are complete.
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -144,7 +144,7 @@ static void cachetable_eviction_full_test (void) {
// close with the eviction in progress. the close should block until
// all of the reads and writes are complete.
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -116,7 +116,7 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
assert(r == 0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -143,7 +143,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
assert(r == 0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -43,7 +43,7 @@ cachetable_fd_test (void) {
r = toku_cachefile_of_filenum(ct, fn, &newcf);
assert(r == ENOENT);
r = toku_cachefile_close(&cf, 0, FALSE, ZERO_LSN); assert(r == 0 && cf == 0);
r = toku_cachefile_close(&cf, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -46,7 +46,7 @@ cachetable_test (void) {
assert(r == 0);
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -70,8 +70,8 @@ test_cachetable_def_flush (int n) {
assert(r == 0);
}
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f2, 0, FALSE, ZERO_LSN); assert(r == 0 && f2 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachefile_close(&f2, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -69,7 +69,7 @@ cachetable_getandpin_test (int n) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -45,7 +45,7 @@ run_test (void) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, TRUE, NULL);
foo = FALSE;
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
assert(foo);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -123,7 +123,7 @@ cachetable_test (void) {
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
// close and reopen cachefile so we can do some simple prefetch tests
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
//
// verify that a prefetch of the node will succeed
......@@ -170,7 +170,7 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -388,7 +388,7 @@ cachetable_test (void) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
sum_vals();
......
......@@ -65,7 +65,7 @@ run_test (void) {
assert(r==0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
......
......@@ -147,7 +147,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
assert(r == 0);
assert(n_flush == 0 && n_write_me == 0 && n_keep_me == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -68,7 +68,7 @@ static void cachetable_prefetch_close_leak_test (void) {
// close with the prefetch in progress. the close should block until
// all of the reads and writes are complete.
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -95,7 +95,7 @@ static void cachetable_prefetch_full_test (BOOL partial_fetch) {
// close with the prefetch in progress. the close should block until
// all of the reads and writes are complete.
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -104,7 +104,7 @@ static void cachetable_prefetch_flowcontrol_test (int cachetable_size_limit) {
#endif
char *error_string;
r = toku_cachefile_close(&f1, &error_string, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, &error_string, FALSE, ZERO_LSN); assert(r == 0);
if (verbose) printf("%s:%d 0x%x 0x%x\n", __FUNCTION__, __LINE__,
evicted_keys, (1 << (2*cachetable_size_limit))-1);
assert(evicted_keys == (1 << (2*cachetable_size_limit))-1);
......
......@@ -135,7 +135,7 @@ static void cachetable_prefetch_maybegetandpin_test (BOOL do_partial_fetch) {
assert(r == 0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -61,7 +61,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
assert(r == 0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -71,7 +71,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
assert(r == 0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -521,7 +521,7 @@ cachetable_test (void) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
sum_vals();
......
......@@ -45,7 +45,7 @@ cachetable_put_test (int n) {
r = toku_cachetable_unpin(f1, k, toku_cachetable_hash(f1, k), CACHETABLE_CLEAN, make_pair_attr(1));
assert(r != 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -69,7 +69,7 @@ cachetable_reserve_filenum_test (void) {
assert(fn2.fileid == fn.fileid);
toku_cachetable_unreserve_filenum (ct, fn);
r = toku_cachefile_close(&cf, 0, FALSE, ZERO_LSN); assert(r == 0 && cf == 0);
r = toku_cachefile_close(&cf, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -138,7 +138,7 @@ test_clean (enum cachetable_dirty dirty, BOOL cloneable) {
check_flush = FALSE;
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
......@@ -87,7 +87,7 @@ test_clean (enum cachetable_dirty dirty, BOOL cloneable) {
flush_called = FALSE;
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 );
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
if (flush_expected) assert(flush_called);
}
......
......@@ -66,7 +66,7 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
This diff is collapsed.
This diff is collapsed.
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
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