Commit 0bc5013e authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

fixes #5423 fixes #5424 fixes #5503 fixes #5225 fsync always succeeds and...

fixes #5423 fixes #5424 fixes #5503 fixes #5225 fsync always succeeds and returns void, no more ft panic or logger panic, no more impossible error paths


git-svn-id: file:///svn/toku/tokudb@48076 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3dbcdf47
......@@ -696,21 +696,21 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) {
printf("const char *db_strerror(int) %s;\n", VISIBLE);
printf("const char *db_version(int*,int *,int *) %s;\n", VISIBLE);
printf("int log_compare (const DB_LSN*, const DB_LSN *) %s;\n", VISIBLE);
printf("int db_env_set_func_fsync (int (*)(int)) %s;\n", VISIBLE);
printf("int toku_set_trace_file (const char *fname) %s;\n", VISIBLE);
printf("int toku_close_trace_file (void) %s;\n", VISIBLE);
printf("int db_env_set_func_free (void (*)(void*)) %s;\n", VISIBLE);
printf("int db_env_set_func_malloc (void *(*)(size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_realloc (void *(*)(void*, size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_fdopen (FILE* (*)(int, const char *)) %s;\n", VISIBLE);
printf("int db_env_set_func_fopen (FILE* (*)(const char *, const char *)) %s;\n", VISIBLE);
printf("int db_env_set_func_open (int (*)(const char *, int, int)) %s;\n", VISIBLE);
printf("int db_env_set_func_fclose (int (*)(FILE*)) %s;\n", VISIBLE);
printf("int db_env_set_func_pread (ssize_t (*)(int, void *, size_t, off_t)) %s;\n", VISIBLE);
printf("void db_env_set_func_fsync (int (*)(int)) %s;\n", VISIBLE);
printf("void db_env_set_func_free (void (*)(void*)) %s;\n", VISIBLE);
printf("void db_env_set_func_malloc (void *(*)(size_t)) %s;\n", VISIBLE);
printf("void db_env_set_func_realloc (void *(*)(void*, size_t)) %s;\n", VISIBLE);
printf("void db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n", VISIBLE);
printf("void db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n", VISIBLE);
printf("void db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE);
printf("void db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE);
printf("void db_env_set_func_fdopen (FILE* (*)(int, const char *)) %s;\n", VISIBLE);
printf("void db_env_set_func_fopen (FILE* (*)(const char *, const char *)) %s;\n", VISIBLE);
printf("void db_env_set_func_open (int (*)(const char *, int, int)) %s;\n", VISIBLE);
printf("void db_env_set_func_fclose (int (*)(FILE*)) %s;\n", VISIBLE);
printf("void db_env_set_func_pread (ssize_t (*)(int, void *, size_t, off_t)) %s;\n", VISIBLE);
printf("void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) %s;\n", VISIBLE);
printf("void db_env_set_checkpoint_callback (void (*)(void*), void*) %s;\n", VISIBLE);
printf("void db_env_set_checkpoint_callback2 (void (*)(void*), void*) %s;\n", VISIBLE);
......
......@@ -365,16 +365,6 @@ toku_ft_unlock (FT ft) {
unlock_for_blocktable(bt);
}
// This is a special debugging function used only in the brt-serialize-test.
void
toku_block_alloc(BLOCK_TABLE bt, uint64_t size, uint64_t *offset) {
lock_for_blocktable(bt);
PRNTF("allocSomethingUnknown", 0L, (int64_t)size, 0L, bt);
block_allocator_alloc_block(bt->block_allocator, size, offset);
PRNTF("allocSomethingUnknownd", 0L, (int64_t)size, (int64_t)*offset, bt);
unlock_for_blocktable(bt);
}
// Also used only in brt-serialize-test.
void
toku_block_free(BLOCK_TABLE bt, uint64_t offset) {
......
......@@ -57,7 +57,6 @@ void toku_block_table_swap_for_redirect(BLOCK_TABLE old_bt, BLOCK_TABLE new_bt);
//DEBUG ONLY (ftdump included), tests included
void toku_blocknum_dump_translation(BLOCK_TABLE bt, BLOCKNUM b);
void toku_dump_translation_table(FILE *f, BLOCK_TABLE bt);
void toku_block_alloc(BLOCK_TABLE bt, uint64_t size, uint64_t *offset);
void toku_block_free(BLOCK_TABLE bt, uint64_t offset);
typedef int(*BLOCKTABLE_CALLBACK)(BLOCKNUM b, int64_t size, int64_t address, void *extra);
enum translation_type {TRANSLATION_NONE=0,
......
......@@ -108,14 +108,14 @@ struct cachefile {
char *fname_in_env; /* Used for logging */
void *userdata;
int (*log_fassociate_during_checkpoint)(CACHEFILE cf, void *userdata); // When starting a checkpoint we must log all open files.
int (*log_suppress_rollback_during_checkpoint)(CACHEFILE cf, void *userdata); // When starting a checkpoint we must log which files need rollbacks suppressed
int (*close_userdata)(CACHEFILE cf, int fd, void *userdata, char **error_string, bool lsnvalid, LSN); // when closing the last reference to a cachefile, first call this function.
int (*begin_checkpoint_userdata)(LSN lsn_of_checkpoint, void *userdata); // before checkpointing cachefiles call this function.
void (*log_fassociate_during_checkpoint)(CACHEFILE cf, void *userdata); // When starting a checkpoint we must log all open files.
void (*log_suppress_rollback_during_checkpoint)(CACHEFILE cf, void *userdata); // When starting a checkpoint we must log which files need rollbacks suppressed
int (*close_userdata)(CACHEFILE cf, int fd, void *userdata, bool lsnvalid, LSN); // when closing the last reference to a cachefile, first call this function.
void (*begin_checkpoint_userdata)(LSN lsn_of_checkpoint, void *userdata); // before checkpointing cachefiles call this function.
int (*checkpoint_userdata)(CACHEFILE cf, int fd, void *userdata); // when checkpointing a cachefile, call this function.
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
void (*end_checkpoint_userdata)(CACHEFILE cf, int fd, void *userdata); // after checkpointing cachefiles call this function.
void (*note_pin_by_checkpoint)(CACHEFILE cf, void *userdata); // add a reference to the userdata to prevent it from being removed from memory
void (*note_unpin_by_checkpoint)(CACHEFILE cf, void *userdata); // add a reference to the userdata to prevent it from being removed from memory
BACKGROUND_JOB_MANAGER bjm;
};
......@@ -262,7 +262,7 @@ public:
toku_pthread_rwlock_t m_pending_lock_expensive;
toku_pthread_rwlock_t m_pending_lock_cheap;
void init();
int destroy();
void destroy();
void evict(PAIR pair);
void put(PAIR pair);
PAIR find_pair(CACHEFILE file, CACHEKEY key, uint32_t hash);
......@@ -317,14 +317,14 @@ class checkpointer {
public:
void init(pair_list *_pl, TOKULOGGER _logger, evictor *_ev, cachefile_list *files);
void destroy();
int set_checkpoint_period(uint32_t new_period);
void set_checkpoint_period(uint32_t new_period);
uint32_t get_checkpoint_period();
int shutdown();
bool has_been_shutdown();
int begin_checkpoint();
void begin_checkpoint();
void add_background_job();
void remove_background_job();
int end_checkpoint(void (*testcallback_f)(void*), void* testextra);
void end_checkpoint(void (*testcallback_f)(void*), void* testextra);
TOKULOGGER get_logger();
// used during begin_checkpoint
void increment_num_txns();
......@@ -351,7 +351,7 @@ private:
void checkpoint_userdata(CACHEFILE* checkpoint_cfs);
void log_end_checkpoint();
void end_checkpoint_userdata(CACHEFILE* checkpoint_cfs);
int remove_cachefiles(CACHEFILE* checkpoint_cfs);
void remove_cachefiles(CACHEFILE* checkpoint_cfs);
// Unit test struct needs access to private members.
friend struct checkpointer_test;
......
This diff is collapsed.
......@@ -11,7 +11,6 @@
#include "fttypes.h"
#include "minicron.h"
// Maintain a cache mapping from cachekeys to values (void*)
// Some of the keys can be pinned. Don't pin too many or for too long.
// If the cachetable is too full, it will call the flush_callback() function with the key, the value, and the otherargs
......@@ -27,10 +26,10 @@
typedef BLOCKNUM CACHEKEY;
int toku_set_cleaner_period (CACHETABLE ct, uint32_t new_period);
void toku_set_cleaner_period (CACHETABLE ct, uint32_t new_period);
uint32_t toku_get_cleaner_period (CACHETABLE ct);
uint32_t toku_get_cleaner_period_unlocked (CACHETABLE ct);
int toku_set_cleaner_iterations (CACHETABLE ct, uint32_t new_iterations);
void toku_set_cleaner_iterations (CACHETABLE ct, uint32_t new_iterations);
uint32_t toku_get_cleaner_iterations (CACHETABLE ct);
uint32_t toku_get_cleaner_iterations_unlocked (CACHETABLE ct);
......@@ -39,7 +38,7 @@ uint32_t toku_get_cleaner_iterations_unlocked (CACHETABLE ct);
// create and initialize a cache table
// size_limit is the upper limit on the size of the size of the values in the table
// pass 0 if you want the default
int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKULOGGER);
void toku_cachetable_create(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKULOGGER);
// Create a new cachetable.
// Effects: a new cachetable is created and initialized.
......@@ -62,11 +61,11 @@ int toku_cachefile_of_iname_in_env (CACHETABLE ct, const char *iname_in_env, CAC
// Get the iname (within the cwd) associated with the cachefile
// Return the filename
char * toku_cachefile_fname_in_cwd (CACHEFILE cf);
char *toku_cachefile_fname_in_cwd (CACHEFILE cf);
void toku_cachetable_begin_checkpoint (CHECKPOINTER cp, TOKULOGGER);
// TODO: #1510 Add comments on how these behave
int toku_cachetable_begin_checkpoint (CHECKPOINTER cp, TOKULOGGER);
int toku_cachetable_end_checkpoint(CHECKPOINTER cp, TOKULOGGER logger,
void toku_cachetable_end_checkpoint(CHECKPOINTER cp, TOKULOGGER logger,
void (*testcallback_f)(void*), void * testextra);
// Shuts down checkpoint thread
......@@ -75,15 +74,15 @@ void toku_cachetable_minicron_shutdown(CACHETABLE ct);
// Close the cachetable.
// Effects: All of the memory objects are flushed to disk, and the cachetable is destroyed.
int toku_cachetable_close (CACHETABLE*); /* Flushes everything to disk, and destroys the cachetable. */
void toku_cachetable_close(CACHETABLE *ct);
// Open a file and bind the file to a new cachefile object. (For use by test programs only.)
int toku_cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname_in_env*/, int flags, mode_t mode);
int toku_cachetable_openf(CACHEFILE *,CACHETABLE, const char *fname_in_env, int flags, mode_t mode);
// Bind a file to a new cachefile object.
int toku_cachetable_openfd (CACHEFILE *,CACHETABLE, int /*fd*/,
const char *fname_relative_to_env); /*(used for logging)*/
int toku_cachetable_openfd_with_filenum (CACHEFILE *,CACHETABLE, int /*fd*/,
int toku_cachetable_openfd(CACHEFILE *,CACHETABLE, int fd,
const char *fname_relative_to_env);
int toku_cachetable_openfd_with_filenum (CACHEFILE *,CACHETABLE, int fd,
const char *fname_in_env,
FILENUM filenum);
......@@ -100,8 +99,7 @@ void toku_cachetable_release_reserved_memory(CACHETABLE, uint64_t);
// cachefile operations
// Does an fsync of a cachefile.
// Handles the case where cf points to /dev/null
int toku_cachefile_fsync(CACHEFILE cf);
void toku_cachefile_fsync(CACHEFILE cf);
enum partial_eviction_cost {
PE_CHEAP=0, // running partial eviction is cheap, and can be done on the client thread
......@@ -189,14 +187,14 @@ typedef void (*CACHETABLE_GET_KEY_AND_FULLHASH)(CACHEKEY* cachekey, uint32_t* fu
typedef void (*CACHETABLE_REMOVE_KEY)(CACHEKEY* cachekey, bool for_checkpoint, void* extra);
void toku_cachefile_set_userdata(CACHEFILE cf, void *userdata,
int (*log_fassociate_during_checkpoint)(CACHEFILE, void*),
int (*log_suppress_rollback_during_checkpoint)(CACHEFILE, void*),
int (*close_userdata)(CACHEFILE, int, void*, char **/*error_string*/, bool, LSN),
void (*log_fassociate_during_checkpoint)(CACHEFILE, void*),
void (*log_suppress_rollback_during_checkpoint)(CACHEFILE, void*),
int (*close_userdata)(CACHEFILE, int, void*, bool, LSN),
int (*checkpoint_userdata)(CACHEFILE, int, void*),
int (*begin_checkpoint_userdata)(LSN, void*),
int (*end_checkpoint_userdata)(CACHEFILE, int, void*),
int (*note_pin_by_checkpoint)(CACHEFILE, void*),
int (*note_unpin_by_checkpoint)(CACHEFILE, void*));
void (*begin_checkpoint_userdata)(LSN, void*),
void (*end_checkpoint_userdata)(CACHEFILE, int, void*),
void (*note_pin_by_checkpoint)(CACHEFILE, void*),
void (*note_unpin_by_checkpoint)(CACHEFILE, void*));
// Effect: Store some cachefile-specific user data. When the last reference to a cachefile is closed, we call close_userdata().
// Before starting a checkpoint, we call checkpoint_prepare_userdata().
// When the cachefile needs to be checkpointed, we call checkpoint_userdata().
......@@ -220,10 +218,10 @@ typedef enum {
// put something into the cachetable and checkpoint dependent pairs
// if the checkpointing is necessary
int toku_cachetable_put_with_dep_pairs(
void toku_cachetable_put_with_dep_pairs(
CACHEFILE cachefile,
CACHETABLE_GET_KEY_AND_FULLHASH get_key_and_fullhash,
void*value,
void *value,
PAIR_ATTR attr,
CACHETABLE_WRITE_CALLBACK write_callback,
void *get_key_and_fullhash_extra,
......@@ -241,9 +239,7 @@ int toku_cachetable_put_with_dep_pairs(
// Effects: Lookup the key in the cachetable. If the key is not in the cachetable,
// then insert the pair and pin it. Otherwise return an error. Some of the key
// value pairs may be evicted from the cachetable when the cachetable gets too big.
// Returns: 0 if the memory object is placed into the cachetable, otherwise an
// error number.
int toku_cachetable_put(CACHEFILE cf, CACHEKEY key, uint32_t fullhash,
void toku_cachetable_put(CACHEFILE cf, CACHEKEY key, uint32_t fullhash,
void *value, PAIR_ATTR size,
CACHETABLE_WRITE_CALLBACK write_callback,
CACHETABLE_PUT_CALLBACK put_callback
......@@ -386,8 +382,6 @@ int toku_cachetable_get_and_pin_nonblocking (
UNLOCKERS unlockers
);
#define CAN_RELEASE_LOCK_DURING_IO
int toku_cachetable_maybe_get_and_pin (CACHEFILE, CACHEKEY, uint32_t /*fullhash*/, void**);
// Effect: Maybe get and pin a memory object.
// This function is similar to the get_and_pin function except that it
......@@ -459,13 +453,13 @@ int toku_cachefile_count_pinned (CACHEFILE, int /*printthem*/ );
// object is freed.
// If oplsn_valid is true then use oplsn as the LSN of the close instead of asking the logger. oplsn_valid being true is only allowed during recovery, and requires that you are removing the last reference (otherwise the lsn wouldn't make it in.)
// Returns: 0 if success, otherwise returns an error number.
int toku_cachefile_close (CACHEFILE*, char **error_string, bool oplsn_valid, LSN oplsn);
int toku_cachefile_close (CACHEFILE*, bool oplsn_valid, LSN oplsn);
// Flush the cachefile.
// Effect: Flush everything owned by the cachefile from the cachetable. All dirty
// blocks are written. All unpinned blocks are evicted from the cachetable.
// Returns: 0 if success, otherwise returns an error number.
int toku_cachefile_flush (CACHEFILE);
void toku_cachefile_flush(CACHEFILE);
// Return on success (different from pread and pwrite)
//int cachefile_pwrite (CACHEFILE, const void *buf, size_t count, toku_off_t offset);
......@@ -527,8 +521,6 @@ void toku_cachetable_verify (CACHETABLE t);
// Not for use in production, but useful for testing.
void toku_cachetable_print_hash_histogram (void) __attribute__((__visibility__("default")));
#define TOKU_CACHETABLE_DO_EVICT_FROM_WRITER 0
void toku_cachetable_maybe_flush_some(CACHETABLE ct);
// for stat64
......@@ -572,11 +564,10 @@ void remove_background_job_from_cf (CACHEFILE cf);
// the cachetable must be notified.
// test-only function
extern int toku_cachetable_get_checkpointing_user_data_status(void);
int toku_cachetable_get_checkpointing_user_data_status(void);
// test-only function
int toku_cleaner_thread_for_test (CACHETABLE ct);
int toku_cleaner_thread (void *cleaner_v);
int toku_cleaner_thread_for_test(CACHETABLE ct);
int toku_cleaner_thread(void *cleaner_v);
#endif
#endif /* CACHETABLE_H */
......@@ -222,7 +222,7 @@ toku_checkpoint(CHECKPOINTER cp, TOKULOGGER logger,
void (*callback_f)(void*), void * extra,
void (*callback2_f)(void*), void * extra2,
checkpoint_caller_t caller_id) {
int r;
int r = 0;
int footprint_offset = (int) caller_id * 1000;
assert(initialized);
......@@ -241,7 +241,7 @@ toku_checkpoint(CHECKPOINTER cp, TOKULOGGER logger,
SET_CHECKPOINT_FOOTPRINT(30);
STATUS_VALUE(CP_TIME_LAST_CHECKPOINT_BEGIN) = time(NULL);
r = toku_cachetable_begin_checkpoint(cp, logger);
toku_cachetable_begin_checkpoint(cp, logger);
toku_ft_open_close_unlock();
multi_operation_checkpoint_unlock();
......@@ -250,7 +250,7 @@ toku_checkpoint(CHECKPOINTER cp, TOKULOGGER logger,
if (r==0) {
if (callback_f)
callback_f(extra); // callback is called with checkpoint_safe_lock still held
r = toku_cachetable_end_checkpoint(cp, logger, callback2_f, extra2);
toku_cachetable_end_checkpoint(cp, logger, callback2_f, extra2);
}
SET_CHECKPOINT_FOOTPRINT(50);
if (r==0 && logger) {
......
......@@ -8,7 +8,7 @@
#ident "$Id$"
int toku_set_checkpoint_period(CACHETABLE ct, uint32_t new_period);
void toku_set_checkpoint_period(CACHETABLE ct, uint32_t new_period);
//Effect: Change [end checkpoint (n) - begin checkpoint (n+1)] delay to
// new_period seconds. 0 means disable.
......
......@@ -45,7 +45,7 @@ cachetable_put_empty_node_with_dep_nodes(
dependent_dirty_bits[i] = (enum cachetable_dirty) dependent_nodes[i]->dirty;
}
int r = toku_cachetable_put_with_dep_pairs(
toku_cachetable_put_with_dep_pairs(
h->cf,
ftnode_get_key_and_fullhash,
new_node,
......@@ -60,7 +60,6 @@ cachetable_put_empty_node_with_dep_nodes(
name,
fullhash,
toku_node_save_ct_pair);
assert_zero(r);
*result = new_node;
}
......
......@@ -1034,7 +1034,6 @@ flush_this_child(
// Effect: Push everything in the CHILDNUMth buffer of node down into the child.
{
update_flush_status(child, 0);
int r;
toku_assert_entire_node_in_memory(node);
if (fa->should_destroy_basement_nodes(fa)) {
maybe_destroy_child_blbs(node, child, h);
......@@ -1053,7 +1052,7 @@ flush_this_child(
set_BNC(node, childnum, toku_create_empty_nl());
// now we have a bnc to flush to the child
r = toku_bnc_flush_to_child(h, bnc, child); assert_zero(r);
toku_bnc_flush_to_child(h, bnc, child);
destroy_nonleaf_childinfo(bnc);
}
......@@ -1136,8 +1135,7 @@ merge_leaf_nodes(FTNODE a, FTNODE b)
b->n_children = 0;
}
static int
balance_leaf_nodes(
static void balance_leaf_nodes(
FTNODE a,
FTNODE b,
DBT *splitk)
......@@ -1151,8 +1149,6 @@ balance_leaf_nodes(
// now split them
// because we are not creating a new node, we can pass in no dependent nodes
ftleaf_split(NULL, a, &a, &b, splitk, false, 0, NULL);
return 0;
}
static void
......@@ -1184,8 +1180,7 @@ maybe_merge_pinned_leaf_nodes(
// one is less than 1/4 of a node, and together they are more than 3/4 of a node.
toku_free(parent_splitk->data); // We don't need the parent_splitk any more. If we need a splitk (if we don't merge) we'll malloc a new one.
*did_rebalance = true;
int r = balance_leaf_nodes(a, b, splitk);
assert(r==0);
balance_leaf_nodes(a, b, splitk);
} else {
// we are merging them.
*did_merge = true;
......@@ -1478,7 +1473,6 @@ flush_some_child(
call_flusher_thread_callback(flt_flush_before_child_pin);
// get the child into memory
int r;
BLOCKNUM targetchild = BP_BLOCKNUM(parent, childnum);
toku_verify_blocknum_allocated(h->blocktable, targetchild);
uint32_t childfullhash = compute_child_fullhash(h->cf, parent, childnum);
......@@ -1557,12 +1551,11 @@ flush_some_child(
child->dirty = 1;
}
// do the actual flush
r = toku_bnc_flush_to_child(
toku_bnc_flush_to_child(
h,
bnc,
child
);
assert_zero(r);
destroy_nonleaf_childinfo(bnc);
}
......@@ -1736,7 +1729,6 @@ struct flusher_extra {
//
static void flush_node_fun(void *fe_v)
{
int r;
struct flusher_extra* fe = (struct flusher_extra *) fe_v;
// The node that has been placed on the background
// thread may not be fully in memory. Some message
......@@ -1761,12 +1753,11 @@ static void flush_node_fun(void *fe_v)
// for test purposes
call_flusher_thread_callback(flt_flush_before_applying_inbox);
r = toku_bnc_flush_to_child(
toku_bnc_flush_to_child(
fe->h,
fe->bnc,
fe->node
);
assert_zero(r);
destroy_nonleaf_childinfo(fe->bnc);
// after the flush has completed, now check to see if the node needs flushing
......
......@@ -131,15 +131,10 @@ unsigned int toku_bnc_nbytesinbuf(NONLEAF_CHILDINFO bnc);
int toku_bnc_n_entries(NONLEAF_CHILDINFO bnc);
long toku_bnc_memory_size(NONLEAF_CHILDINFO bnc);
long toku_bnc_memory_used(NONLEAF_CHILDINFO bnc);
int toku_bnc_insert_msg(NONLEAF_CHILDINFO bnc, const void *key, ITEMLEN keylen, const void *data, ITEMLEN datalen, enum ft_msg_type type, MSN msn, XIDS xids, bool is_fresh, DESCRIPTOR desc, ft_compare_func cmp);
void toku_bnc_insert_msg(NONLEAF_CHILDINFO bnc, const void *key, ITEMLEN keylen, const void *data, ITEMLEN datalen, enum ft_msg_type type, MSN msn, XIDS xids, bool is_fresh, DESCRIPTOR desc, ft_compare_func cmp);
void toku_bnc_empty(NONLEAF_CHILDINFO bnc);
int toku_bnc_flush_to_child(
FT h,
NONLEAF_CHILDINFO bnc,
FTNODE child
);
bool
toku_ft_nonleaf_is_gorged(FTNODE node, uint32_t nodesize);
void toku_bnc_flush_to_child(FT h, NONLEAF_CHILDINFO bnc, FTNODE child);
bool toku_ft_nonleaf_is_gorged(FTNODE node, uint32_t nodesize);
enum reactivity get_nonleaf_reactivity (FTNODE node);
......@@ -463,11 +458,6 @@ struct ft {
// A checkpoint is running. If true, then keep this header around for checkpoint, like a transaction
bool pinned_by_checkpoint;
// If nonzero there was a write error. Don't write any more, because it probably only gets worse. This is the error code.
int panic;
// A malloced string that can indicate what went wrong.
char *panic_string;
// is this ft a blackhole? if so, all messages are dropped.
bool blackhole;
};
......@@ -550,8 +540,7 @@ deserialize_ft_from_fd_into_rbuf(int fd,
int
deserialize_ft_versioned(int fd, struct rbuf *rb, FT *ft, uint32_t version);
int
read_block_from_fd_into_rbuf(
void read_block_from_fd_into_rbuf(
int fd,
BLOCKNUM blocknum,
FT h,
......@@ -582,9 +571,9 @@ unsigned int toku_serialize_ftnode_size(FTNODE node); /* How much space will it
void toku_verify_or_set_counts(FTNODE);
int toku_serialize_ft_size (FT_HEADER h);
int toku_serialize_ft_to (int fd, FT_HEADER h, BLOCK_TABLE blocktable, CACHEFILE cf);
int toku_serialize_ft_to_wbuf (
size_t toku_serialize_ft_size (FT_HEADER h);
void toku_serialize_ft_to (int fd, FT_HEADER h, BLOCK_TABLE blocktable, CACHEFILE cf);
void toku_serialize_ft_to_wbuf (
struct wbuf *wbuf,
FT_HEADER h,
DISKOFF translation_location_on_disk,
......@@ -892,8 +881,7 @@ int toku_cmd_leafval_heaviside (OMTVALUE leafentry, void *extra)
__attribute__((__warn_unused_result__));
// toku_ft_root_put_cmd() accepts non-constant cmd because this is where we set the msn
int toku_ft_root_put_cmd(FT h, FT_MSG_S * cmd)
__attribute__((__warn_unused_result__));
void toku_ft_root_put_cmd(FT h, FT_MSG_S * cmd);
void *mempool_malloc_from_omt(OMT omt, struct mempool *mp, size_t size, void **maybe_free);
// Effect: Allocate a new object of size SIZE in MP. If MP runs out of space, allocate new a new mempool space, and copy all the items
......
This diff is collapsed.
......@@ -37,10 +37,10 @@ int toku_open_ft_handle (const char *fname, int is_create, FT_HANDLE *, int node
// - can only update cmp descriptor immidiately after opening the FIRST ft handle for this ft and before
// ANY operations. to update the cmp descriptor after any operations have already happened, all handles
// and transactions must close and reopen before the change, then you can update the cmp descriptor
int toku_ft_change_descriptor(FT_HANDLE t, const DBT* old_descriptor, const DBT* new_descriptor, bool do_log, TOKUTXN txn, bool update_cmp_descriptor);
void toku_ft_change_descriptor(FT_HANDLE t, const DBT* old_descriptor, const DBT* new_descriptor, bool do_log, TOKUTXN txn, bool update_cmp_descriptor);
uint32_t toku_serialize_descriptor_size(const DESCRIPTOR desc);
int toku_ft_handle_create(FT_HANDLE *) __attribute__ ((warn_unused_result));
void toku_ft_handle_create(FT_HANDLE *ft);
void toku_ft_set_flags(FT_HANDLE, unsigned int flags);
void toku_ft_get_flags(FT_HANDLE, unsigned int *flags);
void toku_ft_handle_set_nodesize(FT_HANDLE, unsigned int nodesize);
......@@ -51,7 +51,7 @@ void toku_ft_handle_get_basementnodesize(FT_HANDLE, unsigned int *basementnodesi
void toku_ft_handle_set_compression_method(FT_HANDLE, enum toku_compression_method);
void toku_ft_handle_get_compression_method(FT_HANDLE, enum toku_compression_method *);
int toku_ft_set_bt_compare(FT_HANDLE, ft_compare_func) __attribute__ ((warn_unused_result));
void toku_ft_set_bt_compare(FT_HANDLE, ft_compare_func);
ft_compare_func toku_ft_get_bt_compare (FT_HANDLE brt);
void toku_ft_set_redirect_callback(FT_HANDLE brt, on_redirect_callback redir_cb, void* extra);
......@@ -92,7 +92,7 @@ void toku_ft_set_redirect_callback(FT_HANDLE brt, on_redirect_callback redir_cb,
// Implementation note: Acquires a write lock on the entire database.
// This function works by sending an BROADCAST-UPDATE message containing
// the key and the extra.
int toku_ft_set_update(FT_HANDLE brt, ft_update_func update_fun) __attribute__ ((warn_unused_result));
void toku_ft_set_update(FT_HANDLE brt, ft_update_func update_fun);
int toku_ft_handle_open(FT_HANDLE, const char *fname_in_env,
int is_create, int only_create, CACHETABLE ct, TOKUTXN txn) __attribute__ ((warn_unused_result));
......@@ -122,52 +122,44 @@ toku_ft_handle_open_with_dict_id(
int toku_ft_lookup (FT_HANDLE brt, DBT *k, FT_GET_CALLBACK_FUNCTION getf, void *getf_v) __attribute__ ((warn_unused_result));
// Effect: Insert a key and data pair into a brt
// Returns 0 if successful
int toku_ft_insert (FT_HANDLE brt, DBT *k, DBT *v, TOKUTXN txn) __attribute__ ((warn_unused_result));
void toku_ft_insert (FT_HANDLE brt, DBT *k, DBT *v, TOKUTXN txn);
int toku_ft_optimize (FT_HANDLE brt) __attribute__ ((warn_unused_result));
// Effect: Optimize the ft
void toku_ft_optimize (FT_HANDLE brt);
// Effect: Insert a key and data pair into a brt if the oplsn is newer than the brt lsn. This function is called during recovery.
// Returns 0 if successful
int toku_ft_maybe_insert (FT_HANDLE brt, DBT *k, DBT *v, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging, enum ft_msg_type type) __attribute__ ((warn_unused_result));
void toku_ft_maybe_insert (FT_HANDLE brt, DBT *k, DBT *v, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging, enum ft_msg_type type);
// Effect: Send an update message into a brt. This function is called
// during recovery.
// Returns 0 if successful
int toku_ft_maybe_update(FT_HANDLE brt, const DBT *key, const DBT *update_function_extra, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging) __attribute__ ((warn_unused_result));
void toku_ft_maybe_update(FT_HANDLE brt, const DBT *key, const DBT *update_function_extra, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging);
// Effect: Send a broadcasting update message into a brt. This function
// is called during recovery.
// Returns 0 if successful
int toku_ft_maybe_update_broadcast(FT_HANDLE brt, const DBT *update_function_extra, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging, bool is_resetting_op) __attribute__ ((warn_unused_result));
void toku_ft_maybe_update_broadcast(FT_HANDLE brt, const DBT *update_function_extra, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging, bool is_resetting_op);
int toku_ft_load_recovery(TOKUTXN txn, FILENUM old_filenum, char const * new_iname, int do_fsync, int do_log, LSN *load_lsn) __attribute__ ((warn_unused_result));
int toku_ft_load(FT_HANDLE brt, TOKUTXN txn, char const * new_iname, int do_fsync, LSN *get_lsn) __attribute__ ((warn_unused_result));
// 2954
int toku_ft_hot_index_recovery(TOKUTXN txn, FILENUMS filenums, int do_fsync, int do_log, LSN *hot_index_lsn);
int toku_ft_hot_index(FT_HANDLE brt, TOKUTXN txn, FILENUMS filenums, int do_fsync, LSN *lsn) __attribute__ ((warn_unused_result));
void toku_ft_load_recovery(TOKUTXN txn, FILENUM old_filenum, char const * new_iname, int do_fsync, int do_log, LSN *load_lsn);
void toku_ft_load(FT_HANDLE brt, TOKUTXN txn, char const * new_iname, int do_fsync, LSN *get_lsn);
void toku_ft_hot_index_recovery(TOKUTXN txn, FILENUMS filenums, int do_fsync, int do_log, LSN *hot_index_lsn);
void toku_ft_hot_index(FT_HANDLE brt, TOKUTXN txn, FILENUMS filenums, int do_fsync, LSN *lsn);
int toku_ft_log_put_multiple (TOKUTXN txn, FT_HANDLE src_ft, FT_HANDLE *brts, int num_fts, const DBT *key, const DBT *val) __attribute__ ((warn_unused_result));
int toku_ft_log_put (TOKUTXN txn, FT_HANDLE brt, const DBT *key, const DBT *val) __attribute__ ((warn_unused_result));
int toku_ft_log_del_multiple (TOKUTXN txn, FT_HANDLE src_ft, FT_HANDLE *brts, int num_fts, const DBT *key, const DBT *val) __attribute__ ((warn_unused_result));
int toku_ft_log_del (TOKUTXN txn, FT_HANDLE brt, const DBT *key) __attribute__ ((warn_unused_result));
void toku_ft_log_put_multiple (TOKUTXN txn, FT_HANDLE src_ft, FT_HANDLE *brts, int num_fts, const DBT *key, const DBT *val);
void toku_ft_log_put (TOKUTXN txn, FT_HANDLE brt, const DBT *key, const DBT *val);
void toku_ft_log_del_multiple (TOKUTXN txn, FT_HANDLE src_ft, FT_HANDLE *brts, int num_fts, const DBT *key, const DBT *val);
void toku_ft_log_del (TOKUTXN txn, FT_HANDLE brt, const DBT *key);
// Effect: Delete a key from a brt
// Returns 0 if successful
int toku_ft_delete (FT_HANDLE brt, DBT *k, TOKUTXN txn) __attribute__ ((warn_unused_result));
void toku_ft_delete (FT_HANDLE brt, DBT *k, TOKUTXN txn);
// Effect: Delete a key from a brt if the oplsn is newer than the brt lsn. This function is called during recovery.
// Returns 0 if successful
int toku_ft_maybe_delete (FT_HANDLE brt, DBT *k, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging) __attribute__ ((warn_unused_result));
void toku_ft_maybe_delete (FT_HANDLE brt, DBT *k, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging);
int toku_ft_send_insert(FT_HANDLE brt, DBT *key, DBT *val, XIDS xids, enum ft_msg_type type) __attribute__ ((warn_unused_result));
int toku_ft_send_delete(FT_HANDLE brt, DBT *key, XIDS xids) __attribute__ ((warn_unused_result));
int toku_ft_send_commit_any(FT_HANDLE brt, DBT *key, XIDS xids) __attribute__ ((warn_unused_result));
void toku_ft_send_insert(FT_HANDLE brt, DBT *key, DBT *val, XIDS xids, enum ft_msg_type type);
void toku_ft_send_delete(FT_HANDLE brt, DBT *key, XIDS xids);
void toku_ft_send_commit_any(FT_HANDLE brt, DBT *key, XIDS xids);
int toku_close_ft_handle_nolsn (FT_HANDLE, char **error_string) __attribute__ ((warn_unused_result));
int toku_ft_handle_set_panic(FT_HANDLE brt, int panic, const char *panic_string) __attribute__ ((warn_unused_result));
int toku_dump_ft (FILE *,FT_HANDLE brt) __attribute__ ((warn_unused_result));
extern int toku_ft_debug_mode;
......@@ -200,7 +192,7 @@ int toku_ft_cursor_get_both_range(FT_CURSOR cursor, DBT *key, DBT *val, FT_GET_C
int toku_ft_cursor_get_both_range_reverse(FT_CURSOR cursor, DBT *key, DBT *val, FT_GET_CALLBACK_FUNCTION getf, void *getf_v) __attribute__ ((warn_unused_result));
int toku_ft_cursor_delete(FT_CURSOR cursor, int flags, TOKUTXN) __attribute__ ((warn_unused_result));
int toku_ft_cursor_close (FT_CURSOR curs) __attribute__ ((warn_unused_result));
void toku_ft_cursor_close (FT_CURSOR curs);
bool toku_ft_cursor_uninitialized(FT_CURSOR c) __attribute__ ((warn_unused_result));
void toku_ft_cursor_peek(FT_CURSOR cursor, const DBT **pkey, const DBT **pval);
......@@ -214,8 +206,7 @@ enum ft_flags {
TOKU_DB_VALCMP_BUILTIN_13 = (1<<3),
};
int
toku_ft_keyrange (FT_HANDLE brt, DBT *key, uint64_t *less, uint64_t *equal, uint64_t *greater) __attribute__ ((warn_unused_result));
void toku_ft_keyrange(FT_HANDLE brt, DBT *key, uint64_t *less, uint64_t *equal, uint64_t *greater);
struct ftstat64_s {
uint64_t nkeys; /* estimate how many unique keys (even when flattened this may be an estimate) */
......@@ -228,8 +219,7 @@ struct ftstat64_s {
uint64_t verify_time_sec; /* time of last verification, in seconds */
};
int
toku_ft_handle_stat64 (FT_HANDLE, TOKUTXN, struct ftstat64_s *stat) __attribute__ ((warn_unused_result));
void toku_ft_handle_stat64 (FT_HANDLE, TOKUTXN, struct ftstat64_s *stat);
int toku_ft_layer_init(void) __attribute__ ((warn_unused_result));
void toku_ft_open_close_lock(void);
......
......@@ -149,8 +149,6 @@ deserialize_ft_versioned(int fd, struct rbuf *rb, FT *ftp, uint32_t version)
XCALLOC(ft);
ft->checkpoint_header = NULL;
ft->panic = 0;
ft->panic_string = 0;
toku_list_init(&ft->live_ft_handles);
//version MUST be in network order on disk regardless of disk order
......@@ -364,10 +362,9 @@ exit:
return r;
}
static uint32_t
static size_t
serialize_ft_min_size (uint32_t version) {
uint32_t size = 0;
size_t size = 0;
switch(version) {
case FT_LAYOUT_VERSION_20:
......@@ -418,6 +415,7 @@ serialize_ft_min_size (uint32_t version) {
default:
lazy_assert(false);
}
lazy_assert(size <= BLOCK_ALLOCATOR_HEADER_RESERVE);
return size;
}
......@@ -654,15 +652,15 @@ exit:
}
int toku_serialize_ft_size (FT_HEADER h) {
uint32_t size = serialize_ft_min_size(h->layout_version);
size_t toku_serialize_ft_size (FT_HEADER h) {
size_t size = serialize_ft_min_size(h->layout_version);
//There is no dynamic data.
lazy_assert(size <= BLOCK_ALLOCATOR_HEADER_RESERVE);
return size;
}
int toku_serialize_ft_to_wbuf (
void toku_serialize_ft_to_wbuf (
struct wbuf *wbuf,
FT_HEADER h,
DISKOFF translation_location_on_disk,
......@@ -700,59 +698,47 @@ int toku_serialize_ft_to_wbuf (
uint32_t checksum = x1764_finish(&wbuf->checksum);
wbuf_int(wbuf, checksum);
lazy_assert(wbuf->ndone == wbuf->size);
return 0;
}
int toku_serialize_ft_to (int fd, FT_HEADER h, BLOCK_TABLE blocktable, CACHEFILE cf) {
int rr = 0;
void toku_serialize_ft_to (int fd, FT_HEADER h, BLOCK_TABLE blocktable, CACHEFILE cf) {
lazy_assert(h->type==FT_CHECKPOINT_INPROGRESS);
struct wbuf w_translation;
int64_t size_translation;
int64_t address_translation;
{
//Must serialize translation first, to get address,size for header.
toku_serialize_translation_to_wbuf(blocktable, fd, &w_translation,
&address_translation,
&size_translation);
lazy_assert(size_translation==w_translation.size);
}
//Must serialize translation first, to get address,size for header.
toku_serialize_translation_to_wbuf(blocktable, fd, &w_translation,
&address_translation,
&size_translation);
lazy_assert(size_translation == w_translation.size);
struct wbuf w_main;
unsigned int size_main = toku_serialize_ft_size(h);
{
wbuf_init(&w_main, toku_xmalloc(size_main), size_main);
{
int r=toku_serialize_ft_to_wbuf(&w_main, h, address_translation, size_translation);
lazy_assert_zero(r);
}
lazy_assert(w_main.ndone==size_main);
}
{
//Actual Write translation table
toku_os_full_pwrite(fd, w_translation.buf,
size_translation, address_translation);
}
{
//Everything but the header MUST be on disk before header starts.
//Otherwise we will think the header is good and some blocks might not
//yet be on disk.
//If the header has a cachefile we need to do cachefile fsync (to
//prevent crash if we redirected to dev null)
//If there is no cachefile we still need to do an fsync.
if (cf) {
rr = toku_cachefile_fsync(cf);
}
else {
rr = toku_file_fsync(fd);
}
if (rr==0) {
//Alternate writing header to two locations:
// Beginning (0) or BLOCK_ALLOCATOR_HEADER_RESERVE
toku_off_t main_offset;
main_offset = (h->checkpoint_count & 0x1) ? 0 : BLOCK_ALLOCATOR_HEADER_RESERVE;
toku_os_full_pwrite(fd, w_main.buf, w_main.ndone, main_offset);
}
}
size_t size_main = toku_serialize_ft_size(h);
wbuf_init(&w_main, toku_xmalloc(size_main), size_main);
toku_serialize_ft_to_wbuf(&w_main, h, address_translation, size_translation);
lazy_assert(w_main.ndone == size_main);
//Actual Write translation table
toku_os_full_pwrite(fd, w_translation.buf, size_translation, address_translation);
//Everything but the header MUST be on disk before header starts.
//Otherwise we will think the header is good and some blocks might not
//yet be on disk.
//If the header has a cachefile we need to do cachefile fsync (to
//prevent crash if we redirected to dev null)
//If there is no cachefile we still need to do an fsync.
if (cf) {
toku_cachefile_fsync(cf);
}
else {
toku_file_fsync(fd);
}
//Alternate writing header to two locations:
// Beginning (0) or BLOCK_ALLOCATOR_HEADER_RESERVE
toku_off_t main_offset;
main_offset = (h->checkpoint_count & 0x1) ? 0 : BLOCK_ALLOCATOR_HEADER_RESERVE;
toku_os_full_pwrite(fd, w_main.buf, w_main.ndone, main_offset);
toku_free(w_main.buf);
toku_free(w_translation.buf);
return rr;
}
......@@ -208,8 +208,7 @@ int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM blocknum, enum ft_
XIDS xids_0 = xids_get_root_xids();
MSN msn = next_dummymsn();
r = toku_bnc_insert_msg(BNC(node, childnum), key, keylen, val, vallen, cmdtype, msn, xids_0, true, NULL, testhelper_string_key_cmp);
assert(r==0);
toku_bnc_insert_msg(BNC(node, childnum), key, keylen, val, vallen, cmdtype, msn, xids_0, true, NULL, testhelper_string_key_cmp);
// Hack to get the test working. The problem is that this test
// is directly queueing something in a FIFO instead of
// using brt APIs.
......
This diff is collapsed.
......@@ -18,7 +18,7 @@
// unlink a ft from the filesystem with or without a txn.
// if with a txn, then the unlink happens on commit.
void toku_ft_unlink(FT_HANDLE handle);
int toku_ft_unlink_on_commit(FT_HANDLE handle, TOKUTXN txn) __attribute__((__warn_unused_result__));
void toku_ft_unlink_on_commit(FT_HANDLE handle, TOKUTXN txn);
//Effect: suppresses rollback logs
void toku_ft_suppress_rollbacks(FT h, TOKUTXN txn);
......@@ -39,7 +39,7 @@ bool toku_ft_has_one_reference_unlocked(FT ft);
// evict a ft from memory by closing its cachefile. any future work
// will have to read in the ft in a new cachefile and new FT object.
int toku_ft_evict_from_memory(FT ft, char **error_string, bool oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result));
int toku_ft_evict_from_memory(FT ft, bool oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result));
FT_HANDLE toku_ft_get_only_existing_ft_handle(FT h);
......@@ -69,7 +69,6 @@ void toku_ft_remove_txn_ref(FT h);
void toku_calculate_root_offset_pointer ( FT h, CACHEKEY* root_key, uint32_t *roothash);
void toku_ft_set_new_root_blocknum(FT h, CACHEKEY new_root_key);
LSN toku_ft_checkpoint_lsn(FT h) __attribute__ ((warn_unused_result));
int toku_ft_set_panic(FT h, int panic, const char *panic_string) __attribute__ ((warn_unused_result));
void toku_ft_stat64 (FT h, struct ftstat64_s *s);
// unconditionally set the descriptor for an open FT. can't do this when
......
......@@ -1109,32 +1109,21 @@ void destroy_nonleaf_childinfo (NONLEAF_CHILDINFO nl)
toku_free(nl);
}
int
read_block_from_fd_into_rbuf(
void read_block_from_fd_into_rbuf(
int fd,
BLOCKNUM blocknum,
FT h,
struct rbuf *rb
)
{
if (h->panic) {
toku_trace("panic set, will not read block from fd into buf");
return h->panic;
}
toku_trace("deserial start nopanic");
// get the file offset and block size for the block
DISKOFF offset, size;
toku_translate_blocknum_to_offset_size(h->blocktable, blocknum, &offset, &size);
uint8_t *XMALLOC_N(size, raw_block);
rbuf_init(rb, raw_block, size);
{
// read the block
ssize_t rlen = toku_os_pread(fd, raw_block, size, offset);
lazy_assert((DISKOFF)rlen == size);
}
return 0;
// read the block
ssize_t rlen = toku_os_pread(fd, raw_block, size, offset);
lazy_assert((DISKOFF)rlen == size);
}
static const int read_header_heuristic_max = 32*1024;
......@@ -1144,7 +1133,6 @@ static const int read_header_heuristic_max = 32*1024;
static void read_ftnode_header_from_fd_into_rbuf_if_small_enough (int fd, BLOCKNUM blocknum, FT h, struct rbuf *rb)
// Effect: If the header part of the node is small enough, then read it into the rbuf. The rbuf will be allocated to be big enough in any case.
{
assert(!h->panic);
DISKOFF offset, size;
toku_translate_blocknum_to_offset_size(h->blocktable, blocknum, &offset, &size);
DISKOFF read_size = MIN(read_header_heuristic_max, size);
......@@ -2424,17 +2412,12 @@ deserialize_ftnode_from_fd(int fd,
STAT64INFO info)
{
struct rbuf rb = RBUF_INITIALIZER;
int r = 0;
r = read_block_from_fd_into_rbuf(fd, blocknum, bfe->h, &rb);
if (r != 0) {
goto cleanup;
} // if we were successful, then we are done.
read_block_from_fd_into_rbuf(fd, blocknum, bfe->h, &rb);
r = deserialize_ftnode_from_rbuf(ftnode, ndd, blocknum, fullhash, bfe, info, &rb, fd);
int r = deserialize_ftnode_from_rbuf(ftnode, ndd, blocknum, fullhash, bfe, info, &rb, fd);
if (r != 0) {
dump_bad_block(rb.buf,rb.size);
}
cleanup:
toku_free(rb.buf);
return r;
}
......@@ -2533,6 +2516,7 @@ serialize_rollback_log_node_to_buf(ROLLBACK_LOG_NODE log, char *buf, size_t calc
lazy_assert(calculated_size==wb.ndone);
}
// TODO: can't fail. assert on ENOMEM for compressed_buf...
static int
serialize_uncompressed_block_to_memory(char * uncompressed_buf,
int n_sub_blocks,
......@@ -2856,9 +2840,6 @@ read_and_decompress_block_from_fd_into_rbuf(int fd, BLOCKNUM blocknum,
/* out */ int *layout_version_p) {
int r = 0;
if (0) printf("Deserializing Block %" PRId64 "\n", blocknum.b);
if (h->panic) return h->panic;
toku_trace("deserial start nopanic");
// get the file offset and block size for the block
DISKOFF offset, size;
......
......@@ -512,10 +512,9 @@ main (int argc, const char *const argv[]) {
int f = open(n, O_RDWR + O_BINARY); assert(f>=0);
FT ft;
// create a cachefile for the header
int r = toku_create_cachetable(&ct, 1<<25, (LSN){0}, 0);
assert(r == 0);
toku_cachetable_create(&ct, 1<<25, (LSN){0}, 0);
CACHEFILE cf = NULL;
r = toku_cachetable_openfd (&cf, ct, f, n);
int r = toku_cachetable_openfd (&cf, ct, f, n);
assert(r==0);
dump_header(f, &ft, cf);
if (interactive) {
......
......@@ -2784,7 +2784,7 @@ static int write_translation_table (struct dbout *out, long long *off_of_transla
static int
write_header (struct dbout *out, long long translation_location_on_disk, long long translation_size_on_disk) {
int result = 0;
unsigned int size = toku_serialize_ft_size (out->h->h);
size_t size = toku_serialize_ft_size(out->h->h);
struct wbuf wbuf;
char *MALLOC_N(size, buf);
if (buf == NULL) {
......
......@@ -201,13 +201,7 @@ check_block(BLOCKNUM blocknum, int64_t UU(blocksize), int64_t UU(address), void
// Let's read the block off of disk and fill a buffer with that
// block.
struct rbuf rb = RBUF_INITIALIZER;
r = read_block_from_fd_into_rbuf(fd, blocknum, ft, &rb);
if (r != 0) {
// This is impossible without setting the panic member in
// the ft, let's just pretend that it is not and exit.
printf(" Read block failed.\n");
failure++;
}
read_block_from_fd_into_rbuf(fd, blocknum, ft, &rb);
// Allocate the node.
FTNODE XMALLOC(node);
......
......@@ -52,11 +52,9 @@ toku_le_cursor_create(LE_CURSOR *le_cursor_result, FT_HANDLE ft_handle, TOKUTXN
return result;
}
int
toku_le_cursor_close(LE_CURSOR le_cursor) {
int result = toku_ft_cursor_close(le_cursor->ft_cursor);
void toku_le_cursor_close(LE_CURSOR le_cursor) {
toku_ft_cursor_close(le_cursor->ft_cursor);
toku_free(le_cursor);
return result;
}
// Move to the next leaf entry under the LE_CURSOR
......
......@@ -25,9 +25,7 @@ typedef struct le_cursor *LE_CURSOR;
int toku_le_cursor_create(LE_CURSOR *le_cursor_result, FT_HANDLE brt, TOKUTXN txn);
// Close and free the LE_CURSOR
// Success: returns 0
// Failure: returns a non-zero error number
int toku_le_cursor_close(LE_CURSOR le_cursor);
void toku_le_cursor_close(LE_CURSOR le_cursor);
// Move to the next leaf entry under the LE_CURSOR
// Success: returns zero, calls the getf callback with the getf_v parameter
......
......@@ -63,10 +63,8 @@ struct tokulogger {
bool output_is_available; // this is part of the predicate for the output condition. It's true if no thread is modifying the output (either doing an fsync or otherwise fiddling with the output).
bool is_open;
bool is_panicked;
bool write_log_files;
bool trim_log_files; // for test purposes
int panic_errno;
char *directory; // file system directory
DIR *dir; // descriptor for directory
int fd;
......
......@@ -156,6 +156,7 @@ verify_clean_shutdown_of_log_version(const char *log_dir, uint32_t version, LSN
// Actually create a log file of the current version, making the environment be of the current version.
// TODO: can't fail
static int
upgrade_log(const char *env_dir, const char *log_dir, LSN last_lsn, TXNID last_xid) { // the real deal
int r;
......@@ -169,8 +170,7 @@ upgrade_log(const char *env_dir, const char *log_dir, LSN last_lsn, TXNID last_x
FOOTPRINT(1);
{ //Create temporary environment
r = toku_create_cachetable(&ct, 1<<25, initial_lsn, NULL);
assert(r == 0);
toku_cachetable_create(&ct, 1<<25, initial_lsn, NULL);
toku_cachetable_set_env_dir(ct, env_dir);
r = toku_logger_create(&logger);
assert(r == 0);
......@@ -184,10 +184,8 @@ upgrade_log(const char *env_dir, const char *log_dir, LSN last_lsn, TXNID last_x
assert(r == 0);
}
{ //Close cachetable and logger
r = toku_logger_shutdown(logger);
assert(r==0);
r = toku_cachetable_close(&ct);
assert(r==0);
toku_logger_shutdown(logger);
toku_cachetable_close(&ct);
r = toku_logger_close(&logger);
assert(r==0);
}
......
......@@ -395,7 +395,7 @@ generate_log_writer (void) {
fprintf(hf, "static const size_t toku_log_%s_overhead = (+4+1+8", lt->name);
DO_FIELDS(field_type, lt, fprintf(hf, "+sizeof(%s)", field_type->type));
fprintf(hf, "+8);\n");
fprintf2(cf, hf, "int toku_log_%s (TOKULOGGER logger, LSN *lsnp, int do_fsync", lt->name);
fprintf2(cf, hf, "void toku_log_%s (TOKULOGGER logger, LSN *lsnp, int do_fsync", lt->name);
switch (lt->log_begin_action) {
case SHOULD_LOG_BEGIN:
case ASSERT_BEGIN_WAS_LOGGED: {
......@@ -407,8 +407,9 @@ generate_log_writer (void) {
DO_FIELDS(field_type, lt, fprintf2(cf, hf, ", %s %s", field_type->type, field_type->name));
fprintf(hf, ");\n");
fprintf(cf, ") {\n");
fprintf(cf, " int r = 0;\n");
fprintf(cf, " if (logger==0) return 0;\n");
fprintf(cf, " if (logger == NULL) {\n");
fprintf(cf, " return;\n");
fprintf(cf, " }\n");
switch (lt->log_begin_action) {
case SHOULD_LOG_BEGIN: {
fprintf(cf, " //txn can be NULL during tests\n");
......@@ -431,7 +432,7 @@ generate_log_writer (void) {
fprintf(cf, " logger->lsn.lsn++;\n");
fprintf(cf, " if (lsnp) *lsnp=logger->lsn;\n");
fprintf(cf, " ml_unlock(&logger->input_lock);\n");
fprintf(cf, " return 0;\n");
fprintf(cf, " return;\n");
fprintf(cf, " }\n");
fprintf(cf, " const unsigned int buflen= (+4 // len at the beginning\n");
fprintf(cf, " +1 // log command\n");
......@@ -442,8 +443,7 @@ generate_log_writer (void) {
fprintf(cf, " );\n");
fprintf(cf, " struct wbuf wbuf;\n");
fprintf(cf, " ml_lock(&logger->input_lock);\n");
fprintf(cf, " r = toku_logger_make_space_in_inbuf(logger, buflen);\n");
fprintf(cf, " if (r!=0) goto panic;\n");
fprintf(cf, " toku_logger_make_space_in_inbuf(logger, buflen);\n");
fprintf(cf, " wbuf_nocrc_init(&wbuf, logger->inbuf.buf+logger->inbuf.n_in_buf, buflen);\n");
fprintf(cf, " wbuf_nocrc_int(&wbuf, buflen);\n");
fprintf(cf, " wbuf_nocrc_char(&wbuf, '%c');\n", (char)(0xff&lt->command_and_flags));
......@@ -459,12 +459,7 @@ generate_log_writer (void) {
fprintf(cf, " wbuf_nocrc_int(&wbuf, buflen);\n");
fprintf(cf, " assert(wbuf.ndone==buflen);\n");
fprintf(cf, " logger->inbuf.n_in_buf += buflen;\n");
fprintf(cf, " r = toku_logger_maybe_fsync(logger, logger->lsn, do_fsync);\n");
fprintf(cf, " if (r!=0) goto panic;\n");
fprintf(cf, " return 0;\n");
fprintf(cf, " panic:\n");
fprintf(cf, " toku_logger_panic(logger, r);\n");
fprintf(cf, " return r;\n");
fprintf(cf, " toku_logger_maybe_fsync(logger, logger->lsn, do_fsync);\n");
fprintf(cf, "}\n\n");
});
}
......@@ -595,7 +590,7 @@ generate_logprint (void) {
fprintf(pf, " if (len_in_file!=len || crc_in_file!=actual_murmur) return DB_BADFORMAT;\n");
fprintf(pf, " };\n");
fprintf(pf, " fprintf(outf, \"\\n\");\n");
fprintf(pf, " return 0;;\n\n");
fprintf(pf, " return 0;\n\n");
});
fprintf(pf, " }\n");
fprintf(pf, " fprintf(outf, \"Unknown command %%d ('%%c')\", cmd, cmd);\n");
......@@ -606,7 +601,7 @@ generate_logprint (void) {
static void
generate_rollbacks (void) {
DO_ROLLBACKS(lt, {
fprintf2(cf, hf, "int toku_logger_save_rollback_%s (TOKUTXN txn", lt->name);
fprintf2(cf, hf, "void toku_logger_save_rollback_%s (TOKUTXN txn", lt->name);
DO_FIELDS(field_type, lt, {
if ( strcmp(field_type->type, "BYTESTRING") == 0 ) {
fprintf2(cf, hf, ", BYTESTRING *%s_ptr", field_type->name);
......@@ -664,7 +659,7 @@ generate_rollbacks (void) {
fprintf(cf, " toku_maybe_spill_rollbacks(txn, log);\n");
fprintf(cf, " toku_rollback_log_unpin(txn, log);\n");
fprintf(cf, " toku_txn_unlock(txn);\n");
fprintf(cf, " return 0;\n}\n");
fprintf(cf, "}\n");
});
DO_ROLLBACKS(lt, {
......
This diff is collapsed.
......@@ -23,25 +23,20 @@ enum {
int toku_logger_create (TOKULOGGER *resultp);
int toku_logger_open (const char *directory, TOKULOGGER logger);
int toku_logger_open_with_last_xid(const char *directory, TOKULOGGER logger, TXNID last_xid);
int toku_logger_shutdown(TOKULOGGER logger);
void toku_logger_shutdown(TOKULOGGER logger);
int toku_logger_close(TOKULOGGER *loggerp);
int toku_logger_open_rollback(TOKULOGGER logger, CACHETABLE cachetable, bool create);
int toku_logger_close_rollback(TOKULOGGER logger, bool recovery_failed);
int toku_logger_close_rollback(TOKULOGGER logger);
bool toku_logger_rollback_is_open (TOKULOGGER); // return true iff the rollback is open.
int toku_logger_fsync (TOKULOGGER logger);
int toku_logger_fsync_if_lsn_not_fsynced(TOKULOGGER logger, LSN lsn);
void toku_logger_panic (TOKULOGGER logger, int err);
int toku_logger_panicked(TOKULOGGER logger);
int toku_logger_is_open(TOKULOGGER logger);
void toku_logger_set_cachetable (TOKULOGGER logger, CACHETABLE ct);
int toku_logger_set_lg_max(TOKULOGGER logger, uint32_t lg_max);
int toku_logger_get_lg_max(TOKULOGGER logger, uint32_t *lg_maxp);
int toku_logger_set_lg_bsize(TOKULOGGER logger, uint32_t bsize);
int toku_logger_lock_init(void);
int toku_logger_lock_destroy(void);
void toku_logger_write_log_files (TOKULOGGER logger, bool write_log_files);
void toku_logger_trim_log_files(TOKULOGGER logger, bool trim_log_files);
......@@ -58,9 +53,9 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn);
// Returns: 0 if success
int toku_logger_maybe_trim_log(TOKULOGGER logger, LSN oldest_open_lsn);
int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, uint32_t mode, uint32_t flags, uint32_t nodesize, uint32_t basementnodesize, enum toku_compression_method compression_method);
int toku_logger_log_fdelete (TOKUTXN txn, FILENUM filenum);
int toku_logger_log_fopen (TOKUTXN txn, const char * fname, FILENUM filenum, uint32_t treeflags);
void toku_logger_log_fcreate(TOKUTXN txn, const char *fname, FILENUM filenum, uint32_t mode, uint32_t flags, uint32_t nodesize, uint32_t basementnodesize, enum toku_compression_method compression_method);
void toku_logger_log_fdelete(TOKUTXN txn, FILENUM filenum);
void toku_logger_log_fopen(TOKUTXN txn, const char * fname, FILENUM filenum, uint32_t treeflags);
int toku_fread_uint8_t (FILE *f, uint8_t *v, struct x1764 *mm, uint32_t *len);
int toku_fread_uint32_t_nocrclen (FILE *f, uint32_t *v);
......@@ -91,7 +86,6 @@ int toku_read_and_print_logmagic (FILE *f, uint32_t *versionp);
int toku_read_logmagic (FILE *f, uint32_t *versionp);
TXNID toku_txn_get_txnid (TOKUTXN txn);
TXNID toku_txn_get_root_txnid (TOKUTXN txn);
LSN toku_logger_last_lsn(TOKULOGGER logger);
TOKULOGGER toku_txn_logger (TOKUTXN txn);
......@@ -103,12 +97,9 @@ int toku_logger_log_archive (TOKULOGGER logger, char ***logs_p, int flags);
TOKUTXN toku_logger_txn_parent (TOKUTXN txn);
void toku_logger_note_checkpoint(TOKULOGGER logger, LSN lsn);
LSN toku_logger_get_next_lsn(TOKULOGGER logger);
int toku_logger_make_space_in_inbuf (TOKULOGGER logger, int n_bytes_needed);
void toku_logger_make_space_in_inbuf (TOKULOGGER logger, int n_bytes_needed);
int
toku_logger_write_inbuf (TOKULOGGER logger);
int toku_logger_write_inbuf (TOKULOGGER logger);
// Effect: Write the buffered data (from the inbuf) to a file. No fsync, however.
// As a side effect, the inbuf will be made empty.
// Return 0 on success, otherwise return an error number.
......@@ -119,9 +110,7 @@ toku_logger_write_inbuf (TOKULOGGER logger);
// Rationale: When the buffer becomes nearly full, call this function so that more can be put in.
// Implementation note: Since the output lock is acquired first, we must release the input lock, and then grab both in the right order.
int
toku_logger_maybe_fsync (TOKULOGGER logger, LSN lsn, int do_fsync);
void toku_logger_maybe_fsync (TOKULOGGER logger, LSN lsn, int do_fsync);
// Effect: If fsync is nonzero, then make sure that the log is flushed and synced at least up to lsn.
// Entry: Holds input lock.
// Exit: Holds no locks.
......@@ -163,14 +152,11 @@ toku_logger_maybe_fsync (TOKULOGGER logger, LSN lsn, int do_fsync);
// fsync
// release the outlock
typedef enum {
LOGGER_NEXT_LSN = 0,
LOGGER_ILOCK_CTR,
LOGGER_OLOCK_CTR,
LOGGER_SWAP_CTR,
LOGGER_PANICKED,
LOGGER_PANIC_ERRNO,
LOGGER_STATUS_NUM_ROWS
} logger_status_entry;
......@@ -179,17 +165,12 @@ typedef struct {
TOKU_ENGINE_STATUS_ROW_S status[LOGGER_STATUS_NUM_ROWS];
} LOGGER_STATUS_S, *LOGGER_STATUS;
void toku_logger_get_status(TOKULOGGER logger, LOGGER_STATUS s);
int toku_get_version_of_logs_on_disk(const char *log_dir, bool *found_any_logs, uint32_t *version_found);
int toku_delete_all_logs_of_version(const char *log_dir, uint32_t version_to_delete);
TXN_MANAGER toku_logger_get_txn_manager(TOKULOGGER logger);
static const TOKULOGGER NULL_logger __attribute__((__unused__)) = NULL;
#endif
#endif /* TOKU_LOGGER_H */
......@@ -98,14 +98,13 @@ toku_minicron_setup(struct minicron *p, uint32_t period_in_seconds, int(*f)(void
return toku_pthread_create(&p->thread, 0, minicron_do, p);
}
int
void
toku_minicron_change_period(struct minicron *p, uint32_t new_period)
{
toku_mutex_lock(&p->mutex);
p->period_in_seconds = new_period;
toku_cond_signal(&p->condvar);
toku_mutex_unlock(&p->mutex);
return 0;
}
uint32_t
......
......@@ -37,7 +37,7 @@ struct minicron {
};
int toku_minicron_setup (struct minicron *s, uint32_t period_in_seconds, int(*f)(void *), void *arg);
int toku_minicron_change_period(struct minicron *p, uint32_t new_period);
void toku_minicron_change_period(struct minicron *p, uint32_t new_period);
uint32_t toku_minicron_get_period(struct minicron *p);
uint32_t toku_minicron_get_period_unlocked(struct minicron *p);
int toku_minicron_shutdown(struct minicron *p);
......
This diff is collapsed.
......@@ -179,8 +179,8 @@ static int do_insertion (enum ft_msg_type type, FILENUM filenum, BYTESTRING key,
? toku_fill_dbt(&data_dbt, data->data, data->len)
: toku_init_dbt(&data_dbt) } } };
r = toku_ft_root_put_cmd(h, &ftcmd);
if (r == 0 && reset_root_xid_that_created) {
toku_ft_root_put_cmd(h, &ftcmd);
if (reset_root_xid_that_created) {
TXNID new_root_xid_that_created = xids_get_outermost_xid(xids);
toku_reset_root_xid_that_created(h, new_root_xid_that_created);
}
......
......@@ -139,10 +139,9 @@ int toku_rollback_commit(TOKUTXN txn, LSN lsn) {
if (txn_has_current_rollback_log(txn)) {
num_nodes--; //Don't count the in-progress rollback log.
}
r = toku_logger_save_rollback_rollinclude(txn->parent, txn->txnid64, num_nodes,
toku_logger_save_rollback_rollinclude(txn->parent, txn->txnid64, num_nodes,
txn->roll_info.spilled_rollback_head, txn->roll_info.spilled_rollback_head_hash,
txn->roll_info.spilled_rollback_tail, txn->roll_info.spilled_rollback_tail_hash);
if (r!=0) return r;
//Remove ownership from child.
txn->roll_info.spilled_rollback_head = ROLLBACK_NONE;
txn->roll_info.spilled_rollback_head_hash = 0;
......
......@@ -27,7 +27,6 @@ rollback_log_destroy(ROLLBACK_LOG_NODE log) {
void toku_rollback_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM logname,
void *rollback_v, void** UU(disk_data), void *extraargs, PAIR_ATTR size, PAIR_ATTR* new_size,
bool write_me, bool keep_me, bool for_checkpoint, bool is_clone) {
int r;
ROLLBACK_LOG_NODE log = nullptr;
SERIALIZED_ROLLBACK_LOG_NODE serialized = nullptr;
if (is_clone) {
......@@ -40,20 +39,10 @@ void toku_rollback_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM logname
}
FT CAST_FROM_VOIDP(h, extraargs);
if (write_me && !h->panic) {
if (write_me) {
assert(h->cf == cachefile);
r = toku_serialize_rollback_log_to(fd, log, serialized, is_clone, h, for_checkpoint);
if (r) {
if (h->panic==0) {
char *e = strerror(r);
int l = 200 + strlen(e);
char s[l];
h->panic=r;
snprintf(s, l-1, "While writing data to disk, error %d (%s)", r, e);
h->panic_string = toku_strdup(s);
}
}
int r = toku_serialize_rollback_log_to(fd, log, serialized, is_clone, h, for_checkpoint);
assert(r == 0);
}
*new_size = size;
if (!keep_me) {
......
......@@ -74,7 +74,6 @@ static void rollback_log_create (TOKUTXN txn, BLOCKNUM previous, uint32_t previo
ROLLBACK_LOG_NODE MALLOC(log);
assert(log);
int r;
CACHEFILE cf = txn->logger->rollback_cachefile;
FT CAST_FROM_VOIDP(h, toku_cachefile_get_userdata(cf));
......@@ -94,11 +93,10 @@ static void rollback_log_create (TOKUTXN txn, BLOCKNUM previous, uint32_t previo
log->rollentry_resident_bytecount = 0;
*result = log;
r = toku_cachetable_put(cf, log->blocknum, log->hash,
log, rollback_memory_size(log),
get_write_callbacks_for_rollback_log(h),
toku_rollback_node_save_ct_pair);
assert(r == 0);
toku_cachetable_put(cf, log->blocknum, log->hash,
log, rollback_memory_size(log),
get_write_callbacks_for_rollback_log(h),
toku_rollback_node_save_ct_pair);
txn->roll_info.current_rollback = log->blocknum;
txn->roll_info.current_rollback_hash = log->hash;
}
......
......@@ -35,14 +35,14 @@ static FT_HANDLE t;
static void setup (void) {
int r;
unlink(fname);
r = toku_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
toku_cachetable_create(&ct, 0, ZERO_LSN, NULL_LOGGER);
r = toku_open_ft_handle(fname, 1, &t, nodesize, basementnodesize, compression_method, ct, NULL_TXN, toku_builtin_compare_fun); assert(r==0);
}
static void toku_shutdown (void) {
int r;
r = toku_close_ft_handle_nolsn(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
toku_cachetable_close(&ct);
}
static void long_long_to_array (unsigned char *a, unsigned long long l) {
int i;
......@@ -57,8 +57,7 @@ static void insert (long long v) {
long_long_to_array(kc, v);
memset(vc, 0, sizeof vc);
long_long_to_array(vc, v);
int r = toku_ft_insert(t, toku_fill_dbt(&kt, kc, keysize), toku_fill_dbt(&vt, vc, valsize), 0);
CKERR(r);
toku_ft_insert(t, toku_fill_dbt(&kt, kc, keysize), toku_fill_dbt(&vt, vc, valsize), 0);
if (do_verify) toku_cachetable_verify(ct);
}
......
......@@ -54,11 +54,11 @@ run_test(unsigned long eltsize, unsigned long nodesize, unsigned long repeat)
for (unsigned int i = 0; i < repeat; ++i) {
bnc = toku_create_empty_nl();
for (; toku_bnc_nbytesinbuf(bnc) <= nodesize; ++cur) {
r = toku_bnc_insert_msg(bnc,
&keys[cur % 1024], sizeof keys[cur % 1024],
vals[cur % 1024], eltsize - (sizeof keys[cur % 1024]),
FT_NONE, next_dummymsn(), xids_123, true,
NULL, long_key_cmp); assert_zero(r);
toku_bnc_insert_msg(bnc,
&keys[cur % 1024], sizeof keys[cur % 1024],
vals[cur % 1024], eltsize - (sizeof keys[cur % 1024]),
FT_NONE, next_dummymsn(), xids_123, true,
NULL, long_key_cmp); assert_zero(r);
}
nbytesinserted += toku_bnc_nbytesinbuf(bnc);
destroy_nonleaf_childinfo(bnc);
......
......@@ -23,7 +23,7 @@ run_test (void) {
const int test_limit = 20;
int r;
ct = NULL;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
f1 = NULL;
......@@ -53,7 +53,7 @@ run_test (void) {
// pin 1 and 2
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v2, &s2, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL);
toku_cachetable_begin_checkpoint(cp, NULL);
// mark nodes as pending a checkpoint, so that get_and_pin_nonblocking on block 1 will return TOKUDB_TRY_AGAIN
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8)); assert(r==0);
......@@ -80,19 +80,16 @@ run_test (void) {
);
assert(r==TOKUDB_TRY_AGAIN);
r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
NULL
);
assert(r==0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -31,7 +31,7 @@ cachetable_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
......@@ -61,10 +61,8 @@ cachetable_test (void) {
assert_zero(r);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -26,7 +26,7 @@ static void *pin_nonblocking(void *arg) {
}
static void *put_same_key(void *arg) {
int r = toku_cachetable_put(
toku_cachetable_put(
f1,
make_blocknum(1),
toku_cachetable_hash(f1,make_blocknum(1)),
......@@ -35,7 +35,6 @@ static void *put_same_key(void *arg) {
def_write_callback(NULL),
put_callback_nop
);
assert(r==0);
return arg;
}
......@@ -53,7 +52,7 @@ cachetable_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
......@@ -87,10 +86,8 @@ cachetable_test (void) {
r = toku_test_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);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -84,7 +84,7 @@ cachetable_test (void) {
check_flush = false;
dirty_flush_called = false;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
evictor_test_helpers::disable_ev_thread(&ct->ev); // disable eviction thread
char fname1[] = __SRCFILE__ "test1.dat";
......@@ -118,7 +118,7 @@ cachetable_test (void) {
usleep(2*1024*1024);
check_flush = true;
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN);
r = toku_cachefile_close(&f1, false, ZERO_LSN);
assert(r == 0);
assert(dirty_flush_called);
check_flush = false;
......@@ -129,8 +129,8 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f2, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f2, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -32,7 +32,7 @@ cachetable_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -52,8 +52,8 @@ cachetable_test (void) {
//r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -105,7 +105,7 @@ static void checkpoint_pending(void) {
if (verbose) { printf("%s:%d n=%d\n", __FUNCTION__, __LINE__, N); fflush(stdout); }
const int test_limit = N;
int r;
r = toku_create_cachetable(&ct, test_limit*sizeof(int), ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit*sizeof(int), ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
r = unlink(fname1); if (r!=0) CKERR2(get_error_errno(), ENOENT);
r = toku_cachetable_openf(&cf, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
......@@ -119,7 +119,7 @@ static void checkpoint_pending(void) {
values[i] = 42;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_put(cf, key, hi, &values[i], make_pair_attr(sizeof(int)), wc, put_callback_nop);
toku_cachetable_put(cf, key, hi, &values[i], make_pair_attr(sizeof(int)), wc, put_callback_nop);
assert(r == 0);
r = toku_test_cachetable_unpin(cf, key, hi, CACHETABLE_DIRTY, make_pair_attr(item_size));
......@@ -153,8 +153,8 @@ 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);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&cf, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -68,7 +68,7 @@ cachetable_test (void) {
const int test_limit = 20;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -91,7 +91,7 @@ cachetable_test (void) {
// flush will be called only for v1, because v1 is dirty
//
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL); assert(r == 0);
toku_cachetable_begin_checkpoint(cp, NULL);
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
......@@ -99,7 +99,7 @@ cachetable_test (void) {
check_me = true;
flush_called = false;
r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
......@@ -110,8 +110,8 @@ cachetable_test (void) {
check_me = false;
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
......
......@@ -70,7 +70,7 @@ cachetable_test (void) {
const int test_limit = 20;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -93,12 +93,12 @@ cachetable_test (void) {
// flush will be called only for v1, because v1 is dirty
//
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL); assert(r == 0);
toku_cachetable_begin_checkpoint(cp, NULL);
check_me = true;
flush_called = false;
r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
......@@ -111,8 +111,8 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
......
......@@ -60,7 +60,7 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
const int test_limit = n;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -74,8 +74,7 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
uint32_t hi = toku_cachetable_hash(f1, key);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_put(f1, key, hi, (void *)(long)i, make_pair_attr(1), wc, put_callback_nop);
assert(r == 0);
toku_cachetable_put(f1, key, hi, (void *)(long)i, make_pair_attr(1), wc, put_callback_nop);
r = toku_test_cachetable_unpin(f1, key, hi, dirty, make_pair_attr(item_size));
assert(r == 0);
......@@ -132,8 +131,8 @@ 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 );
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0 );
toku_cachetable_close(&ct);
}
int
......
......@@ -34,8 +34,6 @@ struct checkpointer_test {
// Description:
//
void checkpointer_test::test_begin_checkpoint() {
int r = 0;
cachefile_list cfl;
cfl.init();
......@@ -46,8 +44,7 @@ void checkpointer_test::test_begin_checkpoint() {
m_cp.init(&ctbl.list, NULL, &ctbl.ev, &cfl);
// 1. Call checkpoint with NO cachefiles.
r = m_cp.begin_checkpoint();
if (r) { assert(!"CHECKPOINTER: Checkpoint with no cachefiles failed!\n"); }
m_cp.begin_checkpoint();
// 2. Call checkpoint with ONE cachefile.
//cachefile cf;
......@@ -57,8 +54,7 @@ void checkpointer_test::test_begin_checkpoint() {
m_cp.m_cf_list->m_head = &cf;
create_dummy_functions(&cf);
r = m_cp.begin_checkpoint();
if (r) { assert(!"CHECKPOINTER: Checkpoint with one cachefile failed!\n"); }
m_cp.begin_checkpoint();
assert(m_cp.m_checkpoint_num_files == 1);
assert(cf.for_checkpoint == true);
......@@ -76,8 +72,7 @@ void checkpointer_test::test_begin_checkpoint() {
}
}
r = m_cp.begin_checkpoint();
if (r) { assert(!"CHECKPOINTER: Multiple checkpoint failed!\n"); }
m_cp.begin_checkpoint();
assert(m_cp.m_checkpoint_num_files == count);
for (uint32_t i = 0; i < count; ++i) {
assert(cfs[i].for_checkpoint == true);
......@@ -171,8 +166,7 @@ void checkpointer_test::test_pending_bits() {
m_cp.m_list->evict(pp);
}
int r = ctbl.list.destroy();
assert_zero(r);
ctbl.list.destroy();
m_cp.destroy();
}
......@@ -307,8 +301,7 @@ void checkpointer_test::test_end_checkpoint() {
m_cp.m_list->evict(pp);
}
m_cp.destroy();
int r = ctbl.list.destroy();
assert_zero(r);
ctbl.list.destroy();
}
......
......@@ -63,7 +63,7 @@ cachetable_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
......@@ -83,11 +83,11 @@ cachetable_test (void) {
cleaner_called = false;
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL);
toku_cachetable_begin_checkpoint(cp, NULL);
assert_zero(r);
toku_cleaner_thread_for_test(ct);
assert(cleaner_called);
r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
......@@ -96,8 +96,8 @@ cachetable_test (void) {
assert(r==0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
......
......@@ -63,7 +63,7 @@ cachetable_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
......@@ -83,11 +83,11 @@ cachetable_test (void) {
cleaner_called = false;
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL);
toku_cachetable_begin_checkpoint(cp, NULL);
assert_zero(r);
toku_cleaner_thread_for_test(ct);
assert(!cleaner_called);
r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
......@@ -96,8 +96,8 @@ cachetable_test (void) {
assert(r==0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
......
......@@ -59,7 +59,7 @@ run_test (void) {
int r;
CACHETABLE ct;
toku_mutex_init(&attr_mutex, NULL);
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
......@@ -126,8 +126,8 @@ 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);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -15,8 +15,8 @@ cachetable_test (void) {
const int test_limit = 1000;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
r = toku_set_cleaner_period(ct, 1); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
toku_set_cleaner_period(ct, 1);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
......@@ -26,8 +26,8 @@ cachetable_test (void) {
usleep(4000000);
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL); assert(r == 0);
r = toku_cachetable_end_checkpoint(
toku_cachetable_begin_checkpoint(cp, NULL);
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
......@@ -36,8 +36,8 @@ cachetable_test (void) {
assert(r==0);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -27,14 +27,14 @@ run_test (void) {
const int test_limit = 1000;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
r = toku_set_cleaner_period(ct, 1); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
toku_set_cleaner_period(ct, 1);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
r = toku_set_cleaner_period(ct, 1);
toku_set_cleaner_period(ct, 1);
assert(r==0);
void* vs[8];
......@@ -62,8 +62,8 @@ run_test (void) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -27,8 +27,8 @@ run_test (void) {
const int test_limit = 1000;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
r = toku_set_cleaner_period(ct, 1); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
toku_set_cleaner_period(ct, 1);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
......@@ -60,8 +60,8 @@ run_test (void) {
usleep(4000000);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -35,8 +35,8 @@ run_test (void) {
const int test_limit = 1000;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
r = toku_set_cleaner_period(ct, 1); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
toku_set_cleaner_period(ct, 1);
my_cleaner_callback_called = false;
char fname1[] = __SRCFILE__ "test1.dat";
......@@ -80,8 +80,8 @@ run_test (void) {
assert(my_cleaner_callback_called);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0 );
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0 );
toku_cachetable_close(&ct);
}
int
......
......@@ -12,7 +12,7 @@ cachetable_test (void) {
int test_limit = 6;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -20,14 +20,13 @@ cachetable_test (void) {
// test that putting something too big in the cachetable works fine
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_put(f1, make_blocknum(num_entries+1), num_entries+1, NULL, make_pair_attr(test_limit*2), wc, put_callback_nop);
assert(r==0);
toku_cachetable_put(f1, make_blocknum(num_entries+1), num_entries+1, NULL, make_pair_attr(test_limit*2), wc, put_callback_nop);
r = toku_test_cachetable_unpin(f1, make_blocknum(num_entries+1), num_entries+1, CACHETABLE_DIRTY, make_pair_attr(test_limit*2));
assert(r==0);
for (int64_t i = 0; i < num_entries; i++) {
r = toku_cachetable_put(f1, make_blocknum(i), i, NULL, make_pair_attr(1), wc, put_callback_nop);
toku_cachetable_put(f1, make_blocknum(i), i, NULL, make_pair_attr(1), wc, put_callback_nop);
assert(toku_cachefile_count_pinned(f1, 0) == (i+1));
}
for (int64_t i = 0; i < num_entries; i++) {
......@@ -35,8 +34,8 @@ cachetable_test (void) {
}
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0 );
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0 );
toku_cachetable_close(&ct);
}
int
......
......@@ -58,7 +58,7 @@ cachetable_test (void) {
num_entries = 0;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -89,7 +89,7 @@ cachetable_test (void) {
}
flush_may_occur = true;
expected_flushed_key = 4;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc, put_callback_nop);
toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc, put_callback_nop);
ct->ev.signal_eviction_thread();
usleep(1*1024*1024);
......@@ -100,8 +100,8 @@ cachetable_test (void) {
usleep(1*1024*1024);
check_flush = false;
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0 );
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0 );
toku_cachetable_close(&ct);
}
int
......
......@@ -99,7 +99,7 @@ cachetable_test (void) {
const int test_limit = 16;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -142,7 +142,7 @@ cachetable_test (void) {
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = other_flush;
wc.pe_callback = other_pe_callback;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc, put_callback_nop);
toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc, put_callback_nop);
ct->ev.signal_eviction_thread();
usleep(1*1024*1024);
flush_may_occur = true;
......@@ -152,8 +152,8 @@ cachetable_test (void) {
assert(expected_bytes_to_free == 0);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -115,7 +115,7 @@ cachetable_test (void) {
const int test_limit = 20;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
evictor_test_helpers::set_hysteresis_limits(&ct->ev, test_limit, 100*test_limit);
evictor_test_helpers::disable_ev_thread(&ct->ev);
char fname1[] = __SRCFILE__ "test1.dat";
......@@ -165,7 +165,7 @@ cachetable_test (void) {
wc.flush_callback = other_flush;
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = other_pe_callback;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc, put_callback_nop);
toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc, put_callback_nop);
flush_may_occur = true;
r = toku_test_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(8));
ct->ev.signal_eviction_thread();
......@@ -180,8 +180,8 @@ cachetable_test (void) {
assert(expected_bytes_to_free == 3);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -95,7 +95,7 @@ cachetable_test (void) {
num_entries = 0;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -128,14 +128,14 @@ cachetable_test (void) {
}
flush_may_occur = true;
expected_flushed_key = 4;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc, put_callback_nop);
toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc, put_callback_nop);
flush_may_occur = true;
expected_flushed_key = 5;
r = toku_test_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 );
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0 );
toku_cachetable_close(&ct);
}
int
......
......@@ -42,13 +42,12 @@ flush (
static void *run_end_checkpoint(void *arg) {
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
int r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
NULL
);
assert_zero(r);
return arg;
}
......@@ -60,7 +59,7 @@ cachetable_test (void) {
const int test_limit = 200;
int r;
ct = NULL;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -77,7 +76,7 @@ cachetable_test (void) {
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
assert_zero(r);
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL);
toku_cachetable_begin_checkpoint(cp, NULL);
clone_flush_started = false;
......@@ -100,8 +99,8 @@ 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);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -53,7 +53,7 @@ cachetable_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -73,7 +73,7 @@ cachetable_test (void) {
flush_completed = false;
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL); assert_zero(r);
toku_cachetable_begin_checkpoint(cp, NULL);
assert_zero(r);
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);
assert_zero(r);
......@@ -91,7 +91,7 @@ cachetable_test (void) {
assert_zero(r);
assert(pf_called);
r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
......@@ -101,8 +101,8 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
......
......@@ -58,7 +58,7 @@ cachetable_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -78,7 +78,7 @@ cachetable_test (void) {
flush_completed = false;
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL); assert_zero(r);
toku_cachetable_begin_checkpoint(cp, NULL);
assert_zero(r);
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);
assert_zero(r);
......@@ -92,7 +92,7 @@ cachetable_test (void) {
assert_zero(r);
assert(pf_called);
r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
......@@ -102,8 +102,8 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
......
......@@ -40,7 +40,7 @@ cachetable_test (enum cachetable_dirty dirty, bool cloneable) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -58,7 +58,7 @@ cachetable_test (enum cachetable_dirty dirty, bool cloneable) {
// test that having a pin that passes false for may_modify_value does not stall behind checkpoint
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL); assert_zero(r);
toku_cachetable_begin_checkpoint(cp, NULL);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_READ, NULL, NULL);
assert(r == 0);
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
......@@ -73,20 +73,16 @@ cachetable_test (enum cachetable_dirty dirty, bool cloneable) {
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
}
r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
NULL
);
assert_zero(r);
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -51,7 +51,7 @@ cachetable_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -72,7 +72,7 @@ cachetable_test (void) {
flush_completed = false;
evict_called = false;
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL); assert_zero(r);
toku_cachetable_begin_checkpoint(cp, NULL);
assert_zero(r);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
assert_zero(r);
......@@ -80,7 +80,7 @@ cachetable_test (void) {
assert_zero(r);
r = toku_cachetable_end_checkpoint(
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
......@@ -90,8 +90,8 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
......
......@@ -12,7 +12,7 @@ cachetable_count_pinned_test (int n) {
const int test_limit = 2*n;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -23,8 +23,7 @@ cachetable_count_pinned_test (int n) {
uint32_t hi;
hi = toku_cachetable_hash(f1, make_blocknum(i));
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc, put_callback_nop);
assert(r == 0);
toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc, put_callback_nop);
assert(toku_cachefile_count_pinned(f1, 0) == i);
void *v;
......@@ -48,8 +47,8 @@ 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);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -11,7 +11,7 @@ cachetable_debug_test (int n) {
const int test_limit = n;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -30,8 +30,7 @@ cachetable_debug_test (int n) {
uint32_t hi;
hi = toku_cachetable_hash(f1, make_blocknum(i));
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(item_size), wc, put_callback_nop);
assert(r == 0);
toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(item_size), wc, put_callback_nop);
void *v; int dirty; long long pinned; long pair_size;
r = toku_cachetable_get_key_state(ct, make_blocknum(i), f1, &v, &dirty, &pinned, &pair_size);
......@@ -53,8 +52,8 @@ cachetable_debug_test (int n) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -70,7 +70,7 @@ static void cachetable_eviction_full_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -132,8 +132,8 @@ 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);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -82,7 +82,7 @@ static void cachetable_eviction_full_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -146,8 +146,8 @@ 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);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -38,7 +38,7 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
evictor_test_helpers::disable_ev_thread(&ct->ev);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
......@@ -119,8 +119,8 @@ 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);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -44,7 +44,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
evictor_test_helpers::disable_ev_thread(&ct->ev);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
......@@ -148,8 +148,8 @@ 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);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -12,7 +12,7 @@ cachetable_fd_test (void) {
const int test_limit = 1;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE cf;
......@@ -44,8 +44,8 @@ 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);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&cf, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -28,7 +28,7 @@ cachetable_test (enum pin_evictor_test_type test_type, bool nonblocking) {
const int test_limit = 7;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
evictor_test_helpers::set_hysteresis_limits(&ct->ev, test_limit, test_limit);
evictor_test_helpers::disable_ev_thread(&ct->ev);
char fname1[] = __SRCFILE__ "test1.dat";
......@@ -100,8 +100,8 @@ cachetable_test (enum pin_evictor_test_type test_type, bool nonblocking) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -25,8 +25,8 @@ cachetable_test (void) {
const int test_limit = 400;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
r = toku_set_cleaner_period(ct, 1); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
toku_set_cleaner_period(ct, 1);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
......@@ -43,12 +43,11 @@ cachetable_test (void) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), i, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
r = toku_test_cachetable_unpin(f1, make_blocknum(i), i, CACHETABLE_DIRTY, make_pair_attr(8));
}
r = toku_cachefile_flush(f1);
assert(r == 0);
toku_cachefile_flush(f1);
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
......
......@@ -12,7 +12,7 @@ test_cachetable_def_flush (int n) {
const int test_limit = 2*n;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -28,13 +28,11 @@ test_cachetable_def_flush (int n) {
for (i=0; i<n; i++) {
uint32_t hi;
hi = toku_cachetable_hash(f1, make_blocknum(i));
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc, put_callback_nop);
assert(r == 0);
toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc, put_callback_nop);
r = toku_test_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
assert(r == 0);
hi = toku_cachetable_hash(f2, make_blocknum(i));
r = toku_cachetable_put(f2, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc, put_callback_nop);
assert(r == 0);
toku_cachetable_put(f2, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc, put_callback_nop);
r = toku_test_cachetable_unpin(f2, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
assert(r == 0);
}
......@@ -57,7 +55,7 @@ test_cachetable_def_flush (int n) {
}
// def_flush
r = toku_cachefile_flush(f1); assert(r == 0);
toku_cachefile_flush(f1);
toku_cachefile_verify(f1);
// verify keys do not exist in f1 but do exist in f2
......@@ -74,9 +72,9 @@ test_cachetable_def_flush (int n) {
assert(r == 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);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
r = toku_cachefile_close(&f2, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -49,7 +49,7 @@ cachetable_getandpin_test (int n) {
const int test_limit = 1024*1024;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test_getandpin.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -73,8 +73,8 @@ cachetable_getandpin_test (int n) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
int
......
......@@ -29,7 +29,7 @@ run_test (void) {
const int test_limit = 12;
int r;
CACHETABLE ct;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -43,16 +43,16 @@ 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_flush(f1); assert(r == 0);
toku_cachefile_flush(f1);
assert(foo);
assert(f1);
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);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
assert(foo);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
toku_cachetable_close(&ct);
}
......
......@@ -81,7 +81,7 @@ cachetable_test (void) {
int r;
CACHETABLE ct;
bool doing_prefetch = false;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
......@@ -128,7 +128,7 @@ cachetable_test (void) {
r = toku_test_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);
r = toku_cachefile_close(&f1, 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
......@@ -176,8 +176,8 @@ cachetable_test (void) {
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
}
......
......@@ -269,16 +269,14 @@ static void *checkpoints(void *arg) {
//
// now run a checkpoint
//
int r;
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL); assert(r == 0);
r = toku_cachetable_end_checkpoint(
toku_cachetable_begin_checkpoint(cp, NULL);
toku_cachetable_end_checkpoint(
cp,
NULL,
NULL,
NULL
);
assert(r==0);
assert (sum==0);
for (int i = 0; i < NUM_ELEMENTS; i++) {
sum += checkpointed_data[i];
......@@ -290,18 +288,12 @@ static void *checkpoints(void *arg) {
return arg;
}
static int
static void
test_begin_checkpoint (
LSN UU(checkpoint_lsn),
void* UU(header_v))
{
memcpy(checkpointed_data, data, sizeof(int64_t)*NUM_ELEMENTS);
return 0;
}
static int
dummy_int_checkpoint_userdata(CACHEFILE UU(cf), int UU(n), void* UU(extra)) {
return 0;
}
static void sum_vals(void) {
......@@ -336,7 +328,7 @@ cachetable_test (void) {
int r;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, NULL_LOGGER);
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
......@@ -344,13 +336,13 @@ cachetable_test (void) {
toku_cachefile_set_userdata(
f1,
NULL,
&dummy_log_fassociate,
&dummy_log_rollback,
&dummy_close_usr,
dummy_int_checkpoint_userdata,
test_begin_checkpoint, // called in begin_checkpoint
dummy_int_checkpoint_userdata,
&dummy_note_pin,
&dummy_log_fassociate,
&dummy_log_rollback,
&dummy_close_usr,
&dummy_chckpnt_usr,
&test_begin_checkpoint,
&dummy_end,
&dummy_note_pin,
&dummy_note_unpin
);
......@@ -389,8 +381,8 @@ cachetable_test (void) {
}
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, false, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
r = toku_cachefile_close(&f1, false, ZERO_LSN); assert(r == 0);
toku_cachetable_close(&ct);
sum_vals();
if (verbose) printf("num_checkpoints %d\n", num_checkpoints);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment