mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 06:44:16 +01:00
[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
This commit is contained in:
parent
581cc5dbb6
commit
357b4981c2
192 changed files with 889 additions and 2740 deletions
|
@ -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)
|
||||
);
|
||||
|
|
897
newbrt/brt.c
897
newbrt/brt.c
File diff suppressed because it is too large
Load diff
38
newbrt/brt.h
38
newbrt/brt.h
|
@ -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__))
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ static inline void ctpair_destroy(PAIR p) {
|
|||
|
||||
// The cachetable is as close to an ENV as we get.
|
||||
// There are 3 locks, must be taken in this order
|
||||
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
|
||||
// openfd_mutex
|
||||
// cachetable_mutex
|
||||
// cachefiles_mutex
|
||||
|
@ -236,14 +237,11 @@ struct cachetable {
|
|||
// minimum period of 1s so if you want
|
||||
// more frequent cleaner runs you must
|
||||
// use this)
|
||||
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
|
||||
toku_pthread_mutex_t openfd_mutex; // make toku_cachetable_openfd() single-threaded
|
||||
OMT reserved_filenums;
|
||||
char *env_dir;
|
||||
|
||||
// For releasing locks during I/O. These are named "ydb_lock_callback" but it could be viewed more generally as being used to release and reacquire locks while I/O is takign place.
|
||||
void (*ydb_lock_callback)(void);
|
||||
void (*ydb_unlock_callback)(void);
|
||||
|
||||
// variables for engine status
|
||||
int64_t size_nonleaf;
|
||||
int64_t size_leaf;
|
||||
|
@ -306,17 +304,18 @@ toku_cachetable_get_status(CACHETABLE ct, CACHETABLE_STATUS statp) {
|
|||
#define END_CRITICAL_REGION {invariant(ct->checkpoint_prohibited > 0); __sync_fetch_and_sub(&ct->checkpoint_prohibited, 1);}
|
||||
|
||||
|
||||
// Lock the cachetable
|
||||
// Lock the cachefiles. Any function that traverses or modifies the
|
||||
// list of cachefiles must hold this lock.
|
||||
static inline void cachefiles_lock(CACHETABLE ct) {
|
||||
int r = toku_pthread_mutex_lock(&ct->cachefiles_mutex); resource_assert_zero(r);
|
||||
}
|
||||
|
||||
// Unlock the cachetable
|
||||
// Unlock the cachefiles
|
||||
static inline void cachefiles_unlock(CACHETABLE ct) {
|
||||
int r = toku_pthread_mutex_unlock(&ct->cachefiles_mutex); resource_assert_zero(r);
|
||||
}
|
||||
|
||||
// Lock the cachetable
|
||||
// Lock the cachetable. Used for a variety of purposes. TODO: like what?
|
||||
static inline void cachetable_lock(CACHETABLE ct __attribute__((unused))) {
|
||||
int r = toku_pthread_mutex_lock(ct->mutex); resource_assert_zero(r);;
|
||||
}
|
||||
|
@ -348,12 +347,6 @@ struct cachefile {
|
|||
CACHEFILE next_in_checkpoint;
|
||||
struct toku_list pairs_for_cachefile; // list of pairs for this cachefile
|
||||
BOOL for_checkpoint; //True if part of the in-progress checkpoint
|
||||
u_int64_t refcount; /* CACHEFILEs are shared. Use a refcount to decide when to really close it.
|
||||
* The reference count is one for every open DB.
|
||||
* Plus one for every commit/rollback record. (It would be harder to keep a count for every open transaction,
|
||||
* because then we'd have to figure out if the transaction was already counted. If we simply use a count for
|
||||
* every record in the transaction, we'll be ok. Hence we use a 64-bit counter to make sure we don't run out.
|
||||
*/
|
||||
BOOL is_closing; /* TRUE if a cachefile is being close/has been closed. */
|
||||
bool is_flushing; // during cachetable_flush_cachefile, this must be
|
||||
// true, to prevent the cleaner thread from messing
|
||||
|
@ -376,9 +369,6 @@ struct cachefile {
|
|||
int (*end_checkpoint_userdata)(CACHEFILE cf, int fd, void *userdata); // after checkpointing cachefiles call this function.
|
||||
int (*note_pin_by_checkpoint)(CACHEFILE cf, void *userdata); // add a reference to the userdata to prevent it from being removed from memory
|
||||
int (*note_unpin_by_checkpoint)(CACHEFILE cf, void *userdata); // add a reference to the userdata to prevent it from being removed from memory
|
||||
toku_pthread_cond_t openfd_wait; // openfd must wait until file is fully closed (purged from cachetable) if file is opened and closed simultaneously
|
||||
toku_pthread_cond_t closefd_wait; // toku_cachefile_of_iname_and_add_reference() must wait until file is fully closed (purged from cachetable) if run while file is being closed.
|
||||
u_int32_t closefd_waiting; // Number of threads waiting on closefd_wait (0 or 1, error otherwise).
|
||||
LSN most_recent_global_checkpoint_that_finished_early;
|
||||
LSN for_local_checkpoint;
|
||||
enum cachefile_checkpoint_state checkpoint_state;
|
||||
|
@ -524,6 +514,7 @@ int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_l
|
|||
toku_init_workers(&ct->wq, &ct->threadpool, 1);
|
||||
toku_init_workers(&ct->checkpoint_wq, &ct->checkpoint_threadpool, 8);
|
||||
ct->mutex = workqueue_lock_ref(&ct->wq);
|
||||
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
|
||||
int r = toku_pthread_mutex_init(&ct->openfd_mutex, NULL); resource_assert_zero(r);
|
||||
r = toku_pthread_mutex_init(&ct->cachefiles_mutex, 0); resource_assert_zero(r);
|
||||
|
||||
|
@ -563,35 +554,6 @@ toku_cachetable_set_env_dir(CACHETABLE ct, const char *env_dir) {
|
|||
ct->env_dir = toku_xstrdup(env_dir);
|
||||
}
|
||||
|
||||
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.
|
||||
{
|
||||
ct->ydb_lock_callback = ydb_lock_callback;
|
||||
ct->ydb_unlock_callback = ydb_unlock_callback;
|
||||
}
|
||||
|
||||
void
|
||||
toku_cachetable_call_ydb_lock(CACHEFILE cf){
|
||||
if (cf->cachetable->ydb_lock_callback) {
|
||||
assert(cf->cachetable->ydb_unlock_callback);
|
||||
cf->cachetable->ydb_lock_callback();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
toku_cachetable_call_ydb_unlock(CACHEFILE cf){
|
||||
if (cf->cachetable->ydb_unlock_callback) cf->cachetable->ydb_unlock_callback();
|
||||
}
|
||||
|
||||
//
|
||||
// Increment the reference count
|
||||
// MUST HOLD cachetable lock
|
||||
static void
|
||||
cachefile_refup (CACHEFILE cf) {
|
||||
cf->refcount++;
|
||||
}
|
||||
|
||||
// What cachefile goes with particular iname (iname relative to env)?
|
||||
// The transaction that is adding the reference might not have a reference
|
||||
// to the brt, therefore the cachefile might be closing.
|
||||
|
@ -600,24 +562,13 @@ cachefile_refup (CACHEFILE cf) {
|
|||
// Once the close has finished, there must not be a cachefile with that name
|
||||
// in the cachetable.
|
||||
int toku_cachefile_of_iname_in_env (CACHETABLE ct, const char *iname_in_env, CACHEFILE *cf) {
|
||||
BOOL restarted = FALSE;
|
||||
cachefiles_lock(ct);
|
||||
CACHEFILE extant;
|
||||
int r;
|
||||
restart:
|
||||
r = ENOENT;
|
||||
for (extant = ct->cachefiles; extant; extant=extant->next) {
|
||||
if (extant->fname_in_env &&
|
||||
!strcmp(extant->fname_in_env, iname_in_env)) {
|
||||
assert(!restarted); //If restarted and found again, this is an error.
|
||||
if (extant->is_closing) {
|
||||
//Cachefile is closing, wait till finished.
|
||||
assert(extant->closefd_waiting==0); //Single client thread (any more and this needs to be re-analyzed).
|
||||
extant->closefd_waiting++;
|
||||
int rwait = toku_pthread_cond_wait(&extant->closefd_wait, ct->mutex); resource_assert_zero(rwait);
|
||||
restarted = TRUE;
|
||||
goto restart; //Restart and verify that it is not found in the second loop.
|
||||
}
|
||||
*cf = extant;
|
||||
r = 0;
|
||||
break;
|
||||
|
@ -792,6 +743,7 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd
|
|||
r=errno; close(fd); // no change for t:2444
|
||||
return r;
|
||||
}
|
||||
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
|
||||
r = toku_pthread_mutex_lock(&ct->openfd_mutex); // purpose is to make this function single-threaded
|
||||
resource_assert_zero(r);
|
||||
cachetable_lock(ct);
|
||||
|
@ -799,15 +751,7 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd
|
|||
for (extant = ct->cachefiles; extant; extant=extant->next) {
|
||||
if (memcmp(&extant->fileid, &fileid, sizeof(fileid))==0) {
|
||||
//File is already open (and in cachetable as extant)
|
||||
cachefile_refup(extant);
|
||||
if (extant->is_closing) {
|
||||
// if another thread is closing this file, wait until the close is fully complete
|
||||
cachefiles_unlock(ct); //Cannot hold cachefiles lock over the cond_wait
|
||||
r = toku_pthread_cond_wait(&extant->openfd_wait, ct->mutex);
|
||||
resource_assert_zero(r);
|
||||
cachefiles_lock(ct);
|
||||
goto try_again; // other thread has closed this file, go create a new cachefile
|
||||
}
|
||||
assert(!extant->is_closing);
|
||||
assert(!is_filenum_reserved(ct, extant->filenum));
|
||||
r = close(fd); // no change for t:2444
|
||||
assert(r == 0);
|
||||
|
@ -857,7 +801,6 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd
|
|||
newcf->cachetable = ct;
|
||||
newcf->filenum.fileid = with_filenum ? filenum.fileid : next_filenum_to_use.fileid++;
|
||||
cachefile_init_filenum(newcf, fd, fname_in_env, fileid);
|
||||
newcf->refcount = 1;
|
||||
newcf->next = ct->cachefiles;
|
||||
ct->cachefiles = newcf;
|
||||
|
||||
|
@ -866,8 +809,6 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd
|
|||
newcf->for_local_checkpoint = ZERO_LSN;
|
||||
newcf->checkpoint_state = CS_NOT_IN_PROGRESS;
|
||||
|
||||
r = toku_pthread_cond_init(&newcf->openfd_wait, NULL); resource_assert_zero(r);
|
||||
r = toku_pthread_cond_init(&newcf->closefd_wait, NULL); resource_assert_zero(r);
|
||||
r = toku_pthread_cond_init(&newcf->background_wait, NULL); resource_assert_zero(r);
|
||||
toku_list_init(&newcf->pairs_for_cachefile);
|
||||
*cfptr = newcf;
|
||||
|
@ -876,6 +817,7 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd
|
|||
exit:
|
||||
cachefiles_unlock(ct);
|
||||
{
|
||||
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
|
||||
int rm = toku_pthread_mutex_unlock(&ct->openfd_mutex);
|
||||
resource_assert_zero(rm);
|
||||
}
|
||||
|
@ -897,10 +839,6 @@ int toku_cachetable_openf (CACHEFILE *cfptr, CACHETABLE ct, const char *fname_in
|
|||
return r;
|
||||
}
|
||||
|
||||
WORKQUEUE toku_cachetable_get_workqueue(CACHETABLE ct) {
|
||||
return &ct->wq;
|
||||
}
|
||||
|
||||
void toku_cachefile_get_workqueue_load (CACHEFILE cf, int *n_in_queue, int *n_threads) {
|
||||
CACHETABLE ct = cf->cachetable;
|
||||
*n_in_queue = workqueue_n_in_queue(&ct->wq, 1);
|
||||
|
@ -1009,11 +947,7 @@ int toku_cachefile_close (CACHEFILE *cfp, char **error_string, BOOL oplsn_valid,
|
|||
cachetable_unlock(ct);
|
||||
wait_on_background_jobs_to_finish(cf);
|
||||
cachetable_lock(ct);
|
||||
assert(cf->refcount>0);
|
||||
if (oplsn_valid)
|
||||
assert(cf->refcount==1); //Recovery is trying to force an lsn. Must get passed through.
|
||||
cf->refcount--;
|
||||
if (cf->refcount==0) {
|
||||
{
|
||||
//Checkpoint holds a reference, close should be impossible if still in use by a checkpoint.
|
||||
assert(!cf->next_in_checkpoint);
|
||||
assert(!cf->for_checkpoint);
|
||||
|
@ -1028,26 +962,8 @@ int toku_cachefile_close (CACHEFILE *cfp, char **error_string, BOOL oplsn_valid,
|
|||
if (0) {
|
||||
error:
|
||||
remove_cf_from_cachefiles_list(cf);
|
||||
if (cf->refcount > 0) {
|
||||
int rs;
|
||||
assert(cf->refcount == 1); // toku_cachetable_openfd() is single-threaded
|
||||
assert(!cf->next_in_checkpoint); //checkpoint cannot run on a closing file
|
||||
assert(!cf->for_checkpoint); //checkpoint cannot run on a closing file
|
||||
rs = toku_pthread_cond_signal(&cf->openfd_wait); resource_assert_zero(rs);
|
||||
}
|
||||
if (cf->closefd_waiting > 0) {
|
||||
int rs;
|
||||
assert(cf->closefd_waiting == 1);
|
||||
rs = toku_pthread_cond_signal(&cf->closefd_wait); assert(rs == 0);
|
||||
}
|
||||
// we can destroy the condition variables because if there was another thread waiting, it was already signalled
|
||||
{
|
||||
int rd;
|
||||
rd = toku_pthread_cond_destroy(&cf->openfd_wait);
|
||||
resource_assert_zero(rd);
|
||||
rd = toku_pthread_cond_destroy(&cf->closefd_wait);
|
||||
resource_assert_zero(rd);
|
||||
}
|
||||
assert(!cf->next_in_checkpoint); //checkpoint cannot run on a closing file
|
||||
assert(!cf->for_checkpoint); //checkpoint cannot run on a closing file
|
||||
if (cf->fname_in_env) toku_free(cf->fname_in_env);
|
||||
|
||||
rwlock_write_lock(&cf->fdlock, ct->mutex);
|
||||
|
@ -1062,7 +978,6 @@ int toku_cachefile_close (CACHEFILE *cfp, char **error_string, BOOL oplsn_valid,
|
|||
rwlock_destroy(&cf->fdlock);
|
||||
assert(toku_list_empty(&cf->pairs_for_cachefile));
|
||||
toku_free(cf);
|
||||
*cfp = NULL;
|
||||
cachetable_unlock(ct);
|
||||
return r;
|
||||
}
|
||||
|
@ -1078,37 +993,19 @@ int toku_cachefile_close (CACHEFILE *cfp, char **error_string, BOOL oplsn_valid,
|
|||
cf->end_checkpoint_userdata = NULL;
|
||||
cf->userdata = NULL;
|
||||
remove_cf_from_cachefiles_list(cf);
|
||||
// refcount could be non-zero if another thread is trying to open this cachefile,
|
||||
// but is blocked in toku_cachetable_openfd() waiting for us to finish closing it.
|
||||
if (cf->refcount > 0) {
|
||||
int rs;
|
||||
assert(cf->refcount == 1); // toku_cachetable_openfd() is single-threaded
|
||||
rs = toku_pthread_cond_signal(&cf->openfd_wait); resource_assert_zero(rs);
|
||||
}
|
||||
if (cf->closefd_waiting > 0) {
|
||||
int rs;
|
||||
assert(cf->closefd_waiting == 1);
|
||||
rs = toku_pthread_cond_signal(&cf->closefd_wait); resource_assert_zero(rs);
|
||||
}
|
||||
// we can destroy the condition variables because if there was another thread waiting, it was already signalled
|
||||
{
|
||||
int rd;
|
||||
rd = toku_pthread_cond_destroy(&cf->openfd_wait);
|
||||
resource_assert_zero(rd);
|
||||
rd = toku_pthread_cond_destroy(&cf->closefd_wait);
|
||||
resource_assert_zero(rd);
|
||||
rd = toku_pthread_cond_destroy(&cf->background_wait);
|
||||
int rd = toku_pthread_cond_destroy(&cf->background_wait);
|
||||
resource_assert_zero(rd);
|
||||
}
|
||||
rwlock_write_lock(&cf->fdlock, ct->mutex); //Just make sure we can get it.
|
||||
cachetable_unlock(ct);
|
||||
|
||||
if ( !toku_cachefile_is_dev_null_unlocked(cf) ) {
|
||||
if (!toku_cachefile_is_dev_null_unlocked(cf)) {
|
||||
cachetable_unlock(ct);
|
||||
r = toku_file_fsync_without_accounting(cf->fd); //t:2444
|
||||
assert(r == 0);
|
||||
cachetable_lock(ct);
|
||||
}
|
||||
|
||||
cachetable_lock(ct);
|
||||
rwlock_write_unlock(&cf->fdlock);
|
||||
rwlock_destroy(&cf->fdlock);
|
||||
assert(toku_list_empty(&cf->pairs_for_cachefile));
|
||||
|
@ -1120,12 +1017,7 @@ int toku_cachefile_close (CACHEFILE *cfp, char **error_string, BOOL oplsn_valid,
|
|||
|
||||
if (cf->fname_in_env) toku_free(cf->fname_in_env);
|
||||
toku_free(cf);
|
||||
*cfp=NULL;
|
||||
return r;
|
||||
} else {
|
||||
cachetable_unlock(ct);
|
||||
*cfp=NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2714,8 +2606,7 @@ int toku_cachetable_get_and_pin_nonblocking (
|
|||
UNLOCKERS unlockers
|
||||
)
|
||||
// Effect: If the block is in the cachetable, then pin it and return it.
|
||||
// Otherwise call the lock_unlock_callback (to unlock), fetch the data (but don't pin it, since we'll just end up pinning it again later), and the call (to lock)
|
||||
// and return TOKUDB_TRY_AGAIN.
|
||||
// Otherwise fetch the data (but don't pin it, since we'll just end up pinning it again later), and return TOKUDB_TRY_AGAIN.
|
||||
{
|
||||
CACHETABLE ct = cf->cachetable;
|
||||
cachetable_lock(ct);
|
||||
|
@ -3320,6 +3211,7 @@ toku_cachetable_close (CACHETABLE *ctp) {
|
|||
}
|
||||
assert(ct->size_evicting == 0);
|
||||
rwlock_destroy(&ct->pending_lock);
|
||||
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
|
||||
int r = toku_pthread_mutex_destroy(&ct->openfd_mutex); resource_assert_zero(r);
|
||||
cachetable_unlock(ct);
|
||||
toku_destroy_workers(&ct->wq, &ct->threadpool);
|
||||
|
@ -3504,10 +3396,10 @@ int toku_cachetable_unpin_and_remove (
|
|||
}
|
||||
|
||||
static int
|
||||
set_filenum_in_array(OMTVALUE brtv, u_int32_t index, void*arrayv) {
|
||||
set_filenum_in_array(OMTVALUE hv, u_int32_t index, void*arrayv) {
|
||||
FILENUM *array = arrayv;
|
||||
BRT brt = brtv;
|
||||
array[index] = toku_cachefile_filenum(brt->cf);
|
||||
struct brt_header* h = hv;
|
||||
array[index] = toku_cachefile_filenum(h->cf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3516,13 +3408,13 @@ log_open_txn (OMTVALUE txnv, u_int32_t UU(index), void *UU(extra)) {
|
|||
TOKUTXN txn = txnv;
|
||||
TOKULOGGER logger = txn->logger;
|
||||
FILENUMS open_filenums;
|
||||
uint32_t num_filenums = toku_omt_size(txn->open_brts);
|
||||
uint32_t num_filenums = toku_omt_size(txn->open_brt_headers);
|
||||
FILENUM array[num_filenums];
|
||||
{
|
||||
open_filenums.num = num_filenums;
|
||||
open_filenums.filenums = array;
|
||||
//Fill in open_filenums
|
||||
int r = toku_omt_iterate(txn->open_brts, set_filenum_in_array, array);
|
||||
int r = toku_omt_iterate(txn->open_brt_headers, set_filenum_in_array, array);
|
||||
assert(r==0);
|
||||
}
|
||||
// Zardosht claims that COMMITTING, ABORTING and RETIRED can never happen because of the multi-operation lock.
|
||||
|
@ -3589,14 +3481,12 @@ toku_cachetable_begin_checkpoint (CACHETABLE ct, TOKULOGGER logger) {
|
|||
ct->checkpoint_num_txns = 0;
|
||||
|
||||
//Make list of cachefiles to be included in checkpoint.
|
||||
//If refcount is 0, the cachefile is closing (performing a local checkpoint)
|
||||
{
|
||||
CACHEFILE cf;
|
||||
assert(ct->cachefiles_in_checkpoint==NULL);
|
||||
cachefiles_lock(ct);
|
||||
for (cf = ct->cachefiles; cf; cf=cf->next) {
|
||||
assert(!cf->is_closing); //Closing requires ydb lock (or in checkpoint). Cannot happen.
|
||||
assert(cf->refcount>0); //Must have a reference if not closing.
|
||||
//Incremement reference count of cachefile because we're using it for the checkpoint.
|
||||
//This will prevent closing during the checkpoint.
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
110
newbrt/recover.c
110
newbrt/recover.c
|
@ -58,12 +58,17 @@ struct file_map_tuple {
|
|||
FILENUM filenum;
|
||||
BRT brt; // NULL brt means it's a rollback file.
|
||||
char *iname;
|
||||
struct __toku_db fake_db;
|
||||
};
|
||||
|
||||
static void file_map_tuple_init(struct file_map_tuple *tuple, FILENUM filenum, BRT brt, char *iname) {
|
||||
tuple->filenum = filenum;
|
||||
tuple->brt = brt;
|
||||
tuple->iname = iname;
|
||||
// use a fake DB for comparisons, using the brtheader's cmp descriptor
|
||||
memset(&tuple->fake_db, 0, sizeof(tuple->fake_db));
|
||||
tuple->fake_db.cmp_descriptor = &tuple->brt->h->cmp_descriptor;
|
||||
tuple->fake_db.descriptor = &tuple->brt->h->descriptor;
|
||||
}
|
||||
|
||||
static void file_map_tuple_destroy(struct file_map_tuple *tuple) {
|
||||
|
@ -81,11 +86,8 @@ struct file_map {
|
|||
// The recovery environment
|
||||
struct recover_env {
|
||||
DB_ENV *env;
|
||||
keep_zombie_callback_t keep_zombie_callback; // at the end of recovery, the zombie BRTs that need to be recorded in the environment are sent this way. The iname is malloc'd and will now be owned by the environment (so the env must free it)
|
||||
prepared_txn_callback_t prepared_txn_callback; // at the end of recovery, all the prepared txns are passed back to the ydb layer to make them into valid transactions.
|
||||
keep_cachetable_callback_t keep_cachetable_callback; // after recovery, store the cachetable into the environment.
|
||||
setup_db_callback_t setup_db_callback; // when creating a DB, we first create a BRT and then use this to biuld the DB we need.
|
||||
close_db_callback_t close_db_callback; // If this function is non-NULL then use it to close the DB and close the BRT. Otherwise we call toku_close_brt ourselves.
|
||||
CACHETABLE ct;
|
||||
TOKULOGGER logger;
|
||||
brt_compare_func bt_compare;
|
||||
|
@ -113,7 +115,7 @@ static uint32_t file_map_get_num_dictionaries(struct file_map *fmap) {
|
|||
return toku_omt_size(fmap->filenums);
|
||||
}
|
||||
|
||||
static void file_map_close_dictionaries(RECOVER_ENV renv, struct file_map *fmap, BOOL recovery_succeeded, LSN oplsn) {
|
||||
static void file_map_close_dictionaries(struct file_map *fmap, BOOL recovery_succeeded, LSN oplsn) {
|
||||
int r;
|
||||
|
||||
while (1) {
|
||||
|
@ -133,36 +135,9 @@ static void file_map_close_dictionaries(RECOVER_ENV renv, struct file_map *fmap,
|
|||
assert(r==0);
|
||||
}
|
||||
// Logging is on again, but we must pass the right LSN into close.
|
||||
char *error_string = NULL;
|
||||
if (tuple->brt) { // it's a DB, not a rollback file
|
||||
DB *db = tuple->brt->db; //Need to free the fake db that was malloced
|
||||
if (!toku_brt_zombie_needed(tuple->brt)) {
|
||||
if (renv->close_db_callback) {
|
||||
r = renv->close_db_callback(tuple->brt->db, true, oplsn);
|
||||
if (r!=0) error_string = toku_strdup("Cannot close DB");
|
||||
db = NULL; // so it won't get freed again below.
|
||||
} else {
|
||||
r = toku_close_brt_nolsn(tuple->brt, &error_string);
|
||||
}
|
||||
if (!recovery_succeeded) {
|
||||
if (tokudb_recovery_trace)
|
||||
fprintf(stderr, "%s:%d %d %s\n", __FUNCTION__, __LINE__, r, error_string);
|
||||
assert(r != 0);
|
||||
} else
|
||||
assert(r == 0);
|
||||
if (error_string)
|
||||
toku_free(error_string);
|
||||
} else {
|
||||
if (renv->keep_zombie_callback) {
|
||||
renv->keep_zombie_callback(renv->env,
|
||||
tuple->brt,
|
||||
tuple->iname, // use iname for the dname.
|
||||
true, oplsn);
|
||||
tuple->iname = NULL; // so it won't be freed again below.
|
||||
db = NULL; // so it won't get freed again below.
|
||||
}
|
||||
}
|
||||
toku_free(db); //Must free the DB after the brt is closed
|
||||
r = toku_brt_close(tuple->brt, true, oplsn);
|
||||
lazy_assert_zero(r);
|
||||
} else {
|
||||
assert(tuple->brt==NULL);
|
||||
}
|
||||
|
@ -214,11 +189,8 @@ static int file_map_find(struct file_map *fmap, FILENUM fnum, struct file_map_tu
|
|||
static int recover_env_init (RECOVER_ENV renv,
|
||||
const char *env_dir,
|
||||
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,
|
||||
brt_compare_func bt_compare,
|
||||
brt_update_func update_function,
|
||||
|
@ -242,11 +214,8 @@ static int recover_env_init (RECOVER_ENV renv,
|
|||
toku_logger_write_log_files(renv->logger, FALSE);
|
||||
toku_logger_set_cachetable(renv->logger, renv->ct);
|
||||
renv->env = env;
|
||||
renv->keep_zombie_callback = keep_zombie_callback;
|
||||
renv->prepared_txn_callback = prepared_txn_callback;
|
||||
renv->keep_cachetable_callback = keep_cachetable_callback;
|
||||
renv->setup_db_callback = setup_db_callback;
|
||||
renv->close_db_callback = close_db_callback;
|
||||
renv->bt_compare = bt_compare;
|
||||
renv->update_function = update_function;
|
||||
renv->generate_row_for_put = generate_row_for_put;
|
||||
|
@ -333,24 +302,12 @@ static int internal_recover_fopen_or_fcreate (RECOVER_ENV renv, BOOL must_create
|
|||
// TODO mode (FUTURE FEATURE)
|
||||
//mode = mode;
|
||||
|
||||
//Create DB (e.g., for comparison functions and also so that when finishing recovery we can make them into zombies)
|
||||
DB *db;
|
||||
db = NULL;
|
||||
if (renv->setup_db_callback) {
|
||||
r = renv->setup_db_callback(&db, renv->env, 0, brt, true);
|
||||
assert(r==0);
|
||||
}
|
||||
r = toku_brt_open_recovery(brt, iname, must_create, must_create, renv->ct, txn, db, filenum, max_acceptable_lsn);
|
||||
r = toku_brt_open_recovery(brt, iname, must_create, must_create, renv->ct, txn, filenum, max_acceptable_lsn);
|
||||
if (r != 0) {
|
||||
//Note: If brt_open fails, then close_brt will NOT write a header to disk.
|
||||
//No need to provide lsn
|
||||
if (renv->close_db_callback) {
|
||||
int rr = renv->close_db_callback(db, false, ZERO_LSN);
|
||||
assert(rr==0);
|
||||
} else {
|
||||
int rr = toku_close_brt_nolsn(brt, NULL); assert(rr == 0);
|
||||
toku_free(db); //Free memory allocated for the fake db.
|
||||
}
|
||||
int r2 = toku_brt_close(brt, FALSE, ZERO_LSN);
|
||||
assert_zero(r2);
|
||||
toku_free(iname);
|
||||
if (r == ENOENT) //Not an error to simply be missing.
|
||||
r = 0;
|
||||
|
@ -492,8 +449,8 @@ static int toku_recover_fassociate (struct logtype_fassociate *l, RECOVER_ENV re
|
|||
BRT t;
|
||||
r = toku_brt_create(&t);
|
||||
assert(r==0);
|
||||
r = toku_brt_open_recovery(t, ROLLBACK_CACHEFILE_NAME, false, false, renv->ct, (TOKUTXN)NULL, (DB*)NULL, l->filenum, max_acceptable_lsn);
|
||||
renv->logger->rollback_cachefile = t->cf;
|
||||
r = toku_brt_open_recovery(t, ROLLBACK_CACHEFILE_NAME, false, false, renv->ct, (TOKUTXN)NULL, l->filenum, max_acceptable_lsn);
|
||||
renv->logger->rollback_cachefile = t->h->cf;
|
||||
} else {
|
||||
r = internal_recover_fopen_or_fcreate(renv, FALSE, 0, &l->iname, l->filenum, l->treeflags, NULL, 0, 0, max_acceptable_lsn);
|
||||
assert(r==0);
|
||||
|
@ -578,7 +535,7 @@ static int recover_xstillopen_internal (TOKUTXN *txnp,
|
|||
struct txninfo info = {
|
||||
COPY_TO_INFO(rollentry_raw_count),
|
||||
.num_brts = 0, //Set afterwards
|
||||
.open_brts = NULL, //Set afterwards
|
||||
.open_brt_headers = NULL, //Set afterwards
|
||||
COPY_TO_INFO(force_fsync_on_commit),
|
||||
COPY_TO_INFO(num_rollback_nodes),
|
||||
COPY_TO_INFO(num_rollentries),
|
||||
|
@ -587,16 +544,16 @@ static int recover_xstillopen_internal (TOKUTXN *txnp,
|
|||
COPY_TO_INFO(current_rollback)
|
||||
};
|
||||
#undef COPY_TO_INFO
|
||||
//Generate open_brts
|
||||
BRT array[open_filenums.num]; //Allocate maximum possible requirement
|
||||
info.open_brts = array;
|
||||
//Generate open_brt_headers
|
||||
struct brt_header* array[open_filenums.num]; //Allocate maximum possible requirement
|
||||
info.open_brt_headers = array;
|
||||
uint32_t i;
|
||||
for (i = 0; i < open_filenums.num; i++) {
|
||||
//open_filenums.filenums[]
|
||||
struct file_map_tuple *tuple = NULL;
|
||||
r = file_map_find(&renv->fmap, open_filenums.filenums[i], &tuple);
|
||||
if (r==0) {
|
||||
info.open_brts[info.num_brts++] = tuple->brt;
|
||||
info.open_brt_headers[info.num_brts++] = tuple->brt->h;
|
||||
}
|
||||
else {
|
||||
assert(r==DB_NOTFOUND);
|
||||
|
@ -685,7 +642,7 @@ static int toku_recover_suppress_rollback (struct logtype_suppress_rollback *UU(
|
|||
assert(txn!=NULL);
|
||||
struct brt_header *h = tuple->brt->h;
|
||||
toku_brt_header_suppress_rollbacks(h, txn);
|
||||
r = toku_txn_note_brt(txn, tuple->brt);
|
||||
r = toku_txn_note_brt(txn, tuple->brt->h);
|
||||
assert(r==0);
|
||||
}
|
||||
return 0;
|
||||
|
@ -892,15 +849,8 @@ static int toku_recover_fclose (struct logtype_fclose *l, RECOVER_ENV renv) {
|
|||
|
||||
if (0!=strcmp(iname, ROLLBACK_CACHEFILE_NAME)) {
|
||||
//Rollback cachefile is closed manually at end of recovery, not here
|
||||
DB *db = tuple->brt->db;
|
||||
if (renv->close_db_callback) {
|
||||
r = renv->close_db_callback(db, true, l->lsn);
|
||||
assert(r==0);
|
||||
} else {
|
||||
r = toku_close_brt_lsn(tuple->brt, 0, TRUE, l->lsn);
|
||||
assert(r == 0);
|
||||
toku_free(db); //Must free the DB after the brt is closed
|
||||
}
|
||||
r = toku_brt_close(tuple->brt, true, l->lsn);
|
||||
lazy_assert_zero(r);
|
||||
}
|
||||
file_map_remove(&renv->fmap, l->filenum);
|
||||
toku_free(iname);
|
||||
|
@ -959,7 +909,7 @@ static int toku_recover_enq_insert (struct logtype_enq_insert *l, RECOVER_ENV re
|
|||
toku_fill_dbt(&valdbt, l->value.data, l->value.len);
|
||||
r = toku_brt_maybe_insert(tuple->brt, &keydbt, &valdbt, txn, TRUE, l->lsn, FALSE, BRT_INSERT);
|
||||
assert(r == 0);
|
||||
r = toku_txn_note_brt(txn, tuple->brt);
|
||||
r = toku_txn_note_brt(txn, tuple->brt->h);
|
||||
assert(r == 0);
|
||||
}
|
||||
return 0;
|
||||
|
@ -1032,7 +982,7 @@ static int toku_recover_enq_insert_multiple (struct logtype_enq_insert_multiple
|
|||
assert(r==DB_NOTFOUND);
|
||||
else {
|
||||
if (r == 0)
|
||||
src_db = tuple->brt->db;
|
||||
src_db = &tuple->fake_db;
|
||||
else
|
||||
do_inserts = FALSE; // src file was probably deleted, #3129
|
||||
}
|
||||
|
@ -1050,7 +1000,7 @@ static int toku_recover_enq_insert_multiple (struct logtype_enq_insert_multiple
|
|||
r = file_map_find(&renv->fmap, l->dest_filenums.filenums[file], &tuple);
|
||||
if (r==0) {
|
||||
// We found the cachefile. (maybe) Do the insert.
|
||||
DB *db = tuple->brt->db;
|
||||
DB *db = &tuple->fake_db;
|
||||
r = renv->generate_row_for_put(db, src_db, &dest_key, &dest_val, &src_key, &src_val);
|
||||
assert(r==0);
|
||||
r = toku_brt_maybe_insert(tuple->brt, &dest_key, &dest_val, txn, TRUE, l->lsn, FALSE, BRT_INSERT);
|
||||
|
@ -1094,7 +1044,7 @@ static int toku_recover_enq_delete_multiple (struct logtype_enq_delete_multiple
|
|||
assert(r==DB_NOTFOUND);
|
||||
else {
|
||||
if (r == 0)
|
||||
src_db = tuple->brt->db;
|
||||
src_db = &tuple->fake_db;
|
||||
else
|
||||
do_deletes = FALSE; // src file was probably deleted, #3129
|
||||
}
|
||||
|
@ -1111,7 +1061,7 @@ static int toku_recover_enq_delete_multiple (struct logtype_enq_delete_multiple
|
|||
r = file_map_find(&renv->fmap, l->dest_filenums.filenums[file], &tuple);
|
||||
if (r==0) {
|
||||
// We found the cachefile. (maybe) Do the delete.
|
||||
DB *db = tuple->brt->db;
|
||||
DB *db = &tuple->fake_db;
|
||||
r = renv->generate_row_for_del(db, src_db, &dest_key, &src_key, &src_val);
|
||||
assert(r==0);
|
||||
r = toku_brt_maybe_delete(tuple->brt, &dest_key, txn, TRUE, l->lsn, FALSE);
|
||||
|
@ -1536,7 +1486,7 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
|
|||
tnow = time(NULL);
|
||||
fprintf(stderr, "%.24s Tokudb recovery closing %"PRIu32" dictionar%s\n", ctime(&tnow), n, n > 1 ? "ies" : "y");
|
||||
}
|
||||
file_map_close_dictionaries(renv, &renv->fmap, TRUE, lastlsn);
|
||||
file_map_close_dictionaries(&renv->fmap, TRUE, lastlsn);
|
||||
|
||||
// write a recovery log entry
|
||||
BYTESTRING recover_comment = { strlen("recover"), "recover" };
|
||||
|
@ -1594,11 +1544,8 @@ toku_recover_unlock(int lockfd) {
|
|||
|
||||
|
||||
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,
|
||||
|
@ -1619,11 +1566,8 @@ int tokudb_recover(DB_ENV *env,
|
|||
r = recover_env_init(&renv,
|
||||
env_dir,
|
||||
env,
|
||||
keep_zombie_callback,
|
||||
prepared_txn_callback,
|
||||
keep_cachetable_callback,
|
||||
setup_db_callback,
|
||||
close_db_callback,
|
||||
logger,
|
||||
bt_compare,
|
||||
update_function,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -77,20 +77,20 @@ static void assert_cursor_first_last(BRT brt, long long firstv, long long lastv)
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_brt_cursor_first(int n, DB *db) {
|
||||
static void test_brt_cursor_first(int n) {
|
||||
CACHETABLE ct;
|
||||
BRT brt;
|
||||
int r;
|
||||
int i;
|
||||
|
||||
if (verbose) printf("test_brt_cursor_first:%d %p\n", n, db);
|
||||
if (verbose) printf("test_brt_cursor_first:%d\n", n);
|
||||
|
||||
unlink(fname);
|
||||
|
||||
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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
/* insert a bunch of kv pairs */
|
||||
|
@ -118,20 +118,20 @@ static void test_brt_cursor_first(int n, DB *db) {
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_brt_cursor_last(int n, DB *db) {
|
||||
static void test_brt_cursor_last(int n) {
|
||||
CACHETABLE ct;
|
||||
BRT brt;
|
||||
int r;
|
||||
int i;
|
||||
|
||||
if (verbose) printf("test_brt_cursor_last:%d %p\n", n, db);
|
||||
if (verbose) printf("test_brt_cursor_last:%d\n", n);
|
||||
|
||||
unlink(fname);
|
||||
|
||||
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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
/* insert keys 0, 1, .. (n-1) */
|
||||
|
@ -159,20 +159,20 @@ static void test_brt_cursor_last(int n, DB *db) {
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_brt_cursor_first_last(int n, DB *db) {
|
||||
static void test_brt_cursor_first_last(int n) {
|
||||
CACHETABLE ct;
|
||||
BRT brt;
|
||||
int r;
|
||||
int i;
|
||||
|
||||
if (verbose) printf("test_brt_cursor_first_last:%d %p\n", n, db);
|
||||
if (verbose) printf("test_brt_cursor_first_last:%d\n", n);
|
||||
|
||||
unlink(fname);
|
||||
|
||||
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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
/* insert a bunch of kv pairs */
|
||||
|
@ -204,20 +204,20 @@ static void test_brt_cursor_first_last(int n, DB *db) {
|
|||
|
||||
}
|
||||
|
||||
static void test_brt_cursor_rfirst(int n, DB *db) {
|
||||
static void test_brt_cursor_rfirst(int n) {
|
||||
CACHETABLE ct;
|
||||
BRT brt;
|
||||
int r;
|
||||
int i;
|
||||
|
||||
if (verbose) printf("test_brt_cursor_rfirst:%d %p\n", n, db);
|
||||
if (verbose) printf("test_brt_cursor_rfirst:%d\n", n);
|
||||
|
||||
unlink(fname);
|
||||
|
||||
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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
/* insert keys n-1, n-2, ... , 0 */
|
||||
|
@ -272,20 +272,20 @@ static void assert_cursor_walk(BRT brt, int n) {
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_brt_cursor_walk(int n, DB *db) {
|
||||
static void test_brt_cursor_walk(int n) {
|
||||
CACHETABLE ct;
|
||||
BRT brt;
|
||||
int r;
|
||||
int i;
|
||||
|
||||
if (verbose) printf("test_brt_cursor_walk:%d %p\n", n, db);
|
||||
if (verbose) printf("test_brt_cursor_walk:%d\n", n);
|
||||
|
||||
unlink(fname);
|
||||
|
||||
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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
/* insert a bunch of kv pairs */
|
||||
|
@ -338,20 +338,20 @@ static void assert_cursor_rwalk(BRT brt, int n) {
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_brt_cursor_rwalk(int n, DB *db) {
|
||||
static void test_brt_cursor_rwalk(int n) {
|
||||
CACHETABLE ct;
|
||||
BRT brt;
|
||||
int r;
|
||||
int i;
|
||||
|
||||
if (verbose) printf("test_brt_cursor_rwalk:%d %p\n", n, db);
|
||||
if (verbose) printf("test_brt_cursor_rwalk:%d\n", n);
|
||||
|
||||
unlink(fname);
|
||||
|
||||
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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
/* insert a bunch of kv pairs */
|
||||
|
@ -423,20 +423,20 @@ static void assert_cursor_walk_inorder(BRT brt, int n) {
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_brt_cursor_rand(int n, DB *db) {
|
||||
static void test_brt_cursor_rand(int n) {
|
||||
CACHETABLE ct;
|
||||
BRT brt;
|
||||
int r;
|
||||
int i;
|
||||
|
||||
if (verbose) printf("test_brt_cursor_rand:%d %p\n", n, db);
|
||||
if (verbose) printf("test_brt_cursor_rand:%d\n", n);
|
||||
|
||||
unlink(fname);
|
||||
|
||||
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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
/* insert a bunch of kv pairs */
|
||||
|
@ -475,7 +475,7 @@ static void test_brt_cursor_rand(int n, DB *db) {
|
|||
|
||||
}
|
||||
|
||||
static void test_brt_cursor_split(int n, DB *db) {
|
||||
static void test_brt_cursor_split(int n) {
|
||||
CACHETABLE ct;
|
||||
BRT brt;
|
||||
BRT_CURSOR cursor=0;
|
||||
|
@ -483,14 +483,14 @@ static void test_brt_cursor_split(int n, DB *db) {
|
|||
int keyseqnum;
|
||||
int i;
|
||||
|
||||
if (verbose) printf("test_brt_cursor_split:%d %p\n", n, db);
|
||||
if (verbose) printf("test_brt_cursor_split:%d\n", n);
|
||||
|
||||
unlink(fname);
|
||||
|
||||
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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
/* insert a bunch of kv pairs */
|
||||
|
@ -553,8 +553,8 @@ static void test_brt_cursor_split(int n, DB *db) {
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_multiple_brt_cursors(int n, DB *db) {
|
||||
if (verbose) printf("test_multiple_brt_cursors:%d %p\n", n, db);
|
||||
static void test_multiple_brt_cursors(int n) {
|
||||
if (verbose) printf("test_multiple_brt_cursors:%d\n", n);
|
||||
|
||||
int r;
|
||||
CACHETABLE ct;
|
||||
|
@ -566,7 +566,7 @@ static void test_multiple_brt_cursors(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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
int i;
|
||||
|
@ -597,8 +597,8 @@ static int log16(int n) {
|
|||
return r;
|
||||
}
|
||||
|
||||
static void test_multiple_brt_cursor_walk(int n, DB *db) {
|
||||
if (verbose) printf("test_multiple_brt_cursor_walk:%d %p\n", n, db);
|
||||
static void test_multiple_brt_cursor_walk(int n) {
|
||||
if (verbose) printf("test_multiple_brt_cursor_walk:%d\n", n);
|
||||
|
||||
int r;
|
||||
CACHETABLE ct;
|
||||
|
@ -615,7 +615,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) {
|
|||
r = toku_brt_create_cachetable(&ct, cachesize, ZERO_LSN, NULL_LOGGER);
|
||||
assert(r==0);
|
||||
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
int c;
|
||||
|
@ -679,8 +679,8 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) {
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
|
||||
if (verbose) printf("test_brt_cursor_set:%d %d %p\n", n, cursor_op, db);
|
||||
static void test_brt_cursor_set(int n, int cursor_op) {
|
||||
if (verbose) printf("test_brt_cursor_set:%d %d\n", n, cursor_op);
|
||||
|
||||
int r;
|
||||
CACHETABLE ct;
|
||||
|
@ -692,7 +692,7 @@ static void test_brt_cursor_set(int n, int cursor_op, 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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
int i;
|
||||
|
@ -751,8 +751,8 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_brt_cursor_set_range(int n, DB *db) {
|
||||
if (verbose) printf("test_brt_cursor_set_range:%d %p\n", n, db);
|
||||
static void test_brt_cursor_set_range(int n) {
|
||||
if (verbose) printf("test_brt_cursor_set_range:%d\n", n);
|
||||
|
||||
int r;
|
||||
CACHETABLE ct;
|
||||
|
@ -764,7 +764,7 @@ static void test_brt_cursor_set_range(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, test_brt_cursor_keycompare, db);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(r==0);
|
||||
|
||||
int i;
|
||||
|
@ -815,8 +815,8 @@ static void test_brt_cursor_set_range(int n, DB *db) {
|
|||
assert(r==0);
|
||||
}
|
||||
|
||||
static void test_brt_cursor_delete(int n, DB *db) {
|
||||
if (verbose) printf("test_brt_cursor_delete:%d %p\n", n, db);
|
||||
static void test_brt_cursor_delete(int n) {
|
||||
if (verbose) printf("test_brt_cursor_delete:%d\n", n);
|
||||
|
||||
int error;
|
||||
CACHETABLE ct;
|
||||
|
@ -828,7 +828,7 @@ static void test_brt_cursor_delete(int n, DB *db) {
|
|||
error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
|
||||
assert(error == 0);
|
||||
|
||||
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
|
||||
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
|
||||
assert(error == 0);
|
||||
|
||||
error = toku_brt_cursor(brt, &cursor, NULL, FALSE, FALSE);
|
||||
|
@ -879,58 +879,55 @@ static void test_brt_cursor_delete(int n, DB *db) {
|
|||
static int test_brt_cursor_inc = 1000;
|
||||
static int test_brt_cursor_limit = 10000;
|
||||
|
||||
static void test_brt_cursor(DB *db) {
|
||||
static void test_brt_cursor(void) {
|
||||
int n;
|
||||
|
||||
test_multiple_brt_cursors(1, db);
|
||||
test_multiple_brt_cursors(2, db);
|
||||
test_multiple_brt_cursors(3, db);
|
||||
test_multiple_brt_cursors(1);
|
||||
test_multiple_brt_cursors(2);
|
||||
test_multiple_brt_cursors(3);
|
||||
|
||||
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
|
||||
test_brt_cursor_first(n, db);
|
||||
test_brt_cursor_first(n);
|
||||
}
|
||||
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
|
||||
test_brt_cursor_rfirst(n, db);
|
||||
test_brt_cursor_rfirst(n);
|
||||
}
|
||||
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
|
||||
test_brt_cursor_walk(n, db);
|
||||
test_brt_cursor_walk(n);
|
||||
}
|
||||
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
|
||||
test_brt_cursor_last(n, db);
|
||||
test_brt_cursor_last(n);
|
||||
}
|
||||
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
|
||||
test_brt_cursor_first_last(n, db);
|
||||
test_brt_cursor_first_last(n);
|
||||
}
|
||||
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
|
||||
test_brt_cursor_split(n, db);
|
||||
test_brt_cursor_split(n);
|
||||
}
|
||||
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
|
||||
test_brt_cursor_rand(n, db);
|
||||
test_brt_cursor_rand(n);
|
||||
}
|
||||
for (n=0; n<test_brt_cursor_limit; n += test_brt_cursor_inc) {
|
||||
test_brt_cursor_rwalk(n, db);
|
||||
test_brt_cursor_rwalk(n);
|
||||
}
|
||||
|
||||
test_brt_cursor_set(1000, DB_SET, db);
|
||||
test_brt_cursor_set(10000, DB_SET, db);
|
||||
test_brt_cursor_set(1000, DB_SET_RANGE, db);
|
||||
test_brt_cursor_set_range(1000, db);
|
||||
test_brt_cursor_set_range(10000, db);
|
||||
test_brt_cursor_set(1000, DB_SET);
|
||||
test_brt_cursor_set(10000, DB_SET);
|
||||
test_brt_cursor_set(1000, DB_SET_RANGE);
|
||||
test_brt_cursor_set_range(1000);
|
||||
test_brt_cursor_set_range(10000);
|
||||
|
||||
|
||||
test_brt_cursor_delete(1000, db);
|
||||
test_multiple_brt_cursor_walk(10000, db);
|
||||
test_multiple_brt_cursor_walk(100000, db);
|
||||
test_brt_cursor_delete(1000);
|
||||
test_multiple_brt_cursor_walk(10000);
|
||||
test_multiple_brt_cursor_walk(100000);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -18,7 +18,7 @@ static void test_dump_empty_db (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);
|
||||
if (verbose) { r=toku_dump_brt(stdout, t); assert(r==0); }
|
||||
r = toku_close_brt_nolsn(t, 0); assert(r==0);
|
||||
|
@ -38,8 +38,8 @@ static void test_multiple_files_of_size (int size) {
|
|||
unlink(n1);
|
||||
|
||||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||
r = toku_open_brt(n0, 1, &t0, size, size / 4, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
|
||||
r = toku_open_brt(n1, 1, &t1, size, size / 4, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
|
||||
r = toku_open_brt(n0, 1, &t0, size, size / 4, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
|
||||
r = toku_open_brt(n1, 1, &t1, size, size / 4, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
|
||||
for (i=0; i<10000; i++) {
|
||||
char key[100],val[100];
|
||||
DBT k,v;
|
||||
|
@ -62,10 +62,10 @@ static void test_multiple_files_of_size (int size) {
|
|||
|
||||
/* Now see if the data is all there. */
|
||||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||
r = toku_open_brt(n0, 0, &t0, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db);
|
||||
r = toku_open_brt(n0, 0, &t0, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun);
|
||||
if (verbose) printf("%s:%d r=%d\n", __FILE__, __LINE__,r);
|
||||
assert(r==0);
|
||||
r = toku_open_brt(n1, 0, &t1, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
|
||||
r = toku_open_brt(n1, 0, &t1, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
|
||||
|
||||
for (i=0; i<10000; i++) {
|
||||
char key[100],val[100];
|
||||
|
@ -98,7 +98,7 @@ static void test_multiple_brts_one_db_one_file (void) {
|
|||
unlink(fname);
|
||||
r = toku_brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||
for (i=0; i<MANYN; i++) {
|
||||
r = toku_open_brt(fname, (i==0), &trees[i], 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db);
|
||||
r = toku_open_brt(fname, (i==0), &trees[i], 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun);
|
||||
assert(r==0);
|
||||
}
|
||||
for (i=0; i<MANYN; i++) {
|
||||
|
@ -137,7 +137,7 @@ static void test_read_what_was_written (void) {
|
|||
|
||||
|
||||
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, null_db); assert(r==0);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
|
||||
r = toku_close_brt_nolsn(brt, 0); assert(r==0);
|
||||
r = toku_cachetable_close(&ct); assert(r==0);
|
||||
|
||||
|
@ -145,7 +145,7 @@ static void test_read_what_was_written (void) {
|
|||
|
||||
/* Now see if we can read an empty tree in. */
|
||||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||
r = toku_open_brt(fname, 0, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
|
||||
r = toku_open_brt(fname, 0, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
|
||||
|
||||
/* See if we can put something in it. */
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ static void test_read_what_was_written (void) {
|
|||
|
||||
/* Now see if we can read it in and get the value. */
|
||||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||
r = toku_open_brt(fname, 0, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
|
||||
r = toku_open_brt(fname, 0, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
|
||||
|
||||
brt_lookup_and_check_nodup(brt, "hello", "there");
|
||||
|
||||
|
@ -225,7 +225,7 @@ static void test_read_what_was_written (void) {
|
|||
|
||||
|
||||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||
r = toku_open_brt(fname, 0, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
|
||||
r = toku_open_brt(fname, 0, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
|
||||
|
||||
brt_lookup_and_check_nodup(brt, "hello", "there");
|
||||
{
|
||||
|
@ -259,7 +259,7 @@ static void test_cursor_last_empty(void) {
|
|||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
|
||||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
|
||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
|
||||
r = toku_brt_cursor(brt, &cursor, NULL, FALSE, FALSE); assert(r==0);
|
||||
{
|
||||
|
@ -274,6 +274,8 @@ static void test_cursor_last_empty(void) {
|
|||
assert(pair.call_count==0);
|
||||
assert(r==DB_NOTFOUND);
|
||||
}
|
||||
r = toku_brt_cursor_close(cursor);
|
||||
assert_zero(r);
|
||||
r = toku_close_brt_nolsn(brt, 0);
|
||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
|
||||
r = toku_cachetable_close(&ct); assert(r==0);
|
||||
|
@ -292,7 +294,7 @@ static void test_cursor_next (void) {
|
|||
|
||||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
|
||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
|
||||
r = toku_brt_insert(brt, toku_fill_dbt(&kbt, "hello", 6), toku_fill_dbt(&vbt, "there", 6), null_txn);
|
||||
r = toku_brt_insert(brt, toku_fill_dbt(&kbt, "byebye", 7), toku_fill_dbt(&vbt, "byenow", 7), null_txn);
|
||||
|
@ -325,6 +327,8 @@ static void test_cursor_next (void) {
|
|||
assert(pair.call_count==0);
|
||||
}
|
||||
|
||||
r = toku_brt_cursor_close(cursor);
|
||||
assert_zero(r);
|
||||
r = toku_close_brt_nolsn(brt, 0);
|
||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
|
||||
r = toku_cachetable_close(&ct); assert(r==0);
|
||||
|
@ -333,8 +337,6 @@ static void test_cursor_next (void) {
|
|||
|
||||
}
|
||||
|
||||
static DB nonce_db;
|
||||
|
||||
static int wrong_compare_fun(DB* UU(desc), const DBT *a, const DBT *b) {
|
||||
unsigned int i;
|
||||
unsigned char *ad=a->data;
|
||||
|
@ -371,7 +373,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
|||
//printf("%s:%d WRONG=%d\n", __FILE__, __LINE__, wrong_p);
|
||||
|
||||
if (0) { // ???? Why is this commented out?
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<20, 1<<17, ct, null_txn, wrong_p ? wrong_compare_fun : toku_builtin_compare_fun, &nonce_db); assert(r==0);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<20, 1<<17, ct, null_txn, wrong_p ? wrong_compare_fun : toku_builtin_compare_fun); assert(r==0);
|
||||
for (i=1; i<257; i+=255) {
|
||||
unsigned char a[4],b[4];
|
||||
b[3] = a[0] = (unsigned char)(i&255);
|
||||
|
@ -410,7 +412,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
|||
|
||||
{
|
||||
toku_cachetable_verify(ct);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<20, 1<<17, ct, null_txn, wrong_p ? wrong_compare_fun : toku_builtin_compare_fun, &nonce_db); assert(r==0);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<20, 1<<17, ct, null_txn, wrong_p ? wrong_compare_fun : toku_builtin_compare_fun); assert(r==0);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
for (i=0; i<N; i++) {
|
||||
|
@ -443,7 +445,8 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
|||
assert(pair.call_count==1);
|
||||
toku_cachetable_verify(ct);
|
||||
}
|
||||
|
||||
r = toku_brt_cursor_close(cursor);
|
||||
assert_zero(r);
|
||||
r = toku_close_brt_nolsn(brt, 0);
|
||||
assert(r==0);
|
||||
}
|
||||
|
@ -465,7 +468,7 @@ static void test_large_kv(int bsize, int ksize, int vsize) {
|
|||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
|
||||
assert(r==0);
|
||||
unlink(fname);
|
||||
r = toku_open_brt(fname, 1, &t, bsize, bsize / 4, ct, null_txn, toku_builtin_compare_fun, null_db);
|
||||
r = toku_open_brt(fname, 1, &t, bsize, bsize / 4, ct, null_txn, toku_builtin_compare_fun);
|
||||
assert(r==0);
|
||||
|
||||
DBT key, val;
|
||||
|
@ -511,7 +514,7 @@ static void test_brt_delete_empty(void) {
|
|||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
|
||||
assert(r==0);
|
||||
unlink(fname);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun);
|
||||
assert(r==0);
|
||||
|
||||
DBT key;
|
||||
|
@ -539,7 +542,7 @@ static void test_brt_delete_present(int n) {
|
|||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
|
||||
assert(r==0);
|
||||
unlink(fname);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun);
|
||||
assert(r==0);
|
||||
|
||||
/* insert 0 .. n-1 */
|
||||
|
@ -601,7 +604,7 @@ static void test_brt_delete_not_present(int n) {
|
|||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
|
||||
assert(r==0);
|
||||
unlink(fname);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun);
|
||||
assert(r==0);
|
||||
|
||||
DBT key, val;
|
||||
|
@ -647,7 +650,7 @@ static void test_brt_delete_cursor_first(int n) {
|
|||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
|
||||
assert(r==0);
|
||||
unlink(fname);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun);
|
||||
assert(r==0);
|
||||
|
||||
/* insert 0 .. n-1 */
|
||||
|
@ -740,7 +743,7 @@ static void test_insert_delete_lookup(int n) {
|
|||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
|
||||
assert(r==0);
|
||||
unlink(fname);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
|
||||
r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun);
|
||||
assert(r==0);
|
||||
|
||||
/* insert 0 .. n-1 */
|
||||
|
@ -827,7 +830,7 @@ static void test_new_brt_cursor_first(int n) {
|
|||
unlink(fname);
|
||||
r = toku_brt_create(&t); assert(r == 0);
|
||||
r = toku_brt_set_nodesize(t, 4096); assert(r == 0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn, 0); assert(r==0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn); assert(r==0);
|
||||
|
||||
DBT key, val;
|
||||
int k, v;
|
||||
|
@ -879,7 +882,7 @@ static void test_new_brt_cursor_last(int n) {
|
|||
unlink(fname);
|
||||
r = toku_brt_create(&t); assert(r == 0);
|
||||
r = toku_brt_set_nodesize(t, 4096); assert(r == 0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn, 0); assert(r==0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn); assert(r==0);
|
||||
|
||||
DBT key, val;
|
||||
int k, v;
|
||||
|
@ -932,7 +935,7 @@ static void test_new_brt_cursor_next(int n) {
|
|||
unlink(fname);
|
||||
r = toku_brt_create(&t); assert(r == 0);
|
||||
r = toku_brt_set_nodesize(t, 4096); assert(r == 0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn, 0); assert(r==0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn); assert(r==0);
|
||||
|
||||
for (i=0; i<n; i++) {
|
||||
DBT key, val;
|
||||
|
@ -975,7 +978,7 @@ static void test_new_brt_cursor_prev(int n) {
|
|||
unlink(fname);
|
||||
r = toku_brt_create(&t); assert(r == 0);
|
||||
r = toku_brt_set_nodesize(t, 4096); assert(r == 0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn, 0); assert(r==0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn); assert(r==0);
|
||||
|
||||
for (i=0; i<n; i++) {
|
||||
DBT key, val;
|
||||
|
@ -1018,7 +1021,7 @@ static void test_new_brt_cursor_current(int n) {
|
|||
unlink(fname);
|
||||
r = toku_brt_create(&t); assert(r == 0);
|
||||
r = toku_brt_set_nodesize(t, 4096); assert(r == 0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn, 0); assert(r==0);
|
||||
r = toku_brt_open(t, fname, 1, 1, ct, null_txn); assert(r==0);
|
||||
|
||||
for (i=0; i<n; i++) {
|
||||
int k = toku_htonl(i);
|
||||
|
@ -1100,7 +1103,7 @@ static void test_new_brt_cursor_set_range(int n) {
|
|||
unlink(fname);
|
||||
r = toku_brt_create(&brt); assert(r == 0);
|
||||
r = toku_brt_set_nodesize(brt, 4096); assert(r == 0);
|
||||
r = toku_brt_open(brt, fname, 1, 1, ct, null_txn, 0); assert(r==0);
|
||||
r = toku_brt_open(brt, fname, 1, 1, ct, null_txn); assert(r==0);
|
||||
|
||||
int i;
|
||||
|
||||
|
@ -1158,7 +1161,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, 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, test_brt_cursor_keycompare, db); assert(r==0);
|
||||
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare); assert(r==0);
|
||||
|
||||
int i;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue