mirror of
https://github.com/MariaDB/server.git
synced 2025-02-01 19:41:47 +01:00
[t:3997], merge to main
git-svn-id: file:///svn/toku/tokudb@36689 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
7295d90993
commit
00e8c8c224
104 changed files with 2742 additions and 2912 deletions
|
@ -84,8 +84,10 @@ typedef struct __toku_engine_status {
|
|||
char checkpoint_time_begin_complete[26]; /* time of last complete checkpoint begin */
|
||||
char checkpoint_time_end[26]; /* time of last checkpoint end */
|
||||
u_int64_t checkpoint_last_lsn; /* LSN of last complete checkpoint */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t cleaner_period; /* delay between automatic checkpoints */
|
||||
u_int32_t cleaner_iterations; /* delay between automatic checkpoints */
|
||||
u_int64_t txn_begin; /* number of transactions ever begun */
|
||||
u_int64_t txn_commit; /* txn commit operations */
|
||||
u_int64_t txn_abort; /* txn abort operations */
|
||||
|
@ -113,6 +115,8 @@ typedef struct __toku_engine_status {
|
|||
int64_t cachetable_size_max; /* the max value (high water mark) of cachetable_size_current */
|
||||
uint64_t cachetable_size_leaf; /* the number of bytes of leaf nodes */
|
||||
uint64_t cachetable_size_nonleaf; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_rollback; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_cachepressure; /* the number of bytes of nonleaf nodes */
|
||||
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
|
||||
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
|
||||
int64_t local_checkpoint; /* number of times a local checkpoint is taken for commit */
|
||||
|
@ -325,13 +329,17 @@ struct __toku_db_env {
|
|||
#define db_env_struct_i(x) ((x)->i)
|
||||
int (*checkpointing_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*checkpointing_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*cleaner_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_set_iterations) (DB_ENV*, u_int32_t) /* Change the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*cleaner_get_iterations) (DB_ENV*, u_int32_t*) /* Retrieve the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
|
||||
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
|
||||
void *app_private; /* 32-bit offset=36 size=4, 64=bit offset=72 size=8 */
|
||||
int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */;
|
||||
int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
|
||||
int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
|
||||
int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*, char*, int) /* Fill in status struct, possibly env panic string */;
|
||||
void *app_private; /* 32-bit offset=36 size=4, 64=bit offset=72 size=8 */
|
||||
int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */;
|
||||
int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */;
|
||||
int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags);
|
||||
|
@ -357,7 +365,7 @@ struct __toku_db_env {
|
|||
void (*set_update) (DB_ENV *env, int (*update_function)(DB *, const DBT *key, const DBT *old_val, const DBT *extra, void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra));
|
||||
int (*set_lock_timeout) (DB_ENV *env, uint64_t lock_wait_time_msec);
|
||||
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_msec);
|
||||
void* __toku_dummy0[11];
|
||||
void* __toku_dummy0[7];
|
||||
char __toku_dummy1[64];
|
||||
void *api1_internal; /* 32-bit offset=212 size=4, 64=bit offset=360 size=8 */
|
||||
void* __toku_dummy2[7];
|
||||
|
|
|
@ -84,8 +84,10 @@ typedef struct __toku_engine_status {
|
|||
char checkpoint_time_begin_complete[26]; /* time of last complete checkpoint begin */
|
||||
char checkpoint_time_end[26]; /* time of last checkpoint end */
|
||||
u_int64_t checkpoint_last_lsn; /* LSN of last complete checkpoint */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t cleaner_period; /* delay between automatic checkpoints */
|
||||
u_int32_t cleaner_iterations; /* delay between automatic checkpoints */
|
||||
u_int64_t txn_begin; /* number of transactions ever begun */
|
||||
u_int64_t txn_commit; /* txn commit operations */
|
||||
u_int64_t txn_abort; /* txn abort operations */
|
||||
|
@ -113,6 +115,8 @@ typedef struct __toku_engine_status {
|
|||
int64_t cachetable_size_max; /* the max value (high water mark) of cachetable_size_current */
|
||||
uint64_t cachetable_size_leaf; /* the number of bytes of leaf nodes */
|
||||
uint64_t cachetable_size_nonleaf; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_rollback; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_cachepressure; /* the number of bytes of nonleaf nodes */
|
||||
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
|
||||
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
|
||||
int64_t local_checkpoint; /* number of times a local checkpoint is taken for commit */
|
||||
|
@ -327,15 +331,19 @@ struct __toku_db_env {
|
|||
#define db_env_struct_i(x) ((x)->i)
|
||||
int (*checkpointing_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*checkpointing_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*cleaner_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_set_iterations) (DB_ENV*, u_int32_t) /* Change the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*cleaner_get_iterations) (DB_ENV*, u_int32_t*) /* Retrieve the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
|
||||
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
|
||||
int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */;
|
||||
int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
|
||||
void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */
|
||||
int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
|
||||
int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*, char*, int) /* Fill in status struct, possibly env panic string */;
|
||||
int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */;
|
||||
int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */;
|
||||
void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */
|
||||
int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags);
|
||||
int (*create_indexer) (DB_ENV *env, DB_TXN *txn, DB_INDEXER **idxrp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t indexer_flags);
|
||||
int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,
|
||||
|
@ -359,7 +367,7 @@ struct __toku_db_env {
|
|||
void (*set_update) (DB_ENV *env, int (*update_function)(DB *, const DBT *key, const DBT *old_val, const DBT *extra, void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra));
|
||||
int (*set_lock_timeout) (DB_ENV *env, uint64_t lock_wait_time_msec);
|
||||
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_msec);
|
||||
void* __toku_dummy0[11];
|
||||
void* __toku_dummy0[7];
|
||||
char __toku_dummy1[96];
|
||||
void *api1_internal; /* 32-bit offset=244 size=4, 64=bit offset=392 size=8 */
|
||||
void* __toku_dummy2[7];
|
||||
|
|
|
@ -84,8 +84,10 @@ typedef struct __toku_engine_status {
|
|||
char checkpoint_time_begin_complete[26]; /* time of last complete checkpoint begin */
|
||||
char checkpoint_time_end[26]; /* time of last checkpoint end */
|
||||
u_int64_t checkpoint_last_lsn; /* LSN of last complete checkpoint */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t cleaner_period; /* delay between automatic checkpoints */
|
||||
u_int32_t cleaner_iterations; /* delay between automatic checkpoints */
|
||||
u_int64_t txn_begin; /* number of transactions ever begun */
|
||||
u_int64_t txn_commit; /* txn commit operations */
|
||||
u_int64_t txn_abort; /* txn abort operations */
|
||||
|
@ -113,6 +115,8 @@ typedef struct __toku_engine_status {
|
|||
int64_t cachetable_size_max; /* the max value (high water mark) of cachetable_size_current */
|
||||
uint64_t cachetable_size_leaf; /* the number of bytes of leaf nodes */
|
||||
uint64_t cachetable_size_nonleaf; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_rollback; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_cachepressure; /* the number of bytes of nonleaf nodes */
|
||||
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
|
||||
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
|
||||
int64_t local_checkpoint; /* number of times a local checkpoint is taken for commit */
|
||||
|
@ -327,15 +331,19 @@ struct __toku_db_env {
|
|||
#define db_env_struct_i(x) ((x)->i)
|
||||
int (*checkpointing_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*checkpointing_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*cleaner_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_set_iterations) (DB_ENV*, u_int32_t) /* Change the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*cleaner_get_iterations) (DB_ENV*, u_int32_t*) /* Retrieve the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
|
||||
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
|
||||
int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */;
|
||||
int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
|
||||
void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */
|
||||
int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
|
||||
int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*, char*, int) /* Fill in status struct, possibly env panic string */;
|
||||
int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */;
|
||||
int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */;
|
||||
void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */
|
||||
int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags);
|
||||
int (*create_indexer) (DB_ENV *env, DB_TXN *txn, DB_INDEXER **idxrp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t indexer_flags);
|
||||
int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,
|
||||
|
@ -359,7 +367,7 @@ struct __toku_db_env {
|
|||
void (*set_update) (DB_ENV *env, int (*update_function)(DB *, const DBT *key, const DBT *old_val, const DBT *extra, void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra));
|
||||
int (*set_lock_timeout) (DB_ENV *env, uint64_t lock_wait_time_msec);
|
||||
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_msec);
|
||||
void* __toku_dummy0[26];
|
||||
void* __toku_dummy0[22];
|
||||
char __toku_dummy1[128];
|
||||
void *api1_internal; /* 32-bit offset=336 size=4, 64=bit offset=544 size=8 */
|
||||
void* __toku_dummy2[7];
|
||||
|
|
|
@ -84,8 +84,10 @@ typedef struct __toku_engine_status {
|
|||
char checkpoint_time_begin_complete[26]; /* time of last complete checkpoint begin */
|
||||
char checkpoint_time_end[26]; /* time of last checkpoint end */
|
||||
u_int64_t checkpoint_last_lsn; /* LSN of last complete checkpoint */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t cleaner_period; /* delay between automatic checkpoints */
|
||||
u_int32_t cleaner_iterations; /* delay between automatic checkpoints */
|
||||
u_int64_t txn_begin; /* number of transactions ever begun */
|
||||
u_int64_t txn_commit; /* txn commit operations */
|
||||
u_int64_t txn_abort; /* txn abort operations */
|
||||
|
@ -113,6 +115,8 @@ typedef struct __toku_engine_status {
|
|||
int64_t cachetable_size_max; /* the max value (high water mark) of cachetable_size_current */
|
||||
uint64_t cachetable_size_leaf; /* the number of bytes of leaf nodes */
|
||||
uint64_t cachetable_size_nonleaf; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_rollback; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_cachepressure; /* the number of bytes of nonleaf nodes */
|
||||
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
|
||||
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
|
||||
int64_t local_checkpoint; /* number of times a local checkpoint is taken for commit */
|
||||
|
@ -327,17 +331,21 @@ struct __toku_db_env {
|
|||
#define db_env_struct_i(x) ((x)->i)
|
||||
int (*checkpointing_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*checkpointing_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*cleaner_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_set_iterations) (DB_ENV*, u_int32_t) /* Change the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*cleaner_get_iterations) (DB_ENV*, u_int32_t*) /* Retrieve the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
|
||||
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
|
||||
int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */;
|
||||
int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
|
||||
int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
|
||||
int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*, char*, int) /* Fill in status struct, possibly env panic string */;
|
||||
void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */
|
||||
int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */;
|
||||
int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */;
|
||||
int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags);
|
||||
int (*create_indexer) (DB_ENV *env, DB_TXN *txn, DB_INDEXER **idxrp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t indexer_flags);
|
||||
void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */
|
||||
int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,
|
||||
const DBT *src_key, const DBT *src_val,
|
||||
uint32_t num_dbs, DB **db_array, DBT *keys, DBT *vals, uint32_t *flags_array) /* insert into multiple DBs */;
|
||||
|
@ -359,7 +367,7 @@ struct __toku_db_env {
|
|||
void (*set_update) (DB_ENV *env, int (*update_function)(DB *, const DBT *key, const DBT *old_val, const DBT *extra, void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra));
|
||||
int (*set_lock_timeout) (DB_ENV *env, uint64_t lock_wait_time_msec);
|
||||
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_msec);
|
||||
void* __toku_dummy0[26];
|
||||
void* __toku_dummy0[22];
|
||||
char __toku_dummy1[128];
|
||||
void *api1_internal; /* 32-bit offset=336 size=4, 64=bit offset=544 size=8 */
|
||||
void* __toku_dummy2[8];
|
||||
|
|
|
@ -84,8 +84,10 @@ typedef struct __toku_engine_status {
|
|||
char checkpoint_time_begin_complete[26]; /* time of last complete checkpoint begin */
|
||||
char checkpoint_time_end[26]; /* time of last checkpoint end */
|
||||
u_int64_t checkpoint_last_lsn; /* LSN of last complete checkpoint */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t cleaner_period; /* delay between automatic checkpoints */
|
||||
u_int32_t cleaner_iterations; /* delay between automatic checkpoints */
|
||||
u_int64_t txn_begin; /* number of transactions ever begun */
|
||||
u_int64_t txn_commit; /* txn commit operations */
|
||||
u_int64_t txn_abort; /* txn abort operations */
|
||||
|
@ -113,6 +115,8 @@ typedef struct __toku_engine_status {
|
|||
int64_t cachetable_size_max; /* the max value (high water mark) of cachetable_size_current */
|
||||
uint64_t cachetable_size_leaf; /* the number of bytes of leaf nodes */
|
||||
uint64_t cachetable_size_nonleaf; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_rollback; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_cachepressure; /* the number of bytes of nonleaf nodes */
|
||||
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
|
||||
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
|
||||
int64_t local_checkpoint; /* number of times a local checkpoint is taken for commit */
|
||||
|
@ -328,17 +332,21 @@ struct __toku_db_env {
|
|||
#define db_env_struct_i(x) ((x)->i)
|
||||
int (*checkpointing_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*checkpointing_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*cleaner_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_set_iterations) (DB_ENV*, u_int32_t) /* Change the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*cleaner_get_iterations) (DB_ENV*, u_int32_t*) /* Retrieve the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
|
||||
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
|
||||
int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */;
|
||||
int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
|
||||
int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
|
||||
int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*, char*, int) /* Fill in status struct, possibly env panic string */;
|
||||
void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */
|
||||
int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */;
|
||||
int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */;
|
||||
int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags);
|
||||
int (*create_indexer) (DB_ENV *env, DB_TXN *txn, DB_INDEXER **idxrp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t indexer_flags);
|
||||
void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */
|
||||
int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,
|
||||
const DBT *src_key, const DBT *src_val,
|
||||
uint32_t num_dbs, DB **db_array, DBT *keys, DBT *vals, uint32_t *flags_array) /* insert into multiple DBs */;
|
||||
|
@ -360,7 +368,7 @@ struct __toku_db_env {
|
|||
void (*set_update) (DB_ENV *env, int (*update_function)(DB *, const DBT *key, const DBT *old_val, const DBT *extra, void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra));
|
||||
int (*set_lock_timeout) (DB_ENV *env, uint64_t lock_wait_time_msec);
|
||||
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_msec);
|
||||
void* __toku_dummy0[27];
|
||||
void* __toku_dummy0[23];
|
||||
char __toku_dummy1[144];
|
||||
void *api1_internal; /* 32-bit offset=356 size=4, 64=bit offset=568 size=8 */
|
||||
void* __toku_dummy2[8];
|
||||
|
|
|
@ -478,8 +478,10 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
|
|||
printf(" char checkpoint_time_begin_complete[26]; /* time of last complete checkpoint begin */ \n");
|
||||
printf(" char checkpoint_time_end[26]; /* time of last checkpoint end */ \n");
|
||||
printf(" u_int64_t checkpoint_last_lsn; /* LSN of last complete checkpoint */ \n");
|
||||
printf(" u_int32_t checkpoint_count; /* number of checkpoints taken */ \n");
|
||||
printf(" u_int32_t checkpoint_count_fail; /* number of checkpoints failed */ \n");
|
||||
printf(" u_int32_t checkpoint_count; /* number of checkpoints taken */ \n");
|
||||
printf(" u_int32_t checkpoint_count_fail; /* number of checkpoints failed */ \n");
|
||||
printf(" u_int32_t cleaner_period; /* delay between automatic checkpoints */ \n");
|
||||
printf(" u_int32_t cleaner_iterations; /* delay between automatic checkpoints */ \n");
|
||||
printf(" u_int64_t txn_begin; /* number of transactions ever begun */ \n");
|
||||
printf(" u_int64_t txn_commit; /* txn commit operations */ \n");
|
||||
printf(" u_int64_t txn_abort; /* txn abort operations */ \n");
|
||||
|
@ -507,6 +509,8 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
|
|||
printf(" int64_t cachetable_size_max; /* the max value (high water mark) of cachetable_size_current */ \n");
|
||||
printf(" uint64_t cachetable_size_leaf; /* the number of bytes of leaf nodes */ \n");
|
||||
printf(" uint64_t cachetable_size_nonleaf; /* the number of bytes of nonleaf nodes */ \n");
|
||||
printf(" uint64_t cachetable_size_rollback; /* the number of bytes of nonleaf nodes */ \n");
|
||||
printf(" uint64_t cachetable_size_cachepressure; /* the number of bytes of nonleaf nodes */ \n");
|
||||
printf(" int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ \n");
|
||||
printf(" int64_t get_and_pin_footprint; /* state of get_and_pin procedure */ \n");
|
||||
printf(" int64_t local_checkpoint; /* number of times a local checkpoint is taken for commit */ \n");
|
||||
|
@ -634,6 +638,10 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
|
|||
const char *extra[]={
|
||||
"int (*checkpointing_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */",
|
||||
"int (*checkpointing_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */",
|
||||
"int (*cleaner_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */",
|
||||
"int (*cleaner_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */",
|
||||
"int (*cleaner_set_iterations) (DB_ENV*, u_int32_t) /* Change the number of attempts on each cleaner invokation. 0 means disabled. */",
|
||||
"int (*cleaner_get_iterations) (DB_ENV*, u_int32_t*) /* Retrieve the number of attempts on each cleaner invokation. 0 means disabled. */",
|
||||
"int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */",
|
||||
"int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */",
|
||||
"int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */",
|
||||
|
|
|
@ -84,8 +84,10 @@ typedef struct __toku_engine_status {
|
|||
char checkpoint_time_begin_complete[26]; /* time of last complete checkpoint begin */
|
||||
char checkpoint_time_end[26]; /* time of last checkpoint end */
|
||||
u_int64_t checkpoint_last_lsn; /* LSN of last complete checkpoint */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t cleaner_period; /* delay between automatic checkpoints */
|
||||
u_int32_t cleaner_iterations; /* delay between automatic checkpoints */
|
||||
u_int64_t txn_begin; /* number of transactions ever begun */
|
||||
u_int64_t txn_commit; /* txn commit operations */
|
||||
u_int64_t txn_abort; /* txn abort operations */
|
||||
|
@ -113,6 +115,8 @@ typedef struct __toku_engine_status {
|
|||
int64_t cachetable_size_max; /* the max value (high water mark) of cachetable_size_current */
|
||||
uint64_t cachetable_size_leaf; /* the number of bytes of leaf nodes */
|
||||
uint64_t cachetable_size_nonleaf; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_rollback; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_cachepressure; /* the number of bytes of nonleaf nodes */
|
||||
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
|
||||
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
|
||||
int64_t local_checkpoint; /* number of times a local checkpoint is taken for commit */
|
||||
|
@ -328,17 +332,21 @@ struct __toku_db_env {
|
|||
#define db_env_struct_i(x) ((x)->i)
|
||||
int (*checkpointing_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*checkpointing_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*cleaner_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_set_iterations) (DB_ENV*, u_int32_t) /* Change the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*cleaner_get_iterations) (DB_ENV*, u_int32_t*) /* Retrieve the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
|
||||
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
|
||||
int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */;
|
||||
int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
|
||||
int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
|
||||
int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*, char*, int) /* Fill in status struct, possibly env panic string */;
|
||||
void *app_private;
|
||||
int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */;
|
||||
int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */;
|
||||
int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags);
|
||||
int (*create_indexer) (DB_ENV *env, DB_TXN *txn, DB_INDEXER **idxrp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t indexer_flags);
|
||||
void *app_private;
|
||||
int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,
|
||||
const DBT *src_key, const DBT *src_val,
|
||||
uint32_t num_dbs, DB **db_array, DBT *keys, DBT *vals, uint32_t *flags_array) /* insert into multiple DBs */;
|
||||
|
|
|
@ -156,7 +156,7 @@ static inline uint64_t mysql_get_bigint(unsigned char *d) {
|
|||
return r;
|
||||
}
|
||||
|
||||
static int mysql_key_compare(DB *mydb __attribute__((unused)),
|
||||
static int mysql_key_compare(DESCRIPTOR desc __attribute__((unused)),
|
||||
const DBT *adbt, const DBT *bdbt) {
|
||||
unsigned char *adata = adbt->data;
|
||||
unsigned char *bdata = bdbt->data;
|
||||
|
|
14
include/db.h
14
include/db.h
|
@ -84,8 +84,10 @@ typedef struct __toku_engine_status {
|
|||
char checkpoint_time_begin_complete[26]; /* time of last complete checkpoint begin */
|
||||
char checkpoint_time_end[26]; /* time of last checkpoint end */
|
||||
u_int64_t checkpoint_last_lsn; /* LSN of last complete checkpoint */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t checkpoint_count; /* number of checkpoints taken */
|
||||
u_int32_t checkpoint_count_fail; /* number of checkpoints failed */
|
||||
u_int32_t cleaner_period; /* delay between automatic checkpoints */
|
||||
u_int32_t cleaner_iterations; /* delay between automatic checkpoints */
|
||||
u_int64_t txn_begin; /* number of transactions ever begun */
|
||||
u_int64_t txn_commit; /* txn commit operations */
|
||||
u_int64_t txn_abort; /* txn abort operations */
|
||||
|
@ -113,6 +115,8 @@ typedef struct __toku_engine_status {
|
|||
int64_t cachetable_size_max; /* the max value (high water mark) of cachetable_size_current */
|
||||
uint64_t cachetable_size_leaf; /* the number of bytes of leaf nodes */
|
||||
uint64_t cachetable_size_nonleaf; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_rollback; /* the number of bytes of nonleaf nodes */
|
||||
uint64_t cachetable_size_cachepressure; /* the number of bytes of nonleaf nodes */
|
||||
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
|
||||
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
|
||||
int64_t local_checkpoint; /* number of times a local checkpoint is taken for commit */
|
||||
|
@ -328,17 +332,21 @@ struct __toku_db_env {
|
|||
#define db_env_struct_i(x) ((x)->i)
|
||||
int (*checkpointing_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*checkpointing_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */;
|
||||
int (*cleaner_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic cleaner attempts. 0 means disabled. */;
|
||||
int (*cleaner_set_iterations) (DB_ENV*, u_int32_t) /* Change the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*cleaner_get_iterations) (DB_ENV*, u_int32_t*) /* Retrieve the number of attempts on each cleaner invokation. 0 means disabled. */;
|
||||
int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */;
|
||||
int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */;
|
||||
int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */;
|
||||
int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */;
|
||||
int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
|
||||
int (*get_engine_status) (DB_ENV*, ENGINE_STATUS*, char*, int) /* Fill in status struct, possibly env panic string */;
|
||||
void *app_private;
|
||||
int (*get_engine_status_text) (DB_ENV*, char*, int) /* Fill in status text */;
|
||||
int (*get_iname) (DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt) /* FOR TEST ONLY: lookup existing iname */;
|
||||
int (*create_loader) (DB_ENV *env, DB_TXN *txn, DB_LOADER **blp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t dbt_flags[/*N*/], uint32_t loader_flags);
|
||||
int (*create_indexer) (DB_ENV *env, DB_TXN *txn, DB_INDEXER **idxrp, DB *src_db, int N, DB *dbs[/*N*/], uint32_t db_flags[/*N*/], uint32_t indexer_flags);
|
||||
void *app_private;
|
||||
int (*put_multiple) (DB_ENV *env, DB *src_db, DB_TXN *txn,
|
||||
const DBT *src_key, const DBT *src_val,
|
||||
uint32_t num_dbs, DB **db_array, DBT *keys, DBT *vals, uint32_t *flags_array) /* insert into multiple DBs */;
|
||||
|
|
|
@ -106,8 +106,6 @@ struct brtnode_fetch_extra {
|
|||
// used in the case where type == brtnode_fetch_subset
|
||||
// parameters needed to find out which child needs to be decompressed (so it can be read)
|
||||
brt_search_t* search;
|
||||
DB *cmp_extra;
|
||||
brt_compare_func cmp;
|
||||
DBT *range_lock_left_key, *range_lock_right_key;
|
||||
BOOL left_is_neg_infty, right_is_pos_infty;
|
||||
// this value will be set during the fetch_callback call by toku_brtnode_fetch_callback or toku_brtnode_pf_req_callback
|
||||
|
@ -115,94 +113,8 @@ struct brtnode_fetch_extra {
|
|||
int child_to_read;
|
||||
};
|
||||
|
||||
//
|
||||
// Helper function to fill a brtnode_fetch_extra with data
|
||||
// that will tell the fetch callback that the entire node is
|
||||
// necessary. Used in cases where the entire node
|
||||
// is required, such as for flushes.
|
||||
//
|
||||
static inline void fill_bfe_for_full_read(struct brtnode_fetch_extra *bfe, struct brt_header *h, DB *cmp_extra, brt_compare_func cmp) {
|
||||
bfe->type = brtnode_fetch_all;
|
||||
bfe->h = h;
|
||||
bfe->search = NULL;
|
||||
bfe->cmp_extra = cmp_extra;
|
||||
bfe->cmp = cmp;
|
||||
bfe->range_lock_left_key = NULL;
|
||||
bfe->range_lock_right_key = NULL;
|
||||
bfe->left_is_neg_infty = FALSE;
|
||||
bfe->right_is_pos_infty = FALSE;
|
||||
bfe->child_to_read = -1;
|
||||
}
|
||||
|
||||
static inline void fill_bfe_for_prefetch(struct brtnode_fetch_extra *bfe, struct brt_header *h, DB *cmp_extra, brt_compare_func cmp, BRT_CURSOR c);
|
||||
|
||||
//
|
||||
// Helper function to fill a brtnode_fetch_extra with data
|
||||
// that will tell the fetch callback that some subset of the node
|
||||
// necessary. Used in cases where some of the node is required
|
||||
// such as for a point query.
|
||||
//
|
||||
static inline void fill_bfe_for_subset_read(
|
||||
struct brtnode_fetch_extra *bfe,
|
||||
struct brt_header *h,
|
||||
DB *cmp_extra,
|
||||
brt_compare_func cmp,
|
||||
brt_search_t* search,
|
||||
DBT *left,
|
||||
DBT *right,
|
||||
BOOL left_is_neg_infty,
|
||||
BOOL right_is_pos_infty
|
||||
)
|
||||
{
|
||||
bfe->type = brtnode_fetch_subset;
|
||||
bfe->h = h;
|
||||
bfe->search = search;
|
||||
bfe->cmp_extra = cmp_extra;
|
||||
bfe->cmp = cmp;
|
||||
bfe->range_lock_left_key = (left->data ? left : NULL);
|
||||
bfe->range_lock_right_key = (right->data ? right : NULL);
|
||||
bfe->left_is_neg_infty = left_is_neg_infty;
|
||||
bfe->right_is_pos_infty = right_is_pos_infty;
|
||||
bfe->child_to_read = -1;
|
||||
}
|
||||
|
||||
//
|
||||
// Helper function to fill a brtnode_fetch_extra with data
|
||||
// that will tell the fetch callback that no partitions are
|
||||
// necessary, only the pivots and/or subtree estimates.
|
||||
// Currently used for stat64.
|
||||
//
|
||||
static inline void fill_bfe_for_min_read(struct brtnode_fetch_extra *bfe, struct brt_header *h, DB *cmp_extra, brt_compare_func cmp) {
|
||||
bfe->type = brtnode_fetch_none;
|
||||
bfe->h = h;
|
||||
bfe->search = NULL;
|
||||
bfe->cmp_extra = cmp_extra;
|
||||
bfe->cmp = cmp;
|
||||
bfe->range_lock_left_key = NULL;
|
||||
bfe->range_lock_right_key = NULL;
|
||||
bfe->left_is_neg_infty = FALSE;
|
||||
bfe->right_is_pos_infty = FALSE;
|
||||
bfe->child_to_read = -1;
|
||||
}
|
||||
|
||||
static inline void destroy_bfe_for_prefetch(struct brtnode_fetch_extra *bfe) {
|
||||
assert(bfe->type == brtnode_fetch_prefetch);
|
||||
if (bfe->range_lock_left_key != NULL) {
|
||||
toku_free(bfe->range_lock_left_key->data);
|
||||
toku_destroy_dbt(bfe->range_lock_left_key);
|
||||
toku_free(bfe->range_lock_left_key);
|
||||
bfe->range_lock_left_key = NULL;
|
||||
}
|
||||
if (bfe->range_lock_right_key != NULL) {
|
||||
toku_free(bfe->range_lock_right_key->data);
|
||||
toku_destroy_dbt(bfe->range_lock_right_key);
|
||||
toku_free(bfe->range_lock_right_key);
|
||||
bfe->range_lock_right_key = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct toku_fifo_entry_key_msn_heaviside_extra {
|
||||
DB *cmp_extra;
|
||||
DESCRIPTOR desc;
|
||||
brt_compare_func cmp;
|
||||
FIFO fifo;
|
||||
bytevec key;
|
||||
|
@ -216,7 +128,7 @@ int
|
|||
toku_fifo_entry_key_msn_heaviside(OMTVALUE v, void *extrap);
|
||||
|
||||
struct toku_fifo_entry_key_msn_cmp_extra {
|
||||
DB *cmp_extra;
|
||||
DESCRIPTOR desc;
|
||||
brt_compare_func cmp;
|
||||
FIFO fifo;
|
||||
};
|
||||
|
@ -237,9 +149,16 @@ struct brtnode_nonleaf_childinfo {
|
|||
unsigned int toku_bnc_nbytesinbuf(NONLEAF_CHILDINFO bnc);
|
||||
int toku_bnc_n_entries(NONLEAF_CHILDINFO bnc);
|
||||
long toku_bnc_memory_size(NONLEAF_CHILDINFO bnc);
|
||||
int toku_bnc_insert_msg(NONLEAF_CHILDINFO bnc, const void *key, ITEMLEN keylen, const void *data, ITEMLEN datalen, int type, MSN msn, XIDS xids, bool is_fresh, DB *cmp_extra, brt_compare_func cmp);
|
||||
int toku_bnc_insert_msg(NONLEAF_CHILDINFO bnc, const void *key, ITEMLEN keylen, const void *data, ITEMLEN datalen, int type, MSN msn, XIDS xids, bool is_fresh, DESCRIPTOR desc, brt_compare_func cmp);
|
||||
void toku_bnc_empty(NONLEAF_CHILDINFO bnc);
|
||||
int toku_bnc_flush_to_child(BRT t, NONLEAF_CHILDINFO bnc, BRTNODE child);
|
||||
int toku_bnc_flush_to_child(
|
||||
brt_compare_func compare_fun,
|
||||
brt_update_func update_fun,
|
||||
DESCRIPTOR desc,
|
||||
CACHEFILE cf,
|
||||
NONLEAF_CHILDINFO bnc,
|
||||
BRTNODE child
|
||||
);
|
||||
|
||||
// data of an available partition of a leaf brtnode
|
||||
struct brtnode_leaf_basement_node {
|
||||
|
@ -480,6 +399,9 @@ struct brt_header {
|
|||
struct toku_list live_brts;
|
||||
struct toku_list zombie_brts;
|
||||
struct toku_list checkpoint_before_commit_link;
|
||||
|
||||
brt_compare_func compare_fun;
|
||||
brt_update_func update_fun;
|
||||
};
|
||||
|
||||
struct brt {
|
||||
|
@ -493,12 +415,8 @@ struct brt {
|
|||
unsigned int basementnodesize;
|
||||
unsigned int flags;
|
||||
BOOL did_set_flags;
|
||||
int (*compare_fun)(DB*,const DBT*,const DBT*);
|
||||
|
||||
int (*update_fun)(DB*,
|
||||
const DBT*key, const DBT *old_val, const DBT *extra,
|
||||
void (*set_val)(const DBT *new_val, void*set_extra), void *set_extra);
|
||||
|
||||
brt_compare_func compare_fun;
|
||||
brt_update_func update_fun;
|
||||
DB *db; // To pass to the compare fun, and close once transactions are done.
|
||||
|
||||
OMT txns; // transactions that are using this OMT (note that the transaction checks the cf also)
|
||||
|
@ -513,6 +431,7 @@ struct brt {
|
|||
};
|
||||
|
||||
long brtnode_memory_size (BRTNODE node);
|
||||
PAIR_ATTR make_brtnode_pair_attr(BRTNODE node);
|
||||
|
||||
/* serialization code */
|
||||
void
|
||||
|
@ -531,7 +450,7 @@ int toku_serialize_rollback_log_to (int fd, BLOCKNUM blocknum, ROLLBACK_LOG_NODE
|
|||
BOOL for_checkpoint);
|
||||
int toku_deserialize_rollback_log_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash, ROLLBACK_LOG_NODE *logp, struct brt_header *h);
|
||||
void toku_deserialize_bp_from_disk(BRTNODE node, int childnum, int fd, struct brtnode_fetch_extra* bfe);
|
||||
void toku_deserialize_bp_from_compressed(BRTNODE node, int childnum, DB *cmp_extra, brt_compare_func cmp);
|
||||
void toku_deserialize_bp_from_compressed(BRTNODE node, int childnum, DESCRIPTOR desc, brt_compare_func cmp);
|
||||
int toku_deserialize_brtnode_from (int fd, BLOCKNUM off, u_int32_t /*fullhash*/, BRTNODE *brtnode, struct brtnode_fetch_extra* bfe);
|
||||
unsigned int toku_serialize_brtnode_size(BRTNODE node); /* How much space will it take? */
|
||||
int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len);
|
||||
|
@ -557,7 +476,7 @@ void toku_assert_entire_node_in_memory(BRTNODE node);
|
|||
void toku_brt_nonleaf_append_child(BRTNODE node, BRTNODE child, struct kv_pair *pivotkey, size_t pivotkeysize);
|
||||
|
||||
// append a cmd to a nonleaf node child buffer
|
||||
void toku_brt_append_to_child_buffer(BRT brt, BRTNODE node, int childnum, int type, MSN msn, XIDS xids, bool is_fresh, const DBT *key, const DBT *val);
|
||||
void toku_brt_append_to_child_buffer(brt_compare_func compare_fun, DESCRIPTOR desc, BRTNODE node, int childnum, int type, MSN msn, XIDS xids, bool is_fresh, const DBT *key, const DBT *val);
|
||||
|
||||
#if 1
|
||||
#define DEADBEEF ((void*)0xDEADBEEF)
|
||||
|
@ -571,14 +490,15 @@ struct brtenv {
|
|||
long long checksum_number;
|
||||
};
|
||||
|
||||
extern void toku_brtnode_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM nodename, void *brtnode_v, void *extraargs, long size, long* new_size, BOOL write_me, BOOL keep_me, BOOL for_checkpoint);
|
||||
extern int toku_brtnode_fetch_callback (CACHEFILE cachefile, int fd, BLOCKNUM nodename, u_int32_t fullhash, void **brtnode_pv, long *sizep, int*dirty, void*extraargs);
|
||||
extern void toku_brtnode_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM nodename, void *brtnode_v, void *extraargs, PAIR_ATTR size, PAIR_ATTR* new_size, BOOL write_me, BOOL keep_me, BOOL for_checkpoint);
|
||||
extern int toku_brtnode_fetch_callback (CACHEFILE cachefile, int fd, BLOCKNUM nodename, u_int32_t fullhash, void **brtnode_pv, PAIR_ATTR *sizep, int*dirty, void*extraargs);
|
||||
extern void toku_brtnode_pe_est_callback(void* brtnode_pv, long* bytes_freed_estimate, enum partial_eviction_cost *cost, void* write_extraargs);
|
||||
extern int toku_brtnode_pe_callback (void *brtnode_pv, long bytes_to_free, long* bytes_freed, void *extraargs);
|
||||
extern int toku_brtnode_pe_callback (void *brtnode_pv, PAIR_ATTR old_attr, PAIR_ATTR* new_attr, void *extraargs);
|
||||
extern BOOL toku_brtnode_pf_req_callback(void* brtnode_pv, void* read_extraargs);
|
||||
int toku_brtnode_pf_callback(void* brtnode_pv, void* read_extraargs, int fd, long* sizep);
|
||||
int toku_brtnode_pf_callback(void* brtnode_pv, void* read_extraargs, int fd, PAIR_ATTR* sizep);
|
||||
extern int toku_brtnode_cleaner_callback (void* brtnode_pv, BLOCKNUM blocknum, u_int32_t fullhash, void* extraargs);
|
||||
extern int toku_brt_alloc_init_header(BRT t, TOKUTXN txn);
|
||||
extern int toku_read_brt_header_and_store_in_cachefile (CACHEFILE cf, LSN max_acceptable_lsn, struct brt_header **header, BOOL* was_open);
|
||||
extern int toku_read_brt_header_and_store_in_cachefile (BRT brt, CACHEFILE cf, LSN max_acceptable_lsn, struct brt_header **header, BOOL* was_open);
|
||||
extern CACHEKEY* toku_calculate_root_offset_pointer (BRT brt, u_int32_t *root_hash);
|
||||
|
||||
static const BRTNODE null_brtnode=0;
|
||||
|
@ -611,17 +531,89 @@ struct brt_cursor {
|
|||
struct brt_cursor_leaf_info leaf_info;
|
||||
};
|
||||
|
||||
//
|
||||
// Helper function to fill a brtnode_fetch_extra with data
|
||||
// that will tell the fetch callback that the entire node is
|
||||
// necessary. Used in cases where the entire node
|
||||
// is required, such as for flushes.
|
||||
//
|
||||
static inline void fill_bfe_for_full_read(struct brtnode_fetch_extra *bfe, struct brt_header *h) {
|
||||
bfe->type = brtnode_fetch_all;
|
||||
bfe->h = h;
|
||||
bfe->search = NULL;
|
||||
bfe->range_lock_left_key = NULL;
|
||||
bfe->range_lock_right_key = NULL;
|
||||
bfe->left_is_neg_infty = FALSE;
|
||||
bfe->right_is_pos_infty = FALSE;
|
||||
bfe->child_to_read = -1;
|
||||
}
|
||||
|
||||
//
|
||||
// Helper function to fill a brtnode_fetch_extra with data
|
||||
// that will tell the fetch callback that some subset of the node
|
||||
// necessary. Used in cases where some of the node is required
|
||||
// such as for a point query.
|
||||
//
|
||||
static inline void fill_bfe_for_subset_read(
|
||||
struct brtnode_fetch_extra *bfe,
|
||||
struct brt_header *h,
|
||||
brt_search_t* search,
|
||||
DBT *left,
|
||||
DBT *right,
|
||||
BOOL left_is_neg_infty,
|
||||
BOOL right_is_pos_infty
|
||||
)
|
||||
{
|
||||
bfe->type = brtnode_fetch_subset;
|
||||
bfe->h = h;
|
||||
bfe->search = search;
|
||||
bfe->range_lock_left_key = (left->data ? left : NULL);
|
||||
bfe->range_lock_right_key = (right->data ? right : NULL);
|
||||
bfe->left_is_neg_infty = left_is_neg_infty;
|
||||
bfe->right_is_pos_infty = right_is_pos_infty;
|
||||
bfe->child_to_read = -1;
|
||||
}
|
||||
|
||||
//
|
||||
// Helper function to fill a brtnode_fetch_extra with data
|
||||
// that will tell the fetch callback that no partitions are
|
||||
// necessary, only the pivots and/or subtree estimates.
|
||||
// Currently used for stat64.
|
||||
//
|
||||
static inline void fill_bfe_for_min_read(struct brtnode_fetch_extra *bfe, struct brt_header *h) {
|
||||
bfe->type = brtnode_fetch_none;
|
||||
bfe->h = h;
|
||||
bfe->search = NULL;
|
||||
bfe->range_lock_left_key = NULL;
|
||||
bfe->range_lock_right_key = NULL;
|
||||
bfe->left_is_neg_infty = FALSE;
|
||||
bfe->right_is_pos_infty = FALSE;
|
||||
bfe->child_to_read = -1;
|
||||
}
|
||||
|
||||
static inline void destroy_bfe_for_prefetch(struct brtnode_fetch_extra *bfe) {
|
||||
assert(bfe->type == brtnode_fetch_prefetch);
|
||||
if (bfe->range_lock_left_key != NULL) {
|
||||
toku_free(bfe->range_lock_left_key->data);
|
||||
toku_destroy_dbt(bfe->range_lock_left_key);
|
||||
toku_free(bfe->range_lock_left_key);
|
||||
bfe->range_lock_left_key = NULL;
|
||||
}
|
||||
if (bfe->range_lock_right_key != NULL) {
|
||||
toku_free(bfe->range_lock_right_key->data);
|
||||
toku_destroy_dbt(bfe->range_lock_right_key);
|
||||
toku_free(bfe->range_lock_right_key);
|
||||
bfe->range_lock_right_key = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// this is in a strange place because it needs the cursor struct to be defined
|
||||
static inline void fill_bfe_for_prefetch(struct brtnode_fetch_extra *bfe,
|
||||
struct brt_header *h,
|
||||
DB *cmp_extra,
|
||||
brt_compare_func cmp,
|
||||
BRT_CURSOR c) {
|
||||
bfe->type = brtnode_fetch_prefetch;
|
||||
bfe->h = h;
|
||||
bfe->search = NULL;
|
||||
bfe->cmp_extra = cmp_extra;
|
||||
bfe->cmp = cmp;
|
||||
{
|
||||
const DBT *left = &c->range_lock_left_key;
|
||||
const DBT *right = &c->range_lock_right_key;
|
||||
|
@ -658,7 +650,7 @@ void maybe_apply_ancestors_messages_to_node (BRT t, BRTNODE node, ANCESTORS ance
|
|||
|
||||
int
|
||||
toku_brt_search_which_child(
|
||||
DB *cmp_extra,
|
||||
DESCRIPTOR desc,
|
||||
brt_compare_func cmp,
|
||||
BRTNODE node,
|
||||
brt_search_t *search
|
||||
|
@ -698,7 +690,7 @@ void toku_pin_brtnode_holding_lock (BRT brt, BLOCKNUM blocknum, u_int32_t fullha
|
|||
BRTNODE *node_p);
|
||||
void toku_unpin_brtnode (BRT brt, BRTNODE node);
|
||||
unsigned int toku_brtnode_which_child(BRTNODE node, const DBT *k,
|
||||
DB *cmp_extra, brt_compare_func cmp)
|
||||
DESCRIPTOR desc, brt_compare_func cmp)
|
||||
__attribute__((__warn_unused_result__));
|
||||
|
||||
/* Stuff for testing */
|
||||
|
@ -713,7 +705,8 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM, enum brt_msg_type, char
|
|||
|
||||
// These two go together to do lookups in a brtnode using the keys in a command.
|
||||
struct cmd_leafval_heaviside_extra {
|
||||
BRT t;
|
||||
brt_compare_func compare_fun;
|
||||
DESCRIPTOR desc;
|
||||
DBT const * const key;
|
||||
};
|
||||
int toku_cmd_leafval_heaviside (OMTVALUE leafentry, void *extra)
|
||||
|
@ -770,8 +763,6 @@ typedef struct brt_status {
|
|||
u_int64_t msn_discards; // how many messages were ignored by leaf because of msn
|
||||
u_int64_t max_workdone; // max workdone value of any buffer
|
||||
u_int64_t dsn_gap; // dsn has detected a gap in continuity of root-to-leaf path (internal node was evicted and re-read)
|
||||
u_int64_t bytes_leaf; // memory used by leaf nodes
|
||||
u_int64_t bytes_nonleaf; // memory used by nonleaf nodes
|
||||
uint64_t total_searches; // total number of searches
|
||||
uint64_t total_retries; // total number of search retries due to TRY_AGAIN
|
||||
uint64_t max_search_excess_retries; // max number of excess search retries (retries - treeheight) due to TRY_AGAIN
|
||||
|
@ -784,7 +775,7 @@ typedef struct brt_status {
|
|||
void toku_brt_get_status(BRT_STATUS);
|
||||
|
||||
void
|
||||
brtleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *splitk, BOOL create_new_node, u_int32_t num_dependent_nodes, BRTNODE* dependent_nodes);
|
||||
brtleaf_split (struct brt_header* h, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *splitk, BOOL create_new_node, u_int32_t num_dependent_nodes, BRTNODE* dependent_nodes);
|
||||
|
||||
void
|
||||
brt_leaf_apply_cmd_once (
|
||||
|
@ -800,7 +791,9 @@ brt_leaf_apply_cmd_once (
|
|||
|
||||
void
|
||||
brt_leaf_put_cmd (
|
||||
BRT t,
|
||||
brt_compare_func compare_fun,
|
||||
brt_update_func update_fun,
|
||||
DESCRIPTOR desc,
|
||||
BASEMENTNODE bn,
|
||||
SUBTREE_EST se,
|
||||
BRT_MSG cmd,
|
||||
|
@ -810,7 +803,17 @@ brt_leaf_put_cmd (
|
|||
OMT live_list_reverse
|
||||
);
|
||||
|
||||
void toku_apply_cmd_to_leaf(BRT t, BRTNODE node, BRT_MSG cmd, bool *made_change, uint64_t *workdone, OMT snapshot_txnids, OMT live_list_reverse);
|
||||
void toku_apply_cmd_to_leaf(
|
||||
brt_compare_func compare_fun,
|
||||
brt_update_func update_fun,
|
||||
DESCRIPTOR desc,
|
||||
BRTNODE node,
|
||||
BRT_MSG cmd,
|
||||
bool *made_change,
|
||||
uint64_t *workdone,
|
||||
OMT snapshot_txnids,
|
||||
OMT live_list_reverse
|
||||
);
|
||||
|
||||
void toku_reset_root_xid_that_created(BRT brt, TXNID new_root_xid_that_created);
|
||||
// Reset the root_xid_that_created field to the given value.
|
||||
|
|
|
@ -849,7 +849,7 @@ toku_serialize_brtnode_to (int fd, BLOCKNUM blocknum, BRTNODE node, struct brt_h
|
|||
|
||||
static void
|
||||
deserialize_child_buffer(NONLEAF_CHILDINFO bnc, struct rbuf *rbuf,
|
||||
DB *cmp_extra, brt_compare_func cmp) {
|
||||
DESCRIPTOR desc, brt_compare_func cmp) {
|
||||
int r;
|
||||
int n_bytes_in_buffer = 0;
|
||||
int n_in_this_buffer = rbuf_int(rbuf);
|
||||
|
@ -903,7 +903,7 @@ deserialize_child_buffer(NONLEAF_CHILDINFO bnc, struct rbuf *rbuf,
|
|||
invariant(rbuf->ndone == rbuf->size);
|
||||
|
||||
if (cmp) {
|
||||
struct toku_fifo_entry_key_msn_cmp_extra extra = { .cmp_extra = cmp_extra, .cmp = cmp, .fifo = bnc->buffer };
|
||||
struct toku_fifo_entry_key_msn_cmp_extra extra = { .desc = desc, .cmp = cmp, .fifo = bnc->buffer };
|
||||
r = mergesort_r(fresh_offsets, nfresh, sizeof fresh_offsets[0], &extra, toku_fifo_entry_key_msn_cmp);
|
||||
assert_zero(r);
|
||||
toku_omt_destroy(&bnc->fresh_message_tree);
|
||||
|
@ -1199,11 +1199,10 @@ static void setup_brtnode_partitions(BRTNODE node, struct brtnode_fetch_extra* b
|
|||
// we can possibly require is a single basement node
|
||||
// we find out what basement node the query cares about
|
||||
// and check if it is available
|
||||
assert(bfe->cmp);
|
||||
assert(bfe->search);
|
||||
bfe->child_to_read = toku_brt_search_which_child(
|
||||
bfe->cmp_extra,
|
||||
bfe->cmp,
|
||||
&bfe->h->descriptor,
|
||||
bfe->h->compare_fun,
|
||||
node,
|
||||
bfe->search
|
||||
);
|
||||
|
@ -1252,7 +1251,7 @@ deserialize_brtnode_partition(
|
|||
struct sub_block *sb,
|
||||
BRTNODE node,
|
||||
int index,
|
||||
DB *cmp_extra,
|
||||
DESCRIPTOR desc,
|
||||
brt_compare_func cmp
|
||||
)
|
||||
{
|
||||
|
@ -1267,7 +1266,7 @@ deserialize_brtnode_partition(
|
|||
if (node->height > 0) {
|
||||
unsigned char ch = rbuf_char(&rb);
|
||||
assert(ch == BRTNODE_PARTITION_FIFO_MSG);
|
||||
deserialize_child_buffer(BNC(node, index), &rb, cmp_extra, cmp);
|
||||
deserialize_child_buffer(BNC(node, index), &rb, desc, cmp);
|
||||
BP_WORKDONE(node, index) = 0;
|
||||
}
|
||||
else {
|
||||
|
@ -1297,11 +1296,11 @@ deserialize_brtnode_partition(
|
|||
}
|
||||
|
||||
static void
|
||||
decompress_and_deserialize_worker(struct rbuf curr_rbuf, struct sub_block curr_sb, BRTNODE node, int child, DB *cmp_extra, brt_compare_func cmp)
|
||||
decompress_and_deserialize_worker(struct rbuf curr_rbuf, struct sub_block curr_sb, BRTNODE node, int child, DESCRIPTOR desc, brt_compare_func cmp)
|
||||
{
|
||||
read_and_decompress_sub_block(&curr_rbuf, &curr_sb);
|
||||
// at this point, sb->uncompressed_ptr stores the serialized node partition
|
||||
deserialize_brtnode_partition(&curr_sb, node, child, cmp_extra, cmp);
|
||||
deserialize_brtnode_partition(&curr_sb, node, child, desc, cmp);
|
||||
toku_free(curr_sb.uncompressed_ptr);
|
||||
}
|
||||
|
||||
|
@ -1564,7 +1563,7 @@ deserialize_brtnode_from_rbuf(
|
|||
switch (BP_STATE(node,i)) {
|
||||
case PT_AVAIL:
|
||||
// case where we read and decompress the partition
|
||||
decompress_and_deserialize_worker(curr_rbuf, curr_sb, node, i, bfe->cmp_extra, bfe->cmp);
|
||||
decompress_and_deserialize_worker(curr_rbuf, curr_sb, node, i, &bfe->h->descriptor, bfe->h->compare_fun);
|
||||
continue;
|
||||
case PT_COMPRESSED:
|
||||
// case where we leave the partition in the compressed state
|
||||
|
@ -1626,7 +1625,7 @@ toku_deserialize_bp_from_disk(BRTNODE node, int childnum, int fd, struct brtnode
|
|||
|
||||
read_and_decompress_sub_block(&rb, &curr_sb);
|
||||
// at this point, sb->uncompressed_ptr stores the serialized node partition
|
||||
deserialize_brtnode_partition(&curr_sb, node, childnum, bfe->cmp_extra, bfe->cmp);
|
||||
deserialize_brtnode_partition(&curr_sb, node, childnum, &bfe->h->descriptor, bfe->h->compare_fun);
|
||||
if (node->height == 0) {
|
||||
toku_brt_bn_reset_stats(node, childnum);
|
||||
}
|
||||
|
@ -1638,7 +1637,7 @@ toku_deserialize_bp_from_disk(BRTNODE node, int childnum, int fd, struct brtnode
|
|||
// Take a brtnode partition that is in the compressed state, and make it avail
|
||||
void
|
||||
toku_deserialize_bp_from_compressed(BRTNODE node, int childnum,
|
||||
DB *cmp_extra, brt_compare_func cmp) {
|
||||
DESCRIPTOR desc, brt_compare_func cmp) {
|
||||
assert(BP_STATE(node, childnum) == PT_COMPRESSED);
|
||||
SUB_BLOCK curr_sb = BSB(node, childnum);
|
||||
|
||||
|
@ -1654,7 +1653,7 @@ toku_deserialize_bp_from_compressed(BRTNODE node, int childnum,
|
|||
curr_sb->compressed_ptr,
|
||||
curr_sb->compressed_size
|
||||
);
|
||||
deserialize_brtnode_partition(curr_sb, node, childnum, cmp_extra, cmp);
|
||||
deserialize_brtnode_partition(curr_sb, node, childnum, desc, cmp);
|
||||
if (node->height == 0) {
|
||||
toku_brt_bn_reset_stats(node, childnum);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ BOOL ignore_if_was_already_open;
|
|||
int toku_testsetup_leaf(BRT brt, BLOCKNUM *blocknum) {
|
||||
BRTNODE node;
|
||||
assert(testsetup_initialized);
|
||||
int r = toku_read_brt_header_and_store_in_cachefile(brt->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
|
||||
int r = toku_read_brt_header_and_store_in_cachefile(brt, brt->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
|
||||
if (r!=0) return r;
|
||||
toku_create_new_brtnode(brt, &node, 0, 1);
|
||||
BP_STATE(node,0) = PT_AVAIL;
|
||||
|
@ -47,7 +47,7 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *blocknum, int n_child
|
|||
BRTNODE node;
|
||||
assert(testsetup_initialized);
|
||||
assert(n_children<=BRT_FANOUT);
|
||||
int r = toku_read_brt_header_and_store_in_cachefile(brt->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
|
||||
int r = toku_read_brt_header_and_store_in_cachefile(brt, brt->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
|
||||
if (r!=0) return r;
|
||||
toku_create_new_brtnode(brt, &node, height, n_children);
|
||||
int i;
|
||||
|
@ -56,8 +56,8 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *blocknum, int n_child
|
|||
BP_STATE(node,i) = PT_AVAIL;
|
||||
}
|
||||
for (i=0; i+1<n_children; i++) {
|
||||
node->childkeys[i] = kv_pair_malloc(keys[i], keylens[i], 0, 0);
|
||||
node->totalchildkeylens += keylens[i];
|
||||
node->childkeys[i] = kv_pair_malloc(keys[i], keylens[i], 0, 0);
|
||||
node->totalchildkeylens += keylens[i];
|
||||
}
|
||||
*blocknum = node->thisnodename;
|
||||
toku_unpin_brtnode(brt, node);
|
||||
|
@ -66,7 +66,7 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *blocknum, int n_child
|
|||
|
||||
int toku_testsetup_root(BRT brt, BLOCKNUM blocknum) {
|
||||
assert(testsetup_initialized);
|
||||
int r = toku_read_brt_header_and_store_in_cachefile(brt->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
|
||||
int r = toku_read_brt_header_and_store_in_cachefile(brt, brt->cf, MAX_LSN, &brt->h, &ignore_if_was_already_open);
|
||||
if (r!=0) return r;
|
||||
brt->h->root = blocknum;
|
||||
brt->h->root_hash.valid = FALSE;
|
||||
|
@ -78,7 +78,7 @@ int toku_testsetup_get_sersize(BRT brt, BLOCKNUM diskoff) // Return the size on
|
|||
assert(testsetup_initialized);
|
||||
void *node_v;
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_full_read(&bfe, brt->h, brt->db, brt->compare_fun);
|
||||
fill_bfe_for_full_read(&bfe, brt->h);
|
||||
int r = toku_cachetable_get_and_pin(
|
||||
brt->cf, diskoff,
|
||||
toku_cachetable_hash(brt->cf, diskoff),
|
||||
|
@ -90,6 +90,7 @@ int toku_testsetup_get_sersize(BRT brt, BLOCKNUM diskoff) // Return the size on
|
|||
toku_brtnode_pe_callback,
|
||||
toku_brtnode_pf_req_callback,
|
||||
toku_brtnode_pf_callback,
|
||||
toku_brtnode_cleaner_callback,
|
||||
&bfe,
|
||||
brt->h
|
||||
);
|
||||
|
@ -106,7 +107,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
|
|||
assert(testsetup_initialized);
|
||||
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_full_read(&bfe, brt->h, brt->db, brt->compare_fun);
|
||||
fill_bfe_for_full_read(&bfe, brt->h);
|
||||
r = toku_cachetable_get_and_pin(
|
||||
brt->cf,
|
||||
blocknum,
|
||||
|
@ -119,6 +120,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
|
|||
toku_brtnode_pe_callback,
|
||||
toku_brtnode_pf_req_callback,
|
||||
toku_brtnode_pf_callback,
|
||||
toku_brtnode_cleaner_callback,
|
||||
&bfe,
|
||||
brt->h
|
||||
);
|
||||
|
@ -143,7 +145,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
|
|||
assert(r==0);
|
||||
|
||||
|
||||
struct cmd_leafval_heaviside_extra be = {brt, &keydbt};
|
||||
struct cmd_leafval_heaviside_extra be = {brt->compare_fun, &brt->h->descriptor, &keydbt};
|
||||
r = toku_omt_find_zero(BLB_BUFFER(node, 0), toku_cmd_leafval_heaviside, &be, &storeddatav, &idx);
|
||||
|
||||
|
||||
|
@ -185,7 +187,7 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t
|
|||
assert(testsetup_initialized);
|
||||
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_full_read(&bfe, brt->h, brt->db, brt->compare_fun);
|
||||
fill_bfe_for_full_read(&bfe, brt->h);
|
||||
r = toku_cachetable_get_and_pin(
|
||||
brt->cf,
|
||||
blocknum,
|
||||
|
@ -198,6 +200,7 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t
|
|||
toku_brtnode_pe_callback,
|
||||
toku_brtnode_pf_req_callback,
|
||||
toku_brtnode_pf_callback,
|
||||
toku_brtnode_cleaner_callback,
|
||||
&bfe,
|
||||
brt->h
|
||||
);
|
||||
|
@ -208,7 +211,7 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t
|
|||
DBT k;
|
||||
int childnum = toku_brtnode_which_child(node,
|
||||
toku_fill_dbt(&k, key, keylen),
|
||||
brt->db, brt->compare_fun);
|
||||
&brt->h->descriptor, brt->compare_fun);
|
||||
|
||||
XIDS xids_0 = xids_get_root_xids();
|
||||
MSN msn = next_dummymsn();
|
||||
|
|
|
@ -175,7 +175,7 @@ toku_verify_brtnode (BRT brt,
|
|||
u_int32_t fullhash = toku_cachetable_hash(brt->cf, blocknum);
|
||||
{
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_full_read(&bfe, brt->h, brt->db, brt->compare_fun);
|
||||
fill_bfe_for_full_read(&bfe, brt->h);
|
||||
int r = toku_cachetable_get_and_pin(
|
||||
brt->cf,
|
||||
blocknum,
|
||||
|
@ -188,6 +188,7 @@ toku_verify_brtnode (BRT brt,
|
|||
toku_brtnode_pe_callback,
|
||||
toku_brtnode_pf_req_callback,
|
||||
toku_brtnode_pf_callback,
|
||||
toku_brtnode_cleaner_callback,
|
||||
&bfe,
|
||||
brt->h
|
||||
);
|
||||
|
@ -332,7 +333,7 @@ toku_verify_brtnode (BRT brt,
|
|||
}
|
||||
done:
|
||||
{
|
||||
int r = toku_cachetable_unpin(brt->cf, blocknum, fullhash, CACHETABLE_CLEAN, 0);
|
||||
int r = toku_cachetable_unpin(brt->cf, blocknum, fullhash, CACHETABLE_CLEAN, make_brtnode_pair_attr(node));
|
||||
assert_zero(r); // this is a bad failure if it happens.
|
||||
}
|
||||
|
||||
|
|
729
newbrt/brt.c
729
newbrt/brt.c
File diff suppressed because it is too large
Load diff
|
@ -28,7 +28,7 @@ C_BEGIN
|
|||
//-infinity depending on direction)
|
||||
typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN, bytevec, ITEMLEN, bytevec, void*);
|
||||
|
||||
int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, int basementnodesize, CACHETABLE, TOKUTXN, int(*)(DB*,const DBT*,const DBT*), DB*) __attribute__ ((warn_unused_result));
|
||||
int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, int basementnodesize, CACHETABLE, TOKUTXN, int(*)(DB *,const DBT*,const DBT*), DB*) __attribute__ ((warn_unused_result));
|
||||
int toku_brt_change_descriptor(BRT t, const DBT* old_descriptor, const DBT* new_descriptor, BOOL do_log, TOKUTXN txn);
|
||||
int toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd);
|
||||
|
||||
|
@ -89,10 +89,7 @@ brt_compare_func toku_brt_get_bt_compare (BRT brt);
|
|||
|
||||
// Question: Why does the update_function need a DB_TXN?
|
||||
|
||||
int toku_brt_set_update(BRT brt, int (*update_fun)(DB *,
|
||||
const DBT *key, const DBT *old_val, const DBT *extra,
|
||||
void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra))
|
||||
__attribute__ ((warn_unused_result));
|
||||
int toku_brt_set_update(BRT brt, brt_update_func update_fun) __attribute__ ((warn_unused_result));
|
||||
int toku_brt_update(BRT brt, TOKUTXN txn, const DBT *key, const DBT *extra) __attribute__ ((warn_unused_result));
|
||||
int toku_brt_broadcast_update(BRT brt, TOKUTXN txn, const DBT *extra) __attribute__ ((warn_unused_result));
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ static void
|
|||
dump_node (int f, BLOCKNUM blocknum, struct brt_header *h) {
|
||||
BRTNODE n;
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_full_read(&bfe, h, NULL, NULL);
|
||||
fill_bfe_for_full_read(&bfe, h);
|
||||
int r = toku_deserialize_brtnode_from (f, blocknum, 0 /*pass zero for hash, it doesn't matter*/, &n, &bfe);
|
||||
assert(r==0);
|
||||
assert(n!=0);
|
||||
|
@ -231,7 +231,7 @@ fragmentation_helper(BLOCKNUM b, int64_t size, int64_t UU(address), void *extra)
|
|||
frag_help_extra *info = extra;
|
||||
BRTNODE n;
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_full_read(&bfe, info->h, NULL, NULL);
|
||||
fill_bfe_for_full_read(&bfe, info->h);
|
||||
int r = toku_deserialize_brtnode_from(info->f, b, 0 /*pass zero for hash, it doesn't matter*/, &n, &bfe);
|
||||
if (r==0) {
|
||||
info->blocksizes += size;
|
||||
|
|
|
@ -38,11 +38,30 @@ typedef u_int64_t TXNID;
|
|||
#define TXNID_NONE_LIVING ((TXNID)0)
|
||||
#define TXNID_NONE ((TXNID)0)
|
||||
|
||||
typedef struct s_blocknum { int64_t b; } BLOCKNUM; // make a struct so that we will notice type problems.
|
||||
typedef struct blocknum_s { int64_t b; } BLOCKNUM; // make a struct so that we will notice type problems.
|
||||
#define ROLLBACK_NONE ((BLOCKNUM){0})
|
||||
|
||||
static inline BLOCKNUM make_blocknum(int64_t b) { BLOCKNUM result={b}; return result; }
|
||||
|
||||
typedef struct pair_attr_s {
|
||||
long size;
|
||||
long nonleaf_size;
|
||||
long leaf_size;
|
||||
long rollback_size;
|
||||
long cache_pressure_size;
|
||||
} PAIR_ATTR;
|
||||
|
||||
static inline PAIR_ATTR make_pair_attr(long size) {
|
||||
PAIR_ATTR result={
|
||||
.size = size,
|
||||
.nonleaf_size = 0,
|
||||
.leaf_size = 0,
|
||||
.rollback_size = 0,
|
||||
.cache_pressure_size = 0
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
u_int32_t len;
|
||||
char *data;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,6 +29,14 @@ extern "C" {
|
|||
|
||||
typedef BLOCKNUM CACHEKEY;
|
||||
|
||||
|
||||
int toku_set_cleaner_period (CACHETABLE ct, u_int32_t new_period);
|
||||
u_int32_t toku_get_cleaner_period (CACHETABLE ct);
|
||||
u_int32_t toku_get_cleaner_period_unlocked (CACHETABLE ct);
|
||||
int toku_set_cleaner_iterations (CACHETABLE ct, u_int32_t new_iterations);
|
||||
u_int32_t toku_get_cleaner_iterations (CACHETABLE ct);
|
||||
u_int32_t toku_get_cleaner_iterations_unlocked (CACHETABLE ct);
|
||||
|
||||
// cachetable operations
|
||||
|
||||
int toku_create_cachetable(CACHETABLE */*result*/, long size_limit, LSN initial_lsn, TOKULOGGER);
|
||||
|
@ -114,20 +122,26 @@ enum partial_eviction_cost {
|
|||
PE_EXPENSIVE=1, // running partial eviction is expensive, and should not be done on the client thread
|
||||
};
|
||||
|
||||
// cachetable pair clean or dirty WRT external memory
|
||||
enum cachetable_dirty {
|
||||
CACHETABLE_CLEAN=0, // the cached object is clean WRT the cachefile
|
||||
CACHETABLE_DIRTY=1, // the cached object is dirty WRT the cachefile
|
||||
};
|
||||
|
||||
// The flush callback is called when a key value pair is being written to storage and possibly removed from the cachetable.
|
||||
// When write_me is true, the value should be written to storage.
|
||||
// When keep_me is false, the value should be freed.
|
||||
// When for_checkpoint is true, this was a 'pending' write
|
||||
// Returns: 0 if success, otherwise an error number.
|
||||
// Can access fd (fd is protected by a readlock during call)
|
||||
typedef void (*CACHETABLE_FLUSH_CALLBACK)(CACHEFILE, int fd, CACHEKEY key, void *value, void *write_extraargs, long size, long* new_size, BOOL write_me, BOOL keep_me, BOOL for_checkpoint);
|
||||
typedef void (*CACHETABLE_FLUSH_CALLBACK)(CACHEFILE, int fd, CACHEKEY key, void *value, void *write_extraargs, PAIR_ATTR size, PAIR_ATTR* new_size, BOOL write_me, BOOL keep_me, BOOL for_checkpoint);
|
||||
|
||||
// The fetch callback is called when a thread is attempting to get and pin a memory
|
||||
// object and it is not in the cachetable.
|
||||
// Returns: 0 if success, otherwise an error number. The address and size of the object
|
||||
// associated with the key are returned.
|
||||
// Can access fd (fd is protected by a readlock during call)
|
||||
typedef int (*CACHETABLE_FETCH_CALLBACK)(CACHEFILE, int fd, CACHEKEY key, u_int32_t fullhash, void **value, long *sizep, int *dirtyp, void *read_extraargs);
|
||||
typedef int (*CACHETABLE_FETCH_CALLBACK)(CACHEFILE, int fd, CACHEKEY key, u_int32_t fullhash, void **value, PAIR_ATTR *sizep, int *dirtyp, void *read_extraargs);
|
||||
|
||||
// The partial eviction estimate callback is a cheap operation called by the cachetable on the client thread
|
||||
// to determine whether partial eviction is cheap and can be run on the client thread, or partial eviction
|
||||
|
@ -142,7 +156,7 @@ typedef void (*CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK)(void *brtnode_pv, long*
|
|||
// bytes_to_free is the number of bytes the cachetable wants freed.
|
||||
// bytes_freed is returned by the callback telling the cachetable how much space was freed
|
||||
// Requires a write lock to be held on the PAIR in the cachetable while this function is called
|
||||
typedef int (*CACHETABLE_PARTIAL_EVICTION_CALLBACK)(void *brtnode_pv, long bytes_to_free, long* bytes_freed, void *write_extraargs);
|
||||
typedef int (*CACHETABLE_PARTIAL_EVICTION_CALLBACK)(void *brtnode_pv, PAIR_ATTR old_attr, PAIR_ATTR* new_attr, void *write_extraargs);
|
||||
|
||||
// This callback is called by the cachetable to ask if a partial fetch is required of brtnode_pv. If a partial fetch
|
||||
// is required, then CACHETABLE_PARTIAL_FETCH_CALLBACK is called (possibly with ydb lock released). The reason
|
||||
|
@ -157,7 +171,11 @@ typedef BOOL (*CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK)(void *brtnode_pv, voi
|
|||
// Requires a write lock to be held on the PAIR in the cachetable while this function is called
|
||||
// The new size of the PAIR is returned in sizep
|
||||
// Returns: 0 if success, otherwise an error number.
|
||||
typedef int (*CACHETABLE_PARTIAL_FETCH_CALLBACK)(void *brtnode_pv, void *read_extraargs, int fd, long *sizep);
|
||||
typedef int (*CACHETABLE_PARTIAL_FETCH_CALLBACK)(void *brtnode_pv, void *read_extraargs, int fd, PAIR_ATTR *sizep);
|
||||
|
||||
// TODO(leif) XXX TODO XXX
|
||||
typedef int (*CACHETABLE_CLEANER_CALLBACK)(void *brtnode_pv, BLOCKNUM blocknum, u_int32_t fullhash, void *write_extraargs);
|
||||
|
||||
|
||||
typedef void (*CACHETABLE_GET_KEY_AND_FULLHASH)(CACHEKEY* cachekey, u_int32_t* fullhash, void* extra);
|
||||
|
||||
|
@ -181,13 +199,6 @@ void *toku_cachefile_get_userdata(CACHEFILE);
|
|||
CACHETABLE toku_cachefile_get_cachetable(CACHEFILE cf);
|
||||
// Effect: Get the cachetable.
|
||||
|
||||
// cachetable pair clean or dirty WRT external memory
|
||||
enum cachetable_dirty {
|
||||
CACHETABLE_CLEAN=0, // the cached object is clean WRT the cachefile
|
||||
CACHETABLE_DIRTY=1, // the cached object is dirty WRT the cachefile
|
||||
};
|
||||
|
||||
|
||||
void toku_checkpoint_pairs(
|
||||
CACHEFILE cf,
|
||||
u_int32_t num_dependent_pairs, // number of dependent pairs that we may need to checkpoint
|
||||
|
@ -204,10 +215,11 @@ int toku_cachetable_put_with_dep_pairs(
|
|||
CACHEFILE cachefile,
|
||||
CACHETABLE_GET_KEY_AND_FULLHASH get_key_and_fullhash,
|
||||
void*value,
|
||||
long size,
|
||||
PAIR_ATTR attr,
|
||||
CACHETABLE_FLUSH_CALLBACK flush_callback,
|
||||
CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK pe_est_callback,
|
||||
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
|
||||
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
|
||||
void *write_extraargs,
|
||||
void *get_key_and_fullhash_extra,
|
||||
u_int32_t num_dependent_pairs, // number of dependent pairs that we may need to checkpoint
|
||||
|
@ -227,10 +239,11 @@ int toku_cachetable_put_with_dep_pairs(
|
|||
// Returns: 0 if the memory object is placed into the cachetable, otherwise an
|
||||
// error number.
|
||||
int toku_cachetable_put(CACHEFILE cf, CACHEKEY key, u_int32_t fullhash,
|
||||
void *value, long size,
|
||||
void *value, PAIR_ATTR size,
|
||||
CACHETABLE_FLUSH_CALLBACK flush_callback,
|
||||
CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK pe_est_callback,
|
||||
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
|
||||
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
|
||||
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
|
||||
void *write_extraargs
|
||||
);
|
||||
|
||||
|
@ -247,6 +260,7 @@ int toku_cachetable_get_and_pin_with_dep_pairs (
|
|||
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback,
|
||||
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
|
||||
void* read_extraargs,
|
||||
void* write_extraargs,
|
||||
u_int32_t num_dependent_pairs, // number of dependent pairs that we may need to checkpoint
|
||||
|
@ -274,6 +288,7 @@ int toku_cachetable_get_and_pin (
|
|||
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback __attribute__((unused)),
|
||||
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback __attribute__((unused)),
|
||||
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
|
||||
void* read_extraargs,
|
||||
void* write_extraargs
|
||||
);
|
||||
|
@ -301,6 +316,7 @@ int toku_cachetable_get_and_pin_nonblocking (
|
|||
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback __attribute__((unused)),
|
||||
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback __attribute__((unused)),
|
||||
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
|
||||
void *read_extraargs,
|
||||
void* write_extraargs,
|
||||
UNLOCKERS unlockers
|
||||
|
@ -318,14 +334,14 @@ int toku_cachetable_maybe_get_and_pin (CACHEFILE, CACHEKEY, u_int32_t /*fullhash
|
|||
int toku_cachetable_maybe_get_and_pin_clean (CACHEFILE, CACHEKEY, u_int32_t /*fullhash*/, void**);
|
||||
// Effect: Like maybe get and pin, but may pin a clean pair.
|
||||
|
||||
int toku_cachetable_unpin(CACHEFILE, CACHEKEY, u_int32_t fullhash, enum cachetable_dirty dirty, long size);
|
||||
int toku_cachetable_unpin(CACHEFILE, CACHEKEY, u_int32_t fullhash, enum cachetable_dirty dirty, PAIR_ATTR size);
|
||||
// Effect: Unpin a memory object
|
||||
// Modifies: If the memory object is in the cachetable, then OR the dirty flag,
|
||||
// update the size, and release the read lock on the memory object.
|
||||
// Returns: 0 if success, otherwise returns an error number.
|
||||
// Requires: The ct is locked.
|
||||
|
||||
int toku_cachetable_unpin_ct_prelocked_no_flush(CACHEFILE, CACHEKEY, u_int32_t fullhash, enum cachetable_dirty dirty, long size);
|
||||
int toku_cachetable_unpin_ct_prelocked_no_flush(CACHEFILE, CACHEKEY, u_int32_t fullhash, enum cachetable_dirty dirty, PAIR_ATTR size);
|
||||
// Effect: The same as tokud_cachetable_unpin, except that the ct must not be locked.
|
||||
// Requires: The ct is NOT locked.
|
||||
|
||||
|
@ -347,6 +363,7 @@ int toku_cachefile_prefetch(CACHEFILE cf, CACHEKEY key, u_int32_t fullhash,
|
|||
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback,
|
||||
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
|
||||
void *read_extraargs,
|
||||
void *write_extraargs,
|
||||
BOOL *doing_prefetch);
|
||||
|
@ -496,6 +513,10 @@ typedef struct cachetable_status {
|
|||
uint64_t local_checkpoint_files; // number of files subject to local checkpoint taken for a commit (2440)
|
||||
uint64_t local_checkpoint_during_checkpoint; // number of times a local checkpoint happened during normal checkpoint (2440)
|
||||
u_int64_t evictions;
|
||||
int64_t size_nonleaf; // number of bytes in cachetable belonging to nonleaf nodes
|
||||
int64_t size_leaf; // number of bytes in cachetable belonging to leaf nodes
|
||||
int64_t size_rollback; // number of bytes in cachetable belonging to rollback nodes
|
||||
int64_t size_cachepressure; // number of bytes that cachetable thinks is causing cache pressure (sum of buffers, basically)
|
||||
} CACHETABLE_STATUS_S, *CACHETABLE_STATUS;
|
||||
|
||||
void toku_cachetable_get_status(CACHETABLE ct, CACHETABLE_STATUS s);
|
||||
|
@ -513,10 +534,14 @@ int toku_cachetable_local_checkpoint_for_commit(CACHETABLE ct, TOKUTXN txn, uint
|
|||
#endif
|
||||
|
||||
void cachefile_kibbutz_enq (CACHEFILE cf, void (*f)(void*), void *extra);
|
||||
// Effect: Add a job to the cachetable's collection of work to do. Note that function f must call notify_cachefile_that_kibbutz_job_finishing()
|
||||
// Effect: Add a job to the cachetable's collection of work to do. Note that function f must call remove_background_job()
|
||||
|
||||
void notify_cachefile_that_kibbutz_job_finishing (CACHEFILE cf);
|
||||
// Effect: When a kibbutz job finishes in a cachefile, the cachetable must be notified.
|
||||
void add_background_job (CACHEFILE cf, bool already_locked);
|
||||
// Effect: When a kibbutz job or cleaner thread starts working, the
|
||||
// cachefile must be notified (so during a close it can wait);
|
||||
void remove_background_job (CACHEFILE cf, bool already_locked);
|
||||
// Effect: When a kibbutz job or cleaner thread finishes in a cachefile,
|
||||
// the cachetable must be notified.
|
||||
|
||||
// test-only function
|
||||
extern int toku_cachetable_get_checkpointing_user_data_status(void);
|
||||
|
|
|
@ -445,15 +445,27 @@ int toku_rollback_abort(TOKUTXN txn, YIELDF yield, void*yieldv, LSN lsn) {
|
|||
return r;
|
||||
}
|
||||
|
||||
static inline PAIR_ATTR make_rollback_pair_attr(long size) {
|
||||
PAIR_ATTR result={
|
||||
.size = size,
|
||||
.nonleaf_size = 0,
|
||||
.leaf_size = 0,
|
||||
.rollback_size = size,
|
||||
.cache_pressure_size = 0
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Write something out. Keep trying even if partial writes occur.
|
||||
// On error: Return negative with errno set.
|
||||
// On success return nbytes.
|
||||
|
||||
static size_t
|
||||
static PAIR_ATTR
|
||||
rollback_memory_size(ROLLBACK_LOG_NODE log) {
|
||||
size_t size = sizeof(*log);
|
||||
size += memarena_total_memory_size(log->rollentry_arena);
|
||||
return size;
|
||||
return make_rollback_pair_attr(size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -467,7 +479,7 @@ toku_rollback_log_free(ROLLBACK_LOG_NODE *log_p) {
|
|||
}
|
||||
|
||||
static void toku_rollback_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM logname,
|
||||
void *rollback_v, void *extraargs, long size, long* new_size,
|
||||
void *rollback_v, void *extraargs, PAIR_ATTR size, PAIR_ATTR* new_size,
|
||||
BOOL write_me, BOOL keep_me, BOOL for_checkpoint) {
|
||||
int r;
|
||||
ROLLBACK_LOG_NODE log = rollback_v;
|
||||
|
@ -499,7 +511,7 @@ static void toku_rollback_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM
|
|||
}
|
||||
|
||||
static int toku_rollback_fetch_callback (CACHEFILE cachefile, int fd, BLOCKNUM logname, u_int32_t fullhash,
|
||||
void **rollback_pv, long *sizep, int * UU(dirtyp), void *extraargs) {
|
||||
void **rollback_pv, PAIR_ATTR *sizep, int * UU(dirtyp), void *extraargs) {
|
||||
int r;
|
||||
struct brt_header *h = extraargs;
|
||||
assert(h->cf == cachefile);
|
||||
|
@ -527,25 +539,35 @@ static void toku_rollback_pe_est_callback(
|
|||
// callback for partially evicting a cachetable entry
|
||||
static int toku_rollback_pe_callback (
|
||||
void *rollback_v,
|
||||
long UU(bytes_to_free),
|
||||
long* bytes_freed,
|
||||
PAIR_ATTR UU(old_attr),
|
||||
PAIR_ATTR* new_attr,
|
||||
void* UU(extraargs)
|
||||
)
|
||||
{
|
||||
assert(rollback_v != NULL);
|
||||
*bytes_freed = 0;
|
||||
*new_attr = old_attr;
|
||||
return 0;
|
||||
}
|
||||
static BOOL toku_rollback_pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int toku_rollback_pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
static int toku_rollback_pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), PAIR_ATTR* UU(sizep)) {
|
||||
// should never be called, given that toku_rollback_pf_req_callback always returns false
|
||||
assert(FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int toku_rollback_cleaner_callback (
|
||||
void* UU(brtnode_pv),
|
||||
BLOCKNUM UU(blocknum),
|
||||
u_int32_t UU(fullhash),
|
||||
void* UU(extraargs)
|
||||
)
|
||||
{
|
||||
assert(FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int toku_create_new_rollback_log (TOKUTXN txn, BLOCKNUM older, uint32_t older_hash, ROLLBACK_LOG_NODE *result) {
|
||||
|
@ -577,6 +599,7 @@ static int toku_create_new_rollback_log (TOKUTXN txn, BLOCKNUM older, uint32_t o
|
|||
toku_rollback_flush_callback,
|
||||
toku_rollback_pe_est_callback,
|
||||
toku_rollback_pe_callback,
|
||||
toku_rollback_cleaner_callback,
|
||||
h);
|
||||
assert(r==0);
|
||||
txn->current_rollback = log->thislogname;
|
||||
|
@ -807,6 +830,7 @@ toku_maybe_prefetch_older_rollback_log(TOKUTXN txn, ROLLBACK_LOG_NODE log) {
|
|||
toku_rollback_pe_callback,
|
||||
toku_brtnode_pf_req_callback,
|
||||
toku_brtnode_pf_callback,
|
||||
toku_rollback_cleaner_callback,
|
||||
h,
|
||||
h,
|
||||
&doing_prefetch);
|
||||
|
@ -838,6 +862,7 @@ int toku_get_and_pin_rollback_log(TOKUTXN txn, TXNID xid, uint64_t sequence, BLO
|
|||
toku_rollback_pe_callback,
|
||||
toku_rollback_pf_req_callback,
|
||||
toku_rollback_pf_callback,
|
||||
toku_rollback_cleaner_callback,
|
||||
h,
|
||||
h
|
||||
);
|
||||
|
|
|
@ -111,6 +111,7 @@ test_serialize_leaf(int valsize, int nelts, double entropy) {
|
|||
brt_h->type = BRTHEADER_CURRENT;
|
||||
brt_h->panic = 0; brt_h->panic_string = 0;
|
||||
brt_h->basementnodesize = 128*1024;
|
||||
brt_h->compare_fun = long_key_cmp;
|
||||
toku_blocktable_create_new(&brt_h->blocktable);
|
||||
//Want to use block #20
|
||||
BLOCKNUM b = make_blocknum(0);
|
||||
|
@ -140,7 +141,7 @@ test_serialize_leaf(int valsize, int nelts, double entropy) {
|
|||
printf("serialize leaf: %0.05lf\n", dt);
|
||||
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_full_read(&bfe, brt_h, NULL, long_key_cmp);
|
||||
fill_bfe_for_full_read(&bfe, brt_h);
|
||||
gettimeofday(&t[0], NULL);
|
||||
r = toku_deserialize_brtnode_from(fd, make_blocknum(20), 0/*pass zero for hash*/, &dn, &bfe);
|
||||
assert(r==0);
|
||||
|
@ -241,6 +242,7 @@ test_serialize_nonleaf(int valsize, int nelts, double entropy) {
|
|||
brt_h->type = BRTHEADER_CURRENT;
|
||||
brt_h->panic = 0; brt_h->panic_string = 0;
|
||||
brt_h->basementnodesize = 128*1024;
|
||||
brt_h->compare_fun = long_key_cmp;
|
||||
toku_blocktable_create_new(&brt_h->blocktable);
|
||||
//Want to use block #20
|
||||
BLOCKNUM b = make_blocknum(0);
|
||||
|
@ -270,7 +272,7 @@ test_serialize_nonleaf(int valsize, int nelts, double entropy) {
|
|||
printf("serialize nonleaf: %0.05lf\n", dt);
|
||||
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_full_read(&bfe, brt_h, NULL, long_key_cmp);
|
||||
fill_bfe_for_full_read(&bfe, brt_h);
|
||||
gettimeofday(&t[0], NULL);
|
||||
r = toku_deserialize_brtnode_from(fd, make_blocknum(20), 0/*pass zero for hash*/, &dn, &bfe);
|
||||
assert(r==0);
|
||||
|
|
|
@ -94,15 +94,16 @@ string_key_cmp(DB *UU(e), const DBT *a, const DBT *b)
|
|||
static void
|
||||
setup_dn(enum brtnode_verify_type bft, int fd, struct brt_header *brt_h, BRTNODE *dn) {
|
||||
int r;
|
||||
brt_h->compare_fun = string_key_cmp;
|
||||
if (bft == read_all) {
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_full_read(&bfe, brt_h, NULL, string_key_cmp);
|
||||
fill_bfe_for_full_read(&bfe, brt_h);
|
||||
r = toku_deserialize_brtnode_from(fd, make_blocknum(20), 0/*pass zero for hash*/, dn, &bfe);
|
||||
assert(r==0);
|
||||
}
|
||||
else if (bft == read_compressed || bft == read_none) {
|
||||
struct brtnode_fetch_extra bfe;
|
||||
fill_bfe_for_min_read(&bfe, brt_h, NULL, string_key_cmp);
|
||||
fill_bfe_for_min_read(&bfe, brt_h);
|
||||
r = toku_deserialize_brtnode_from(fd, make_blocknum(20), 0/*pass zero for hash*/, dn, &bfe);
|
||||
assert(r==0);
|
||||
// assert all bp's are compressed or on disk.
|
||||
|
@ -112,8 +113,8 @@ setup_dn(enum brtnode_verify_type bft, int fd, struct brt_header *brt_h, BRTNODE
|
|||
// if read_none, get rid of the compressed bp's
|
||||
if (bft == read_none) {
|
||||
if ((*dn)->height == 0) {
|
||||
long bytes_freed = 0;
|
||||
toku_brtnode_pe_callback(*dn, 0xffffffff, &bytes_freed, NULL);
|
||||
PAIR_ATTR attr;
|
||||
toku_brtnode_pe_callback(*dn, make_pair_attr(0xffffffff), &attr, NULL);
|
||||
// assert all bp's are on disk
|
||||
for (int i = 0; i < (*dn)->n_children; i++) {
|
||||
if ((*dn)->height == 0) {
|
||||
|
@ -129,34 +130,33 @@ setup_dn(enum brtnode_verify_type bft, int fd, struct brt_header *brt_h, BRTNODE
|
|||
// first decompress everything, and make sure
|
||||
// that it is available
|
||||
// then run partial eviction to get it compressed
|
||||
fill_bfe_for_full_read(&bfe, brt_h, NULL, string_key_cmp);
|
||||
PAIR_ATTR attr;
|
||||
fill_bfe_for_full_read(&bfe, brt_h);
|
||||
assert(toku_brtnode_pf_req_callback(*dn, &bfe));
|
||||
long size;
|
||||
r = toku_brtnode_pf_callback(*dn, &bfe, fd, &size);
|
||||
r = toku_brtnode_pf_callback(*dn, &bfe, fd, &attr);
|
||||
assert(r==0);
|
||||
// assert all bp's are available
|
||||
for (int i = 0; i < (*dn)->n_children; i++) {
|
||||
assert(BP_STATE(*dn,i) == PT_AVAIL);
|
||||
}
|
||||
long bytes_freed = 0;
|
||||
toku_brtnode_pe_callback(*dn, 0xffffffff, &bytes_freed, NULL);
|
||||
toku_brtnode_pe_callback(*dn, make_pair_attr(0xffffffff), &attr, NULL);
|
||||
for (int i = 0; i < (*dn)->n_children; i++) {
|
||||
// assert all bp's are still available, because we touched the clock
|
||||
assert(BP_STATE(*dn,i) == PT_AVAIL);
|
||||
// now assert all should be evicted
|
||||
assert(BP_SHOULD_EVICT(*dn, i));
|
||||
}
|
||||
toku_brtnode_pe_callback(*dn, 0xffffffff, &bytes_freed, NULL);
|
||||
toku_brtnode_pe_callback(*dn, make_pair_attr(0xffffffff), &attr, NULL);
|
||||
for (int i = 0; i < (*dn)->n_children; i++) {
|
||||
assert(BP_STATE(*dn,i) == PT_COMPRESSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
// now decompress them
|
||||
fill_bfe_for_full_read(&bfe, brt_h, NULL, string_key_cmp);
|
||||
fill_bfe_for_full_read(&bfe, brt_h);
|
||||
assert(toku_brtnode_pf_req_callback(*dn, &bfe));
|
||||
long size;
|
||||
r = toku_brtnode_pf_callback(*dn, &bfe, fd, &size);
|
||||
PAIR_ATTR attr;
|
||||
r = toku_brtnode_pf_callback(*dn, &bfe, fd, &attr);
|
||||
assert(r==0);
|
||||
// assert all bp's are available
|
||||
for (int i = 0; i < (*dn)->n_children; i++) {
|
||||
|
|
|
@ -12,7 +12,7 @@ static DB * const null_db = 0;
|
|||
|
||||
static int test_cursor_debug = 0;
|
||||
|
||||
static int test_brt_cursor_keycompare(DB *db __attribute__((unused)), const DBT *a, const DBT *b) {
|
||||
static int test_brt_cursor_keycompare(DB *desc __attribute__((unused)), const DBT *a, const DBT *b) {
|
||||
return toku_keycompare(a->data, a->size, b->data, b->size);
|
||||
}
|
||||
|
||||
|
|
|
@ -335,13 +335,13 @@ static void test_cursor_next (void) {
|
|||
|
||||
static DB nonce_db;
|
||||
|
||||
static int wrong_compare_fun(DB *db, const DBT *a, const DBT *b) {
|
||||
static int wrong_compare_fun(DB* UU(desc), const DBT *a, const DBT *b) {
|
||||
unsigned int i;
|
||||
unsigned char *ad=a->data;
|
||||
unsigned char *bd=b->data;
|
||||
unsigned int siz=a->size;
|
||||
assert(a->size==b->size);
|
||||
assert(db==&nonce_db); // make sure the db was passed down correctly
|
||||
//assert(db==&nonce_db); // make sure the db was passed down correctly
|
||||
for (i=0; i<siz; i++) {
|
||||
if (ad[siz-1-i]<bd[siz-1-i]) return -1;
|
||||
if (ad[siz-1-i]>bd[siz-1-i]) return +1;
|
||||
|
@ -363,8 +363,8 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
|||
char a[4]={0,1,0,0};
|
||||
char b[4]={1,0,0,0};
|
||||
DBT at, bt;
|
||||
assert(wrong_compare_fun(&nonce_db, toku_fill_dbt(&at, a, 4), toku_fill_dbt(&bt, b, 4))>0);
|
||||
assert(wrong_compare_fun(&nonce_db, toku_fill_dbt(&at, b, 4), toku_fill_dbt(&bt, a, 4))<0);
|
||||
assert(wrong_compare_fun(NULL, toku_fill_dbt(&at, a, 4), toku_fill_dbt(&bt, b, 4))>0);
|
||||
assert(wrong_compare_fun(NULL, toku_fill_dbt(&at, b, 4), toku_fill_dbt(&bt, a, 4))<0);
|
||||
}
|
||||
|
||||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||
|
@ -451,7 +451,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
|||
|
||||
}
|
||||
|
||||
static int test_brt_cursor_keycompare(DB *db __attribute__((unused)), const DBT *a, const DBT *b) {
|
||||
static int test_brt_cursor_keycompare(DB *desc __attribute__((unused)), const DBT *a, const DBT *b) {
|
||||
return toku_keycompare(a->data, a->size, b->data, b->size);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ static int qsort_compare_ints (const void *a, const void *b) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int compare_int(DB *dest_db, const DBT *akey, const DBT *bkey) {
|
||||
assert(dest_db == NULL);
|
||||
static int compare_int(DB *desc, const DBT *akey, const DBT *bkey) {
|
||||
assert(desc == NULL);
|
||||
assert(akey->size == sizeof (int));
|
||||
assert(bkey->size == sizeof (int));
|
||||
return qsort_compare_ints(akey->data, bkey->data);
|
||||
|
|
|
@ -45,8 +45,8 @@ static int qsort_compare_ints (const void *a, const void *b) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int compare_int(DB *dest_db, const DBT *akey, const DBT *bkey) {
|
||||
assert(dest_db == NULL);
|
||||
static int compare_int(DB *desc, const DBT *akey, const DBT *bkey) {
|
||||
assert(desc == NULL);
|
||||
assert(akey->size == sizeof (int));
|
||||
assert(bkey->size == sizeof (int));
|
||||
return qsort_compare_ints(akey->data, bkey->data);
|
||||
|
|
|
@ -28,8 +28,8 @@ static int qsort_compare_ints (const void *a, const void *b) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int compare_int(DB *dest_db, const DBT *akey, const DBT *bkey) {
|
||||
assert(dest_db == NULL);
|
||||
static int compare_int(DB *desc, const DBT *akey, const DBT *bkey) {
|
||||
assert(desc == NULL);
|
||||
assert(akey->size == sizeof (int));
|
||||
assert(bkey->size == sizeof (int));
|
||||
return qsort_compare_ints(akey->data, bkey->data);
|
||||
|
|
|
@ -221,8 +221,7 @@ static int qsort_compare_ints (const void *a, const void *b) {
|
|||
|
||||
}
|
||||
|
||||
static int compare_ints (DB *dest_db, const DBT *akey, const DBT *bkey) {
|
||||
assert(dest_db==NULL);
|
||||
static int compare_ints (DB* UU(desc), const DBT *akey, const DBT *bkey) {
|
||||
assert(akey->size==sizeof(int));
|
||||
assert(bkey->size==sizeof(int));
|
||||
return qsort_compare_ints(akey->data, bkey->data);
|
||||
|
|
|
@ -33,7 +33,7 @@ static void *my_malloc(size_t n) {
|
|||
return malloc(n);
|
||||
}
|
||||
|
||||
static int my_compare(DB *UU(db), const DBT *UU(akey), const DBT *UU(bkey)) {
|
||||
static int my_compare(DB *UU(desc), const DBT *UU(akey), const DBT *UU(bkey)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@ static int qsort_compare_ints (const void *a, const void *b) {
|
|||
|
||||
}
|
||||
|
||||
static int compare_ints (DB *dest_db, const DBT *akey, const DBT *bkey) {
|
||||
assert(dest_db==NULL);
|
||||
static int compare_ints (DB *UU(desc), const DBT *akey, const DBT *bkey) {
|
||||
assert(akey->size==sizeof(int));
|
||||
assert(bkey->size==sizeof(int));
|
||||
return qsort_compare_ints(akey->data, bkey->data);
|
||||
|
|
|
@ -27,8 +27,7 @@ static int qsort_compare_ints (const void *a, const void *b) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int compare_ints (DB *dest_db, const DBT *akey, const DBT *bkey) {
|
||||
assert(dest_db==NULL);
|
||||
static int compare_ints (DB *UU(desc), const DBT *akey, const DBT *bkey) {
|
||||
assert(akey->size==sizeof(int));
|
||||
assert(bkey->size==sizeof(int));
|
||||
return qsort_compare_ints(akey->data, bkey->data);
|
||||
|
|
|
@ -24,8 +24,7 @@ static int qsort_compare_ints (const void *a, const void *b) {
|
|||
|
||||
}
|
||||
|
||||
static int compare_ints (DB *dest_db, const DBT *akey, const DBT *bkey) {
|
||||
assert(dest_db==NULL);
|
||||
static int compare_ints (DB* UU(desc), const DBT *akey, const DBT *bkey) {
|
||||
assert(akey->size==sizeof(int));
|
||||
assert(bkey->size==sizeof(int));
|
||||
return qsort_compare_ints(akey->data, bkey->data);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -10,86 +10,32 @@ CACHETABLE ct;
|
|||
// freed memory was being accessed by toku_cachetable_unpin_and_remove
|
||||
//
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
CACHEFILE f1;
|
||||
|
||||
static void
|
||||
unlock_test_fun (void *v) {
|
||||
assert(v == NULL);
|
||||
// CT lock is held
|
||||
int r = toku_cachetable_unpin_ct_prelocked_no_flush(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 100);
|
||||
int r = toku_cachetable_unpin_ct_prelocked_no_flush(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert(r==0);
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
run_test (void) {
|
||||
const int test_limit = 20;
|
||||
|
@ -106,12 +52,12 @@ run_test (void) {
|
|||
long s1;
|
||||
long s2;
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8); assert(r==0);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 8); assert(r==0);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -122,12 +68,12 @@ run_test (void) {
|
|||
|
||||
|
||||
// pin 1 and 2
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v2, &s2, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_begin_checkpoint(ct, NULL);
|
||||
// mark nodes as pending a checkpoint, so that get_and_pin_nonblocking on block 1 will return TOKUDB_TRY_AGAIN
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8); assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
// now we try to pin 1, and it should get evicted out from under us
|
||||
struct unlockers foo;
|
||||
foo.extra = NULL;
|
||||
|
@ -140,12 +86,13 @@ run_test (void) {
|
|||
1,
|
||||
&v1,
|
||||
&s1,
|
||||
flush,
|
||||
def_flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
&foo
|
||||
|
|
|
@ -9,8 +9,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -22,55 +22,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 8;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
|
@ -86,14 +37,14 @@ cachetable_test (void) {
|
|||
void* v1;
|
||||
void* v2;
|
||||
long s1, s2;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
// usleep (2*1024*1024);
|
||||
//r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL);
|
||||
//r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, def_fetch, def_pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL);
|
||||
|
||||
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
//r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
|
||||
|
||||
|
|
|
@ -32,10 +32,21 @@ sleep_random (void)
|
|||
int expect_value = 42; // initially 42, later 43
|
||||
|
||||
static void
|
||||
flush (CACHEFILE UU(thiscf), int UU(fd), CACHEKEY UU(key), void *value, void *UU(extraargs), long size, long* UU(new_size), BOOL write_me, BOOL keep_me, BOOL UU(for_checkpoint))
|
||||
flush (
|
||||
CACHEFILE UU(thiscf),
|
||||
int UU(fd),
|
||||
CACHEKEY UU(key),
|
||||
void *value,
|
||||
void *UU(extraargs),
|
||||
PAIR_ATTR size,
|
||||
PAIR_ATTR* UU(new_size),
|
||||
BOOL write_me,
|
||||
BOOL keep_me,
|
||||
BOOL UU(for_checkpoint)
|
||||
)
|
||||
{
|
||||
// printf("f");
|
||||
assert(size == item_size);
|
||||
assert(size.size== item_size);
|
||||
int *v = value;
|
||||
if (*v!=expect_value) printf("got %d expect %d\n", *v, expect_value);
|
||||
assert(*v==expect_value);
|
||||
|
@ -46,44 +57,21 @@ flush (CACHEFILE UU(thiscf), int UU(fd), CACHEKEY UU(key), void *value, void *UU
|
|||
}
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE UU(thiscf), int UU(fd), CACHEKEY UU(key), u_int32_t UU(fullhash), void **UU(value), long *UU(sizep), int *UU(dirtyp), void *UU(extraargs))
|
||||
fetch (
|
||||
CACHEFILE UU(thiscf),
|
||||
int UU(fd),
|
||||
CACHEKEY UU(key),
|
||||
u_int32_t UU(fullhash),
|
||||
void **UU(value),
|
||||
PAIR_ATTR *UU(sizep),
|
||||
int *UU(dirtyp),
|
||||
void *UU(extraargs)
|
||||
)
|
||||
{
|
||||
assert(0); // should not be called
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
// placeholder for now
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void*
|
||||
do_update (void *UU(ignore))
|
||||
|
@ -95,7 +83,7 @@ do_update (void *UU(ignore))
|
|||
u_int32_t hi = toku_cachetable_hash(cf, key);
|
||||
void *vv;
|
||||
long size;
|
||||
int r = toku_cachetable_get_and_pin(cf, key, hi, &vv, &size, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0);
|
||||
int r = toku_cachetable_get_and_pin(cf, key, hi, &vv, &size, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
|
||||
//printf("g");
|
||||
assert(r==0);
|
||||
assert(size==sizeof(int));
|
||||
|
@ -103,7 +91,7 @@ do_update (void *UU(ignore))
|
|||
assert(*v==42);
|
||||
*v = 43;
|
||||
//printf("[%d]43\n", i);
|
||||
r = toku_cachetable_unpin(cf, key, hi, CACHETABLE_DIRTY, item_size);
|
||||
r = toku_cachetable_unpin(cf, key, hi, CACHETABLE_DIRTY, make_pair_attr(item_size));
|
||||
sleep_random();
|
||||
}
|
||||
return 0;
|
||||
|
@ -144,10 +132,10 @@ static void checkpoint_pending(void) {
|
|||
CACHEKEY key = make_blocknum(i);
|
||||
u_int32_t hi = toku_cachetable_hash(cf, key);
|
||||
values[i] = 42;
|
||||
r = toku_cachetable_put(cf, key, hi, &values[i], sizeof(int), flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(cf, key, hi, &values[i], make_pair_attr(sizeof(int)), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
|
||||
r = toku_cachetable_unpin(cf, key, hi, CACHETABLE_DIRTY, item_size);
|
||||
r = toku_cachetable_unpin(cf, key, hi, CACHETABLE_DIRTY, make_pair_attr(item_size));
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -15,8 +15,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -41,7 +41,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -52,49 +52,10 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
else {
|
||||
*value = &clean_val;
|
||||
}
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
const int test_limit = 20;
|
||||
|
@ -110,8 +71,8 @@ cachetable_test (void) {
|
|||
void* v2;
|
||||
long s1;
|
||||
long s2;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, &dirty_val, &dirty_val);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &dirty_val, &dirty_val);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
|
||||
//
|
||||
// Here is the test, we have two pairs, v1 is dirty, v2 is clean, but both are currently pinned
|
||||
|
@ -122,8 +83,8 @@ cachetable_test (void) {
|
|||
r = toku_cachetable_begin_checkpoint(ct, NULL); assert(r == 0);
|
||||
|
||||
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
check_me = TRUE;
|
||||
flush_called = FALSE;
|
||||
|
@ -138,8 +99,6 @@ cachetable_test (void) {
|
|||
assert(r==0);
|
||||
assert(flush_called);
|
||||
check_me = FALSE;
|
||||
|
||||
|
||||
|
||||
toku_cachetable_verify(ct);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -15,8 +15,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -41,7 +41,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -54,49 +54,10 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
*value = &clean_val;
|
||||
*dirtyp = FALSE;
|
||||
}
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
const int test_limit = 20;
|
||||
|
@ -109,10 +70,10 @@ cachetable_test (void) {
|
|||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
BOOL doing_prefetch = FALSE;
|
||||
r = toku_cachefile_prefetch(f1, make_blocknum(1), 1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, &dirty_val, &dirty_val, &doing_prefetch);
|
||||
r = toku_cachefile_prefetch(f1, make_blocknum(1), 1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &dirty_val, &dirty_val, &doing_prefetch);
|
||||
assert(doing_prefetch);
|
||||
doing_prefetch = FALSE;
|
||||
r = toku_cachefile_prefetch(f1, make_blocknum(2), 2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, &doing_prefetch);
|
||||
r = toku_cachefile_prefetch(f1, make_blocknum(2), 2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, &doing_prefetch);
|
||||
assert(doing_prefetch);
|
||||
|
||||
//
|
||||
|
|
|
@ -12,40 +12,15 @@ static const int item_size = 1;
|
|||
|
||||
static int n_flush, n_write_me, n_keep_me, n_fetch;
|
||||
|
||||
static void flush(CACHEFILE cf, int UU(fd), CACHEKEY key, void *value, void *extraargs, long size, long* UU(new_size), BOOL write_me, BOOL keep_me, BOOL UU(for_checkpoint)) {
|
||||
static void flush(CACHEFILE cf, int UU(fd), CACHEKEY key, void *value, void *extraargs, PAIR_ATTR size, PAIR_ATTR* UU(new_size), BOOL write_me, BOOL keep_me, BOOL UU(for_checkpoint)) {
|
||||
cf = cf; key = key; value = value; extraargs = extraargs;
|
||||
// assert(key == make_blocknum((long)value));
|
||||
assert(size == item_size);
|
||||
assert(size.size == item_size);
|
||||
n_flush++;
|
||||
if (write_me) n_write_me++;
|
||||
if (keep_me) n_keep_me++;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int callback_was_called = 0;
|
||||
static int callback2_was_called = 0;
|
||||
|
||||
|
@ -86,10 +61,10 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
|
|||
for (i=0; i<n; i++) {
|
||||
CACHEKEY key = make_blocknum(i);
|
||||
u_int32_t hi = toku_cachetable_hash(f1, key);
|
||||
r = toku_cachetable_put(f1, key, hi, (void *)(long)i, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, key, hi, (void *)(long)i, make_pair_attr(1), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
|
||||
r = toku_cachetable_unpin(f1, key, hi, dirty, item_size);
|
||||
r = toku_cachetable_unpin(f1, key, hi, dirty, make_pair_attr(item_size));
|
||||
assert(r == 0);
|
||||
|
||||
void *v;
|
||||
|
@ -122,7 +97,7 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
|
|||
r = toku_cachetable_maybe_get_and_pin(f1, key, hi, &v);
|
||||
if (r != 0)
|
||||
continue;
|
||||
r = toku_cachetable_unpin(f1, key, hi, CACHETABLE_CLEAN, item_size);
|
||||
r = toku_cachetable_unpin(f1, key, hi, CACHETABLE_CLEAN, make_pair_attr(item_size));
|
||||
assert(r == 0);
|
||||
|
||||
int its_dirty;
|
||||
|
|
135
newbrt/tests/cachetable-cleaner-thread-attrs-accumulate.c
Normal file
135
newbrt/tests/cachetable-cleaner-thread-attrs-accumulate.c
Normal file
|
@ -0,0 +1,135 @@
|
|||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
//
|
||||
// This test verifies that the cleaner thread doesn't call the callback if
|
||||
// nothing needs flushing.
|
||||
//
|
||||
|
||||
toku_pthread_mutex_t attr_mutex;
|
||||
|
||||
|
||||
const PAIR_ATTR attrs[] = {
|
||||
{ .size = 20, .nonleaf_size = 13, .leaf_size = 900, .rollback_size = 123, .cache_pressure_size = 403 },
|
||||
{ .size = 21, .nonleaf_size = 16, .leaf_size = 910, .rollback_size = 113, .cache_pressure_size = 401 },
|
||||
{ .size = 22, .nonleaf_size = 17, .leaf_size = 940, .rollback_size = 133, .cache_pressure_size = 402 },
|
||||
{ .size = 23, .nonleaf_size = 18, .leaf_size = 931, .rollback_size = 153, .cache_pressure_size = 404 },
|
||||
{ .size = 25, .nonleaf_size = 19, .leaf_size = 903, .rollback_size = 173, .cache_pressure_size = 413 },
|
||||
{ .size = 26, .nonleaf_size = 10, .leaf_size = 903, .rollback_size = 193, .cache_pressure_size = 423 },
|
||||
{ .size = 20, .nonleaf_size = 11, .leaf_size = 902, .rollback_size = 103, .cache_pressure_size = 433 },
|
||||
{ .size = 29, .nonleaf_size = 12, .leaf_size = 909, .rollback_size = 113, .cache_pressure_size = 443 }
|
||||
};
|
||||
const int n_pairs = (sizeof attrs) / (sizeof attrs[0]);
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
PAIR_ATTR *expect = e;
|
||||
if (!keep) {
|
||||
int r = toku_pthread_mutex_lock(&attr_mutex); // purpose is to make this function single-threaded
|
||||
resource_assert_zero(r);
|
||||
expect->size -= s.size;
|
||||
expect->nonleaf_size -= s.nonleaf_size;
|
||||
expect->leaf_size -= s.leaf_size;
|
||||
expect->rollback_size -= s.rollback_size;
|
||||
expect->cache_pressure_size -= s.cache_pressure_size;
|
||||
r = toku_pthread_mutex_unlock(&attr_mutex);
|
||||
resource_assert_zero(r);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
run_test (void) {
|
||||
const int test_limit = 1000;
|
||||
int r;
|
||||
CACHETABLE ct;
|
||||
r = toku_pthread_mutex_init(&attr_mutex, NULL); resource_assert_zero(r);
|
||||
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
|
||||
|
||||
char fname1[] = __FILE__ "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);
|
||||
|
||||
CACHETABLE_STATUS_S ct_stat;
|
||||
toku_cachetable_get_status(ct, &ct_stat);
|
||||
assert(ct_stat.size_nonleaf == 0);
|
||||
assert(ct_stat.size_leaf == 0);
|
||||
assert(ct_stat.size_rollback == 0);
|
||||
assert(ct_stat.size_cachepressure == 0);
|
||||
|
||||
void* vs[n_pairs];
|
||||
//void* v2;
|
||||
long ss[n_pairs];
|
||||
//long s2;
|
||||
PAIR_ATTR expect = { .size = 0, .nonleaf_size = 0, .leaf_size = 0, .rollback_size = 0, .cache_pressure_size = 0 };
|
||||
for (int i = 0; i < n_pairs; ++i) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
|
||||
flush,
|
||||
def_fetch,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
NULL, &expect);
|
||||
assert_zero(r);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i+1), i+1, CACHETABLE_DIRTY, attrs[i]);
|
||||
assert_zero(r);
|
||||
expect.size += attrs[i].size;
|
||||
expect.nonleaf_size += attrs[i].nonleaf_size;
|
||||
expect.leaf_size += attrs[i].leaf_size;
|
||||
expect.rollback_size += attrs[i].rollback_size;
|
||||
expect.cache_pressure_size += attrs[i].cache_pressure_size;
|
||||
}
|
||||
|
||||
toku_cachetable_get_status(ct, &ct_stat);
|
||||
assert(ct_stat.size_nonleaf == expect.nonleaf_size);
|
||||
assert(ct_stat.size_leaf == expect.leaf_size);
|
||||
assert(ct_stat.size_rollback == expect.rollback_size);
|
||||
assert(ct_stat.size_cachepressure == expect.cache_pressure_size);
|
||||
|
||||
void *big_v;
|
||||
long big_s;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(n_pairs + 1), n_pairs + 1, &big_v, &big_s,
|
||||
flush,
|
||||
def_fetch,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
NULL, &expect);
|
||||
toku_cachetable_unpin(f1, make_blocknum(n_pairs + 1), n_pairs + 1, CACHETABLE_CLEAN,
|
||||
make_pair_attr(test_limit - expect.size + 20));
|
||||
|
||||
usleep(2*1024*1024);
|
||||
|
||||
toku_cachetable_get_status(ct, &ct_stat);
|
||||
assert(ct_stat.size_nonleaf == expect.nonleaf_size);
|
||||
assert(ct_stat.size_leaf == expect.leaf_size);
|
||||
assert(ct_stat.size_rollback == expect.rollback_size);
|
||||
assert(ct_stat.size_cachepressure == expect.cache_pressure_size);
|
||||
|
||||
toku_cachetable_verify(ct);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
|
||||
}
|
||||
|
||||
int
|
||||
test_main(int argc, const char *argv[]) {
|
||||
default_parse_args(argc, argv);
|
||||
run_test();
|
||||
return 0;
|
||||
}
|
46
newbrt/tests/cachetable-cleaner-thread-empty-cachetable.c
Normal file
46
newbrt/tests/cachetable-cleaner-thread-empty-cachetable.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
//
|
||||
// simple tests for cleaner thread with an empty cachetable
|
||||
//
|
||||
|
||||
static void
|
||||
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);
|
||||
|
||||
char fname1[] = __FILE__ "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);
|
||||
|
||||
usleep(4000000);
|
||||
|
||||
r = toku_cachetable_begin_checkpoint(ct, NULL); assert(r == 0);
|
||||
r = toku_cachetable_end_checkpoint(
|
||||
ct,
|
||||
NULL,
|
||||
fake_ydb_lock,
|
||||
fake_ydb_unlock,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
assert(r==0);
|
||||
|
||||
toku_cachetable_verify(ct);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
|
||||
}
|
||||
|
||||
int
|
||||
test_main(int argc, const char *argv[]) {
|
||||
default_parse_args(argc, argv);
|
||||
cachetable_test();
|
||||
return 0;
|
||||
}
|
72
newbrt/tests/cachetable-cleaner-thread-everything-pinned.c
Normal file
72
newbrt/tests/cachetable-cleaner-thread-everything-pinned.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
//
|
||||
// This test verifies that the cleaner thread doesn't call the callback if
|
||||
// everything is pinned.
|
||||
//
|
||||
|
||||
static UU() int
|
||||
everything_pinned_cleaner_callback(
|
||||
void* UU(brtnode_pv),
|
||||
BLOCKNUM UU(blocknum),
|
||||
u_int32_t UU(fullhash),
|
||||
void* UU(extraargs)
|
||||
)
|
||||
{
|
||||
assert(FALSE); // everything is pinned so this should never be called
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
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);
|
||||
|
||||
char fname1[] = __FILE__ "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);
|
||||
assert(r==0);
|
||||
|
||||
void* vs[8];
|
||||
//void* v2;
|
||||
long ss[8];
|
||||
//long s2;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
|
||||
def_flush,
|
||||
def_fetch,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
everything_pinned_cleaner_callback,
|
||||
NULL, NULL);
|
||||
assert_zero(r);
|
||||
}
|
||||
|
||||
usleep(4000000);
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i+1), i+1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert_zero(r);
|
||||
}
|
||||
|
||||
toku_cachetable_verify(ct);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
|
||||
}
|
||||
|
||||
int
|
||||
test_main(int argc, const char *argv[]) {
|
||||
default_parse_args(argc, argv);
|
||||
run_test();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
//
|
||||
// This test verifies that the cleaner thread doesn't call the callback if
|
||||
// nothing needs flushing.
|
||||
//
|
||||
|
||||
static UU() int
|
||||
everything_pinned_cleaner_callback(
|
||||
void* UU(brtnode_pv),
|
||||
BLOCKNUM UU(blocknum),
|
||||
u_int32_t UU(fullhash),
|
||||
void* UU(extraargs)
|
||||
)
|
||||
{
|
||||
assert(FALSE); // everything is pinned so this should never be called
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
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);
|
||||
|
||||
char fname1[] = __FILE__ "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);
|
||||
|
||||
void* vs[8];
|
||||
//void* v2;
|
||||
long ss[8];
|
||||
//long s2;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
|
||||
def_flush,
|
||||
def_fetch,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
everything_pinned_cleaner_callback,
|
||||
NULL, NULL);
|
||||
assert_zero(r);
|
||||
// set cachepressure_size to 0
|
||||
PAIR_ATTR attr = make_pair_attr(8);
|
||||
attr.cache_pressure_size = 0;
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i+1), i+1, CACHETABLE_CLEAN, attr);
|
||||
assert_zero(r);
|
||||
}
|
||||
|
||||
usleep(4000000);
|
||||
|
||||
toku_cachetable_verify(ct);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
|
||||
}
|
||||
|
||||
int
|
||||
test_main(int argc, const char *argv[]) {
|
||||
default_parse_args(argc, argv);
|
||||
run_test();
|
||||
return 0;
|
||||
}
|
92
newbrt/tests/cachetable-cleaner-thread-simple.c
Normal file
92
newbrt/tests/cachetable-cleaner-thread-simple.c
Normal file
|
@ -0,0 +1,92 @@
|
|||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
//
|
||||
// This test verifies that the cleaner thread doesn't call the callback if
|
||||
// nothing needs flushing.
|
||||
//
|
||||
|
||||
CACHEFILE f1;
|
||||
bool my_cleaner_callback_called;
|
||||
|
||||
static UU() int
|
||||
my_cleaner_callback(
|
||||
void* UU(brtnode_pv),
|
||||
BLOCKNUM UU(blocknum),
|
||||
u_int32_t UU(fullhash),
|
||||
void* UU(extraargs)
|
||||
)
|
||||
{
|
||||
assert(blocknum.b == 100); // everything is pinned so this should never be called
|
||||
assert(fullhash == 100);
|
||||
PAIR_ATTR attr = make_pair_attr(8);
|
||||
attr.cache_pressure_size = 100;
|
||||
int r = toku_cachetable_unpin(f1, make_blocknum(100), 100, CACHETABLE_CLEAN, attr);
|
||||
my_cleaner_callback_called = true;
|
||||
return r;
|
||||
}
|
||||
|
||||
static void
|
||||
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);
|
||||
my_cleaner_callback_called = FALSE;
|
||||
|
||||
char fname1[] = __FILE__ "test1.dat";
|
||||
unlink(fname1);
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* vs[5];
|
||||
//void* v2;
|
||||
long ss[5];
|
||||
//long s2;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(100), 100, &vs[4], &ss[4],
|
||||
def_flush,
|
||||
def_fetch,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
my_cleaner_callback,
|
||||
NULL, NULL);
|
||||
PAIR_ATTR attr = make_pair_attr(8);
|
||||
attr.cache_pressure_size = 100;
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(100), 100, CACHETABLE_CLEAN, attr);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
|
||||
def_flush,
|
||||
def_fetch,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
NULL, NULL);
|
||||
assert_zero(r);
|
||||
// set cachepressure_size to 0
|
||||
attr = make_pair_attr(8);
|
||||
attr.cache_pressure_size = 0;
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i+1), i+1, CACHETABLE_CLEAN, attr);
|
||||
assert_zero(r);
|
||||
}
|
||||
|
||||
usleep(4000000);
|
||||
assert(my_cleaner_callback_called);
|
||||
|
||||
toku_cachetable_verify(ct);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
|
||||
}
|
||||
|
||||
int
|
||||
test_main(int argc, const char *argv[]) {
|
||||
default_parse_args(argc, argv);
|
||||
run_test();
|
||||
return 0;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-clock-eviction.c 32940 2011-07-11 18:24:15Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -11,64 +11,15 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 1;
|
||||
*value = NULL;
|
||||
*sizep = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
|
@ -83,18 +34,18 @@ cachetable_test (void) {
|
|||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
// test that putting something too big in the cachetable works fine
|
||||
r = toku_cachetable_put(f1, make_blocknum(num_entries+1), num_entries+1, NULL, test_limit*2, flush, pe_est_callback, pe_callback, NULL);
|
||||
r = toku_cachetable_put(f1, make_blocknum(num_entries+1), num_entries+1, NULL, make_pair_attr(test_limit*2), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, NULL);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(num_entries+1), num_entries+1, CACHETABLE_DIRTY, test_limit*2);
|
||||
r = toku_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, 1, flush, pe_est_callback, pe_callback, NULL);
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), i, NULL, make_pair_attr(1), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, NULL);
|
||||
assert(toku_cachefile_count_pinned(f1, 0) == (i+1));
|
||||
}
|
||||
for (int64_t i = 0; i < num_entries; i++) {
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), i, CACHETABLE_DIRTY, 1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), i, CACHETABLE_DIRTY, make_pair_attr(1));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -36,49 +36,16 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 1;
|
||||
*sizep = make_pair_attr(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
const int test_limit = 4;
|
||||
|
@ -97,27 +64,27 @@ cachetable_test (void) {
|
|||
flush_may_occur = FALSE;
|
||||
check_flush = TRUE;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
flush_may_occur = TRUE;
|
||||
expected_flushed_key = 4;
|
||||
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, 4, flush, pe_est_callback, pe_callback, NULL);
|
||||
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, NULL);
|
||||
flush_may_occur = TRUE;
|
||||
expected_flushed_key = 5;
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
|
||||
check_flush = FALSE;
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
|
|
|
@ -11,8 +11,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v,
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep,
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -31,14 +31,14 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
int* foo = toku_malloc(sizeof(int));
|
||||
*value = foo;
|
||||
*sizep = 4;
|
||||
*sizep = make_pair_attr(4);
|
||||
*foo = 4;
|
||||
return 0;
|
||||
}
|
||||
|
@ -49,35 +49,23 @@ other_flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv,
|
||||
long UU(bytes_to_free),
|
||||
long* bytes_freed,
|
||||
PAIR_ATTR UU(bytes_to_free),
|
||||
PAIR_ATTR* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free-1;
|
||||
*bytes_freed = make_pair_attr(bytes_to_free.size-1);
|
||||
expected_bytes_to_free--;
|
||||
int* foo = brtnode_pv;
|
||||
int blah = *foo;
|
||||
|
@ -88,21 +76,13 @@ pe_callback (
|
|||
static int
|
||||
other_pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed __attribute__((__unused__)),
|
||||
PAIR_ATTR bytes_to_free __attribute__((__unused__)),
|
||||
PAIR_ATTR* bytes_freed __attribute__((__unused__)),
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
|
@ -120,26 +100,26 @@ cachetable_test (void) {
|
|||
long s1, s2;
|
||||
flush_may_occur = FALSE;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, def_pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, def_pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
flush_may_occur = FALSE;
|
||||
expected_bytes_to_free = 4;
|
||||
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, 4, other_flush, pe_est_callback, other_pe_callback, NULL);
|
||||
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), other_flush, def_pe_est_callback, other_pe_callback, def_cleaner_callback, NULL);
|
||||
flush_may_occur = TRUE;
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
assert(expected_bytes_to_free == 0);
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-clock-eviction2.c 34104 2011-08-22 01:17:04Z zardosht $"
|
||||
#ident "$Id$"
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
|
@ -11,8 +11,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void* UU(v),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep,
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -31,14 +31,14 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
int* foo = toku_malloc(sizeof(int));
|
||||
*value = foo;
|
||||
*sizep = 4;
|
||||
*sizep = make_pair_attr(4);
|
||||
*foo = 4;
|
||||
return 0;
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ other_flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -72,12 +72,12 @@ pe_est_callback(
|
|||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv,
|
||||
long UU(bytes_to_free),
|
||||
long* bytes_freed,
|
||||
PAIR_ATTR UU(bytes_to_free),
|
||||
PAIR_ATTR* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free-1;
|
||||
*bytes_freed = make_pair_attr(bytes_to_free.size-1);
|
||||
printf("calling pe_callback\n");
|
||||
expected_bytes_to_free--;
|
||||
int* foo = brtnode_pv;
|
||||
|
@ -89,22 +89,14 @@ pe_callback (
|
|||
static int
|
||||
other_pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed __attribute__((__unused__)),
|
||||
PAIR_ATTR bytes_to_free __attribute__((__unused__)),
|
||||
PAIR_ATTR* bytes_freed __attribute__((__unused__)),
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
|
@ -122,26 +114,26 @@ cachetable_test (void) {
|
|||
long s1, s2;
|
||||
flush_may_occur = FALSE;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
flush_may_occur = FALSE;
|
||||
expected_bytes_to_free = 4;
|
||||
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, 4, other_flush, pe_est_callback, other_pe_callback, NULL);
|
||||
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), other_flush, pe_est_callback, other_pe_callback, def_cleaner_callback, NULL);
|
||||
flush_may_occur = TRUE;
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
// we are testing that having a wildly different estimate than
|
||||
// what actually gets freed is ok
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-clock-eviction.c 34099 2011-08-21 19:35:34Z zardosht $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -24,8 +24,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -46,13 +46,13 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 1;
|
||||
*sizep = make_pair_attr(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,8 @@ pe_est_callback(
|
|||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
PAIR_ATTR bytes_to_free __attribute__((__unused__)),
|
||||
PAIR_ATTR* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
|
@ -81,14 +81,6 @@ pe_callback (
|
|||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
|
@ -108,27 +100,27 @@ cachetable_test (void) {
|
|||
flush_may_occur = FALSE;
|
||||
check_flush = TRUE;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
flush_may_occur = TRUE;
|
||||
expected_flushed_key = 4;
|
||||
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, 4, flush, pe_est_callback, pe_callback, NULL);
|
||||
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), flush, pe_est_callback, pe_callback, def_cleaner_callback, NULL);
|
||||
flush_may_occur = TRUE;
|
||||
expected_flushed_key = 5;
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, 4);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
|
||||
check_flush = FALSE;
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
|
|
|
@ -2,45 +2,6 @@
|
|||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_count_pinned_test (int n) {
|
||||
|
@ -57,7 +18,7 @@ cachetable_count_pinned_test (int n) {
|
|||
for (i=1; i<=n; i++) {
|
||||
u_int32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
assert(toku_cachefile_count_pinned(f1, 0) == i);
|
||||
|
||||
|
@ -73,7 +34,7 @@ cachetable_count_pinned_test (int n) {
|
|||
for (i=n; i>0; i--) {
|
||||
u_int32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
if (i-1) assert(toku_cachetable_assert_all_unpinned(ct));
|
||||
assert(toku_cachefile_count_pinned(f1, 0) == i-1);
|
||||
|
|
|
@ -2,46 +2,6 @@
|
|||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_debug_test (int n) {
|
||||
const int test_limit = n;
|
||||
|
@ -65,7 +25,7 @@ cachetable_debug_test (int n) {
|
|||
const int item_size = 1;
|
||||
u_int32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, item_size, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(item_size), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
|
||||
void *v; int dirty; long long pinned; long pair_size;
|
||||
|
@ -76,7 +36,7 @@ cachetable_debug_test (int n) {
|
|||
assert(pinned == 1);
|
||||
assert(pair_size == item_size);
|
||||
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
|
||||
toku_cachetable_get_state(ct, &num_entries, &hash_size, &size_current, &size_limit, &size_max);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- mode: C; c-basic-offset: 4 -*- */
|
||||
|
||||
// verify that closing the cachetable with prefetches in progress works
|
||||
#ident "$Id: cachetable-prefetch-close-test.c 34904 2011-09-20 14:46:20Z zardosht $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -16,8 +16,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -26,22 +26,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
sleep(2);
|
||||
}
|
||||
|
||||
static void
|
||||
other_flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int fetch_calls = 0;
|
||||
|
||||
static int
|
||||
|
@ -50,7 +34,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -58,7 +42,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
fetch_calls++;
|
||||
|
||||
*value = 0;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
*dirtyp = 0;
|
||||
|
||||
return 0;
|
||||
|
@ -76,28 +60,6 @@ pe_est_callback(
|
|||
*cost = PE_EXPENSIVE;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void cachetable_eviction_full_test (void) {
|
||||
const int test_limit = 12;
|
||||
int r;
|
||||
|
@ -129,14 +91,15 @@ static void cachetable_eviction_full_test (void) {
|
|||
flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_DIRTY, 1);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_DIRTY, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
}
|
||||
expect_full_flush = TRUE;
|
||||
|
@ -147,17 +110,18 @@ static void cachetable_eviction_full_test (void) {
|
|||
1,
|
||||
&value2,
|
||||
&size2,
|
||||
other_flush,
|
||||
def_flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- mode: C; c-basic-offset: 4 -*- */
|
||||
|
||||
// verify that closing the cachetable with prefetches in progress works
|
||||
#ident "$Id: cachetable-prefetch-close-test.c 34904 2011-09-20 14:46:20Z zardosht $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -16,8 +16,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -25,22 +25,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
assert(expect_full_flush);
|
||||
}
|
||||
|
||||
static void
|
||||
other_flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int fetch_calls = 0;
|
||||
|
||||
static int
|
||||
|
@ -49,7 +33,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -57,7 +41,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
fetch_calls++;
|
||||
|
||||
*value = 0;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
*dirtyp = 0;
|
||||
|
||||
return 0;
|
||||
|
@ -78,26 +62,16 @@ pe_est_callback(
|
|||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
PAIR_ATTR bytes_to_free __attribute__((__unused__)),
|
||||
PAIR_ATTR* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free-7;
|
||||
*bytes_freed = make_pair_attr(bytes_to_free.size-7);
|
||||
sleep(2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void cachetable_eviction_full_test (void) {
|
||||
const int test_limit = 12;
|
||||
int r;
|
||||
|
@ -130,13 +104,14 @@ static void cachetable_eviction_full_test (void) {
|
|||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
assert(r == 0);
|
||||
}
|
||||
expect_full_flush = TRUE;
|
||||
|
@ -147,17 +122,18 @@ static void cachetable_eviction_full_test (void) {
|
|||
1,
|
||||
&value2,
|
||||
&size2,
|
||||
other_flush,
|
||||
def_flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- mode: C; c-basic-offset: 4 -*- */
|
||||
|
||||
/* verify that get_and_pin waits while a prefetch block is pending */
|
||||
#ident "$Id: cachetable-prefetch-getandpin-test.c 34156 2011-08-24 21:22:59Z zardosht $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -14,8 +14,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -25,79 +25,13 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
other_flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
||||
*value = 0;
|
||||
*sizep = 8;
|
||||
*dirtyp = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint64_t tdelta_usec(struct timeval *tend, struct timeval *tstart) {
|
||||
uint64_t t = tend->tv_sec * 1000000 + tend->tv_usec;
|
||||
t -= tstart->tv_sec * 1000000 + tstart->tv_usec;
|
||||
return t;
|
||||
}
|
||||
|
||||
static void cachetable_prefetch_maybegetandpin_test (void) {
|
||||
static void cachetable_predef_fetch_maybegetandpin_test (void) {
|
||||
const int test_limit = 12;
|
||||
int r;
|
||||
CACHETABLE ct;
|
||||
|
@ -120,22 +54,23 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
&value,
|
||||
&size,
|
||||
flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_fetch,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
}
|
||||
|
||||
struct timeval tstart;
|
||||
gettimeofday(&tstart, NULL);
|
||||
|
||||
// fetch another block, causing an eviction of the first block we made above
|
||||
// def_fetch another block, causing an eviction of the first block we made above
|
||||
do_sleep = TRUE;
|
||||
void* value2;
|
||||
long size2;
|
||||
|
@ -145,26 +80,27 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
1,
|
||||
&value2,
|
||||
&size2,
|
||||
other_flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_flush,
|
||||
def_fetch,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
void *v = 0;
|
||||
long size = 0;
|
||||
// now verify that the block we are trying to evict may be pinned
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
|
||||
assert(r == TOKUDB_TRY_AGAIN);
|
||||
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
assert(r == 0 && v == 0 && size == 8);
|
||||
do_sleep = FALSE;
|
||||
|
||||
|
@ -175,7 +111,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
if (verbose)printf("time %"PRIu64" \n", tdelta_usec(&tend, &tstart));
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
|
@ -186,6 +122,6 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
int
|
||||
test_main(int argc, const char *argv[]) {
|
||||
default_parse_args(argc, argv);
|
||||
cachetable_prefetch_maybegetandpin_test();
|
||||
cachetable_predef_fetch_maybegetandpin_test();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,59 +1,12 @@
|
|||
/* -*- mode: C; c-basic-offset: 4 -*- */
|
||||
|
||||
/* verify that get_and_pin waits while a prefetch block is pending */
|
||||
#ident "$Id: cachetable-prefetch-getandpin-test.c 34156 2011-08-24 21:22:59Z zardosht $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
static void
|
||||
other_flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
||||
*value = 0;
|
||||
*sizep = 8;
|
||||
*dirtyp = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
|
@ -69,22 +22,13 @@ pe_est_callback(
|
|||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
PAIR_ATTR bytes_to_free __attribute__((__unused__)),
|
||||
PAIR_ATTR* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
sleep(2);
|
||||
*bytes_freed = bytes_to_free-7;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
*bytes_freed = make_pair_attr(bytes_to_free.size-7);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -116,17 +60,18 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
fullhash,
|
||||
&value,
|
||||
&size,
|
||||
flush,
|
||||
fetch,
|
||||
def_flush,
|
||||
def_fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
}
|
||||
|
||||
struct timeval tstart;
|
||||
|
@ -141,26 +86,58 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
1,
|
||||
&value2,
|
||||
&size2,
|
||||
other_flush,
|
||||
fetch,
|
||||
def_flush,
|
||||
def_fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
void *v = 0;
|
||||
long size = 0;
|
||||
// now verify that the block we are trying to evict may be pinned
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(
|
||||
f1,
|
||||
key,
|
||||
fullhash,
|
||||
&v,
|
||||
&size,
|
||||
def_flush,
|
||||
def_fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
assert(r==TOKUDB_TRY_AGAIN);
|
||||
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(
|
||||
f1,
|
||||
key,
|
||||
fullhash,
|
||||
&v,
|
||||
&size,
|
||||
def_flush,
|
||||
def_fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
assert(r == 0 && v == 0 && size == 1);
|
||||
|
||||
struct timeval tend;
|
||||
|
@ -170,7 +147,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
if (verbose) printf("time %"PRIu64" \n", tdelta_usec(&tend, &tstart));
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
|
|
91
newbrt/tests/cachetable-flush-during-cleaner.c
Normal file
91
newbrt/tests/cachetable-flush-during-cleaner.c
Normal file
|
@ -0,0 +1,91 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 36579 2011-11-04 20:02:04Z zardosht $"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
CACHEFILE f1;
|
||||
|
||||
static int
|
||||
cleaner_callback(
|
||||
void* UU(brtnode_pv),
|
||||
BLOCKNUM blocknum,
|
||||
u_int32_t fullhash,
|
||||
void* UU(extraargs)
|
||||
)
|
||||
{
|
||||
int r = toku_cachetable_unpin(f1,blocknum, fullhash,CACHETABLE_CLEAN,make_pair_attr(8));
|
||||
assert(r==0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
/* Do nothing */
|
||||
if (verbose) { printf("FLUSH: %d\n", (int)k.b); }
|
||||
}
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
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);
|
||||
|
||||
char fname1[] = __FILE__ "test1.dat";
|
||||
unlink(fname1);
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
//void* v2;
|
||||
long s1;
|
||||
//long s2;
|
||||
for (int j = 0; j < 50000; j++) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), i, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), i, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
}
|
||||
r = toku_cachefile_flush(f1);
|
||||
assert(r == 0);
|
||||
}
|
||||
toku_cachetable_verify(ct);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
|
||||
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
test_main(int argc, const char *argv[]) {
|
||||
default_parse_args(argc, argv);
|
||||
cachetable_test();
|
||||
return 0;
|
||||
}
|
|
@ -3,46 +3,7 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
test_cachetable_flush (int n) {
|
||||
test_cachetable_def_flush (int n) {
|
||||
const int test_limit = 2*n;
|
||||
int r;
|
||||
CACHETABLE ct;
|
||||
|
@ -62,14 +23,14 @@ test_cachetable_flush (int n) {
|
|||
for (i=0; i<n; i++) {
|
||||
u_int32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, 1);
|
||||
r = toku_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, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f2, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
r = toku_cachetable_unpin(f2, make_blocknum(i), hi, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f2, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
}
|
||||
toku_cachetable_verify(ct);
|
||||
|
@ -81,16 +42,16 @@ test_cachetable_flush (int n) {
|
|||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
r = toku_cachetable_maybe_get_and_pin(f1, make_blocknum(i), hi, &v);
|
||||
assert(r == 0 && v == (void *)(long)i);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, 1);
|
||||
r = toku_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_maybe_get_and_pin(f2, make_blocknum(i), hi, &v);
|
||||
assert(r == 0 && v == (void *)(long)i);
|
||||
r = toku_cachetable_unpin(f2, make_blocknum(i), hi, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f2, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
// flush
|
||||
// def_flush
|
||||
r = toku_cachefile_flush(f1); assert(r == 0);
|
||||
toku_cachefile_verify(f1);
|
||||
|
||||
|
@ -104,7 +65,7 @@ test_cachetable_flush (int n) {
|
|||
hi = toku_cachetable_hash(f2, make_blocknum(i));
|
||||
r = toku_cachetable_maybe_get_and_pin(f2, make_blocknum(i), hi, &v);
|
||||
assert(r == 0);
|
||||
r = toku_cachetable_unpin(f2, make_blocknum(i), hi, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f2, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
|
@ -116,6 +77,6 @@ test_cachetable_flush (int n) {
|
|||
int
|
||||
test_main(int argc, const char *argv[]) {
|
||||
default_parse_args(argc, argv);
|
||||
test_cachetable_flush(8);
|
||||
test_cachetable_def_flush(8);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8,21 +8,31 @@ flush (CACHEFILE cf __attribute__((__unused__)),
|
|||
CACHEKEY key __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__)),
|
||||
long size __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR size __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL write_me __attribute__((__unused__)),
|
||||
BOOL keep_me __attribute__((__unused__)),
|
||||
BOOL for_checkpoint __attribute__((__unused__))
|
||||
) {
|
||||
assert((long) key.b == size);
|
||||
assert((long) key.b == size.size);
|
||||
if (!keep_me) toku_free(v);
|
||||
}
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE cf, int UU(fd), CACHEKEY key, u_int32_t hash, void **vptr, long *sizep, int *dirtyp, void *extra) {
|
||||
fetch (
|
||||
CACHEFILE cf,
|
||||
int UU(fd),
|
||||
CACHEKEY key,
|
||||
u_int32_t hash,
|
||||
void **vptr,
|
||||
PAIR_ATTR *sizep,
|
||||
int *dirtyp,
|
||||
void *extra
|
||||
)
|
||||
{
|
||||
cf = cf; hash = hash; extra = extra;
|
||||
*sizep = (long) key.b;
|
||||
*vptr = toku_malloc(*sizep);
|
||||
*sizep = make_pair_attr((long) key.b);
|
||||
*vptr = toku_malloc(sizep->size);
|
||||
*dirtyp = 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -42,22 +52,14 @@ pe_est_callback(
|
|||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
PAIR_ATTR bytes_to_free __attribute__((__unused__)),
|
||||
PAIR_ATTR* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_getandpin_test (int n) {
|
||||
|
@ -77,11 +79,11 @@ cachetable_getandpin_test (int n) {
|
|||
u_int32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
void *v; long size;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), hi, &v, &size, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), hi, &v, &size, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
|
||||
assert(r == 0);
|
||||
assert(size == i);
|
||||
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, i);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(i));
|
||||
assert(r == 0);
|
||||
}
|
||||
toku_cachetable_verify(ct);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -8,79 +8,14 @@ BOOL foo;
|
|||
//
|
||||
// This test verifies that flushing a cachefile will wait on kibbutzes to finish
|
||||
//
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
/* Do nothing */
|
||||
if (verbose) { printf("FLUSH: %d\n", (int)k.b); }
|
||||
}
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 8;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void kibbutz_work(void *fe_v)
|
||||
{
|
||||
CACHEFILE f1 = fe_v;
|
||||
sleep(2);
|
||||
foo = TRUE;
|
||||
int r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
int r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert(r==0);
|
||||
notify_cachefile_that_kibbutz_job_finishing(f1);
|
||||
remove_background_job(f1, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,14 +34,14 @@ run_test (void) {
|
|||
//void* v2;
|
||||
long s1;
|
||||
//long s2;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, def_flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
foo = FALSE;
|
||||
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
|
||||
r = toku_cachefile_flush(f1); assert(r == 0);
|
||||
assert(foo);
|
||||
assert(f1);
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, def_flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
foo = FALSE;
|
||||
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -17,8 +17,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -33,13 +33,13 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = &fetch_val;
|
||||
*sizep = sizeof(fetch_val);
|
||||
*sizep = make_pair_attr(sizeof(fetch_val));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ err_fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -58,32 +58,6 @@ err_fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -92,17 +66,17 @@ static BOOL true_pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs))
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int err_pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
static int err_pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), PAIR_ATTR* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), PAIR_ATTR* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static int true_pf_callback(void* UU(brtnode_pv), void* read_extraargs, int UU(fd), long* sizep) {
|
||||
static int true_pf_callback(void* UU(brtnode_pv), void* read_extraargs, int UU(fd), PAIR_ATTR* sizep) {
|
||||
pf_req_called = TRUE;
|
||||
*sizep = sizeof(fetch_val)+1;
|
||||
*sizep = make_pair_attr(sizeof(fetch_val)+1);
|
||||
assert(read_extraargs == &fetch_val);
|
||||
return 0;
|
||||
}
|
||||
|
@ -124,7 +98,7 @@ cachetable_test (void) {
|
|||
//void* v2;
|
||||
long s1;
|
||||
//long s2;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
assert(&fetch_val == v1);
|
||||
//
|
||||
// verify that a prefetch of this node will fail
|
||||
|
@ -135,10 +109,11 @@ cachetable_test (void) {
|
|||
1,
|
||||
flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_cleaner_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
&doing_prefetch
|
||||
|
@ -146,21 +121,21 @@ cachetable_test (void) {
|
|||
assert(r == 0);
|
||||
// make sure that prefetch should not happen, because we have already pinned node
|
||||
assert(!doing_prefetch);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
//
|
||||
// now get and pin node again, and make sure that partial fetch and fetch are not called
|
||||
//
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, pe_est_callback, pe_callback, pf_req_callback, err_pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, err_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
//
|
||||
// now make sure that if we say a partial fetch is required, that we get a partial fetch
|
||||
// and that read_extraargs properly passed down
|
||||
//
|
||||
pf_req_called = FALSE;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, pe_est_callback, pe_callback, true_pf_req_callback, true_pf_callback, &fetch_val, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, def_pe_est_callback, def_pe_callback, true_pf_req_callback, true_pf_callback, def_cleaner_callback, &fetch_val, NULL);
|
||||
assert(pf_req_called);
|
||||
assert(s1 == sizeof(fetch_val)+1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
// close and reopen cachefile so we can do some simple prefetch tests
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
|
@ -174,10 +149,11 @@ cachetable_test (void) {
|
|||
1,
|
||||
flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_cleaner_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
&doing_prefetch
|
||||
|
@ -188,9 +164,9 @@ cachetable_test (void) {
|
|||
//
|
||||
// now verify we can pin it, and NO fetch callback should get called
|
||||
//
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, pe_est_callback, pe_callback, pf_req_callback, err_pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, err_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
assert(&fetch_val == v1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
//
|
||||
// now verify a prefetch that requires a partial fetch works, and that we can then pin the node
|
||||
|
@ -201,18 +177,19 @@ cachetable_test (void) {
|
|||
1,
|
||||
flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
true_pf_req_callback,
|
||||
true_pf_callback,
|
||||
def_cleaner_callback,
|
||||
&fetch_val,
|
||||
NULL,
|
||||
&doing_prefetch
|
||||
);
|
||||
assert(doing_prefetch);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, pe_est_callback, pe_callback, pf_req_callback, err_pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, err_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
assert(&fetch_val == v1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
|
||||
toku_cachetable_verify(ct);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 35106 2011-09-27 18:30:11Z zardosht $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -29,8 +29,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL write_me,
|
||||
BOOL keep_me,
|
||||
BOOL checkpoint_me
|
||||
|
@ -55,7 +55,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k,
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value,
|
||||
long *sizep,
|
||||
PAIR_ATTR *sizep,
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -67,43 +67,10 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
usleep(10);
|
||||
*data_val = data[data_index];
|
||||
*value = data_val;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void *test_time(void *arg) {
|
||||
//
|
||||
// if num_Seconds is set to 0, run indefinitely
|
||||
|
@ -117,12 +84,6 @@ static void *test_time(void *arg) {
|
|||
return arg;
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
CACHETABLE ct;
|
||||
CACHEFILE f1;
|
||||
|
||||
|
@ -163,7 +124,7 @@ static void *move_numbers(void *arg) {
|
|||
less,
|
||||
&v1,
|
||||
&s1,
|
||||
flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback,
|
||||
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
0, //num_dependent_pairs
|
||||
|
@ -185,7 +146,7 @@ static void *move_numbers(void *arg) {
|
|||
greater,
|
||||
&v1,
|
||||
&s1,
|
||||
flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback,
|
||||
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
1, //num_dependent_pairs
|
||||
|
@ -203,7 +164,7 @@ static void *move_numbers(void *arg) {
|
|||
usleep(10);
|
||||
(*first_val)++;
|
||||
(*second_val)--;
|
||||
r = toku_cachetable_unpin(f1, less_key, less_fullhash, less_dirty, 8);
|
||||
r = toku_cachetable_unpin(f1, less_key, less_fullhash, less_dirty, make_pair_attr(8));
|
||||
|
||||
int third = 0;
|
||||
int num_possible_values = (NUM_ELEMENTS-1) - greater;
|
||||
|
@ -219,7 +180,7 @@ static void *move_numbers(void *arg) {
|
|||
third,
|
||||
&v1,
|
||||
&s1,
|
||||
flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback,
|
||||
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
1, //num_dependent_pairs
|
||||
|
@ -235,9 +196,9 @@ static void *move_numbers(void *arg) {
|
|||
usleep(10);
|
||||
(*second_val)++;
|
||||
(*third_val)--;
|
||||
r = toku_cachetable_unpin(f1, third_key, third_fullhash, third_dirty, 8);
|
||||
r = toku_cachetable_unpin(f1, third_key, third_fullhash, third_dirty, make_pair_attr(8));
|
||||
}
|
||||
r = toku_cachetable_unpin(f1, greater_key, greater_fullhash, greater_dirty, 8);
|
||||
r = toku_cachetable_unpin(f1, greater_key, greater_fullhash, greater_dirty, make_pair_attr(8));
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
|
@ -254,13 +215,13 @@ static void *read_random_numbers(void *arg) {
|
|||
rand_key1,
|
||||
&v1,
|
||||
&s1,
|
||||
flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback,
|
||||
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
if (r1 == 0) {
|
||||
r1 = toku_cachetable_unpin(f1, make_blocknum(rand_key1), rand_key1, CACHETABLE_CLEAN, 8);
|
||||
r1 = toku_cachetable_unpin(f1, make_blocknum(rand_key1), rand_key1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert(r1 == 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,57 +15,47 @@ const int item_size = 1;
|
|||
|
||||
int n_flush, n_write_me, n_keep_me, n_fetch;
|
||||
|
||||
static void flush(CACHEFILE cf, int UU(fd), CACHEKEY key, void *value, void *extraargs, long size, long* UU(new_size), BOOL write_me, BOOL keep_me, BOOL UU(for_checkpoint)) {
|
||||
static void flush(
|
||||
CACHEFILE cf,
|
||||
int UU(fd),
|
||||
CACHEKEY key,
|
||||
void *value,
|
||||
void *extraargs,
|
||||
PAIR_ATTR size,
|
||||
PAIR_ATTR* UU(new_size),
|
||||
BOOL write_me,
|
||||
BOOL keep_me,
|
||||
BOOL UU(for_checkpoint)
|
||||
)
|
||||
{
|
||||
cf = cf; key = key; value = value; extraargs = extraargs;
|
||||
// assert(key == make_blocknum((long)value));
|
||||
assert(size == item_size);
|
||||
assert(size.size == item_size);
|
||||
n_flush++;
|
||||
if (write_me) n_write_me++;
|
||||
if (keep_me) n_keep_me++;
|
||||
}
|
||||
|
||||
static int fetch(CACHEFILE cf, int UU(fd), CACHEKEY key, u_int32_t fullhash, void **value, long *sizep, int *dirtyp, void *extraargs) {
|
||||
static int fetch(
|
||||
CACHEFILE cf,
|
||||
int UU(fd),
|
||||
CACHEKEY key,
|
||||
u_int32_t fullhash,
|
||||
void **value,
|
||||
PAIR_ATTR *sizep,
|
||||
int *dirtyp,
|
||||
void *extraargs
|
||||
)
|
||||
{
|
||||
cf = cf; key = key; fullhash = fullhash; value = value; sizep = sizep; extraargs = extraargs;
|
||||
n_fetch++;
|
||||
sleep(10);
|
||||
*value = 0;
|
||||
*sizep = item_size;
|
||||
*sizep = make_pair_attr(item_size);
|
||||
*dirtyp = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static int dummy_pin_unpin(CACHEFILE UU(cfu), void* UU(v)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -88,7 +78,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
|
|||
{
|
||||
CACHEKEY key = make_blocknum(n+1);
|
||||
u_int32_t fullhash = toku_cachetable_hash(f1, key);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0, NULL);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
|
||||
toku_cachetable_verify(ct);
|
||||
}
|
||||
|
||||
|
@ -97,10 +87,10 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
|
|||
for (i=0; i<n; i++) {
|
||||
CACHEKEY key = make_blocknum(i);
|
||||
u_int32_t hi = toku_cachetable_hash(f1, key);
|
||||
r = toku_cachetable_put(f1, key, hi, (void *)(long)i, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, key, hi, (void *)(long)i, make_pair_attr(1), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
|
||||
r = toku_cachetable_unpin(f1, key, hi, dirty, item_size);
|
||||
r = toku_cachetable_unpin(f1, key, hi, dirty, make_pair_attr(item_size));
|
||||
assert(r == 0);
|
||||
|
||||
void *v;
|
||||
|
@ -131,7 +121,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
|
|||
r = toku_cachetable_maybe_get_and_pin(f1, key, hi, &v);
|
||||
if (r != 0)
|
||||
continue;
|
||||
r = toku_cachetable_unpin(f1, key, hi, CACHETABLE_CLEAN, item_size);
|
||||
r = toku_cachetable_unpin(f1, key, hi, CACHETABLE_CLEAN, make_pair_attr(item_size));
|
||||
assert(r == 0);
|
||||
|
||||
int its_dirty;
|
||||
|
|
|
@ -12,8 +12,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -30,7 +30,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -39,44 +39,12 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
sleep(10);
|
||||
|
||||
*value = toku_malloc(1);
|
||||
*sizep = 1;
|
||||
*sizep = make_pair_attr(1);
|
||||
*dirtyp = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void cachetable_prefetch_close_leak_test (void) {
|
||||
const int test_limit = 1;
|
||||
int r;
|
||||
|
@ -90,7 +58,7 @@ static void cachetable_prefetch_close_leak_test (void) {
|
|||
// prefetch block 0. this will take 10 seconds.
|
||||
CACHEKEY key = make_blocknum(0);
|
||||
u_int32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0, NULL);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
// close with the prefetch in progress. the close should block until
|
||||
|
|
|
@ -14,8 +14,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -31,7 +31,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -40,49 +40,12 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
sleep(2);
|
||||
|
||||
*value = 0;
|
||||
*sizep = 1;
|
||||
*sizep = make_pair_attr(1);
|
||||
*dirtyp = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
assert(expect_pf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(expect_pf);
|
||||
sleep(2);
|
||||
*sizep = 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void cachetable_prefetch_full_test (BOOL partial_fetch) {
|
||||
const int test_limit = 2;
|
||||
expect_pf = FALSE;
|
||||
|
@ -113,18 +76,19 @@ static void cachetable_prefetch_full_test (BOOL partial_fetch) {
|
|||
&size,
|
||||
flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0, NULL);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
// close with the prefetch in progress. the close should block until
|
||||
|
|
|
@ -18,8 +18,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k,
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w,
|
||||
BOOL keep,
|
||||
BOOL f_ckpt __attribute__((__unused__))
|
||||
|
@ -41,7 +41,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k,
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value,
|
||||
long *sizep,
|
||||
PAIR_ATTR *sizep,
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -50,45 +50,12 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
if (verbose) printf("%s:%d %"PRId64"\n", __FUNCTION__, __LINE__, k.b);
|
||||
|
||||
*value = 0;
|
||||
*sizep = 1;
|
||||
*sizep = make_pair_attr(1);
|
||||
*dirtyp = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
// Note: cachetable_size_limit must be a power of 2
|
||||
static void cachetable_prefetch_flowcontrol_test (int cachetable_size_limit) {
|
||||
int r;
|
||||
|
@ -105,7 +72,7 @@ static void cachetable_prefetch_flowcontrol_test (int cachetable_size_limit) {
|
|||
for (i=0; i<cachetable_size_limit; i++) {
|
||||
CACHEKEY key = make_blocknum(i);
|
||||
u_int32_t fullhash = toku_cachetable_hash(f1, key);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0, NULL);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
|
||||
toku_cachetable_verify(ct);
|
||||
}
|
||||
|
||||
|
@ -116,7 +83,7 @@ static void cachetable_prefetch_flowcontrol_test (int cachetable_size_limit) {
|
|||
for (i=i; i<2*cachetable_size_limit; i++) {
|
||||
CACHEKEY key = make_blocknum(i);
|
||||
u_int32_t fullhash = toku_cachetable_hash(f1, key);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0, NULL);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
|
||||
toku_cachetable_verify(ct);
|
||||
// sleep(1);
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -30,7 +30,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -39,36 +39,12 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
sleep(2);
|
||||
}
|
||||
*value = 0;
|
||||
*sizep = 2;
|
||||
*sizep = make_pair_attr(2);
|
||||
*dirtyp = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
if (do_pf) {
|
||||
assert(expect_pf);
|
||||
|
@ -79,10 +55,10 @@ static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
|||
}
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), PAIR_ATTR* UU(sizep)) {
|
||||
assert(expect_pf);
|
||||
sleep(2);
|
||||
*sizep = 2;
|
||||
*sizep = make_pair_attr(2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -117,15 +93,16 @@ static void cachetable_prefetch_maybegetandpin_test (BOOL do_partial_fetch) {
|
|||
&size,
|
||||
flush,
|
||||
fetch,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_cleaner_callback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
|
||||
struct timeval tstart;
|
||||
|
@ -133,16 +110,16 @@ static void cachetable_prefetch_maybegetandpin_test (BOOL do_partial_fetch) {
|
|||
|
||||
// prefetch block 0. this will take 2 seconds.
|
||||
do_pf = TRUE;
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0, NULL);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, pf_callback, def_cleaner_callback, 0, 0, NULL);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
// verify that get_and_pin waits while the prefetch is in progress
|
||||
void *v = 0;
|
||||
long size = 0;
|
||||
do_pf = FALSE;
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, flush, fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, pf_callback, def_cleaner_callback, NULL, NULL, NULL);
|
||||
assert(r==TOKUDB_TRY_AGAIN);
|
||||
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, flush, fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
assert(r == 0 && v == 0 && size == 2);
|
||||
|
||||
struct timeval tend;
|
||||
|
@ -152,7 +129,7 @@ static void cachetable_prefetch_maybegetandpin_test (BOOL do_partial_fetch) {
|
|||
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
|
|
|
@ -6,27 +6,13 @@
|
|||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -34,44 +20,12 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
sleep(10);
|
||||
|
||||
*value = 0;
|
||||
*sizep = 1;
|
||||
*sizep = make_pair_attr(1);
|
||||
*dirtyp = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void cachetable_prefetch_maybegetandpin_test (void) {
|
||||
const int test_limit = 1;
|
||||
|
@ -86,7 +40,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
// prefetch block 0. this will take 10 seconds.
|
||||
CACHEKEY key = make_blocknum(0);
|
||||
u_int32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0, NULL);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
// verify that maybe_get_and_pin returns an error while the prefetch is in progress
|
||||
|
@ -101,7 +55,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
assert(i>1);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
|
|
|
@ -7,20 +7,6 @@
|
|||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
static int fetch_calls = 0;
|
||||
|
||||
static int
|
||||
|
@ -29,7 +15,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -38,45 +24,12 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
sleep(10);
|
||||
|
||||
*value = 0;
|
||||
*sizep = 1;
|
||||
*sizep = make_pair_attr(1);
|
||||
*dirtyp = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void cachetable_prefetch_maybegetandpin_test (void) {
|
||||
const int test_limit = 1;
|
||||
int r;
|
||||
|
@ -90,11 +43,11 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
// prefetch block 0. this will take 10 seconds.
|
||||
CACHEKEY key = make_blocknum(0);
|
||||
u_int32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0, NULL);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
// prefetch again. this should do nothing.
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0, NULL);
|
||||
r = toku_cachefile_prefetch(f1, key, fullhash, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
// verify that maybe_get_and_pin returns an error while the prefetch is in progress
|
||||
|
@ -112,7 +65,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
|||
// there should only be 1 fetch callback
|
||||
assert(fetch_calls == 1);
|
||||
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
|
|
|
@ -2,46 +2,6 @@
|
|||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_put_test (int n) {
|
||||
const int test_limit = 2*n;
|
||||
|
@ -57,11 +17,11 @@ cachetable_put_test (int n) {
|
|||
for (i=1; i<=n; i++) {
|
||||
u_int32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
assert(toku_cachefile_count_pinned(f1, 0) == i);
|
||||
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == -1);
|
||||
assert(toku_cachefile_count_pinned(f1, 0) == i);
|
||||
|
||||
|
@ -78,7 +38,7 @@ cachetable_put_test (int n) {
|
|||
for (i=n; i>0; i--) {
|
||||
u_int32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
assert(toku_cachefile_count_pinned(f1, 0) == i-1);
|
||||
}
|
||||
|
@ -86,7 +46,7 @@ cachetable_put_test (int n) {
|
|||
toku_cachetable_verify(ct);
|
||||
|
||||
CACHEKEY k = make_blocknum(n+1);
|
||||
r = toku_cachetable_unpin(f1, k, toku_cachetable_hash(f1, k), CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, k, toku_cachetable_hash(f1, k), CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r != 0);
|
||||
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
|
|
|
@ -41,8 +41,8 @@ static void r_flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k,
|
||||
void *value,
|
||||
void *extra __attribute__((__unused__)),
|
||||
long size __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR size __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL write_me __attribute__((__unused__)),
|
||||
BOOL keep_me,
|
||||
BOOL for_checkpoint __attribute__((__unused__))) {
|
||||
|
@ -74,46 +74,13 @@ static int r_fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY key __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void**value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void*extraargs __attribute__((__unused__))) {
|
||||
// fprintf(stderr, "Whoops, this should never be called");
|
||||
return -42;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void test_rename (void) {
|
||||
CACHETABLE t;
|
||||
CACHEFILE f;
|
||||
|
@ -134,8 +101,8 @@ static void test_rename (void) {
|
|||
if (verbose) printf("n_keys=%d Insert %08" PRIx64 "\n", n_keys, nkey.b);
|
||||
u_int32_t hnkey = toku_cachetable_hash(f, nkey);
|
||||
r = toku_cachetable_put(f, nkey, hnkey,
|
||||
(void*)nval, 1,
|
||||
r_flush, pe_est_callback, pe_callback, 0);
|
||||
(void*)nval, make_pair_attr(1),
|
||||
r_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r==0);
|
||||
test_mutex_lock();
|
||||
while (n_keys >= KEYLIMIT) {
|
||||
|
@ -148,7 +115,7 @@ static void test_rename (void) {
|
|||
vals[n_keys] = (void*)nval;
|
||||
n_keys++;
|
||||
test_mutex_unlock();
|
||||
r = toku_cachetable_unpin(f, nkey, hnkey, CACHETABLE_DIRTY, 1);
|
||||
r = toku_cachetable_unpin(f, nkey, hnkey, CACHETABLE_DIRTY, make_pair_attr(1));
|
||||
assert(r==0);
|
||||
} else if (ra==2 && n_keys>0) {
|
||||
// Rename something
|
||||
|
@ -160,7 +127,7 @@ static void test_rename (void) {
|
|||
void *current_value;
|
||||
long current_size;
|
||||
if (verbose) printf("Rename %" PRIx64 " to %" PRIx64 "\n", okey.b, nkey.b);
|
||||
r = toku_cachetable_get_and_pin(f, okey, toku_cachetable_hash(f, okey), ¤t_value, ¤t_size, r_flush, r_fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0);
|
||||
r = toku_cachetable_get_and_pin(f, okey, toku_cachetable_hash(f, okey), ¤t_value, ¤t_size, r_flush, r_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
|
||||
if (r == -42) continue;
|
||||
assert(r==0);
|
||||
r = toku_cachetable_rename(f, okey, nkey);
|
||||
|
@ -175,7 +142,7 @@ static void test_rename (void) {
|
|||
assert(j < n_keys);
|
||||
keys[j]=nkey;
|
||||
test_mutex_unlock();
|
||||
r = toku_cachetable_unpin(f, nkey, toku_cachetable_hash(f, nkey), CACHETABLE_DIRTY, 1);
|
||||
r = toku_cachetable_unpin(f, nkey, toku_cachetable_hash(f, nkey), CACHETABLE_DIRTY, make_pair_attr(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +154,7 @@ static void test_rename (void) {
|
|||
r = toku_cachetable_maybe_get_and_pin(f, okey, toku_cachetable_hash(f, okey), &v);
|
||||
if (r != 0)
|
||||
break;
|
||||
r = toku_cachetable_unpin(f, okey, toku_cachetable_hash(f, okey), CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f, okey, toku_cachetable_hash(f, okey), CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
}
|
||||
nkey = make_blocknum(random());
|
||||
|
|
|
@ -14,12 +14,12 @@ static void f_flush (CACHEFILE f,
|
|||
CACHEKEY key,
|
||||
void *value,
|
||||
void *extra __attribute__((__unused__)),
|
||||
long size,
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR size,
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL write_me,
|
||||
BOOL keep_me,
|
||||
BOOL for_checkpoint __attribute__((__unused__))) {
|
||||
assert(size==BLOCKSIZE);
|
||||
assert(size.size==BLOCKSIZE);
|
||||
if (write_me) {
|
||||
toku_os_full_pwrite(toku_cachefile_get_and_pin_fd(f), value, BLOCKSIZE, key.b);
|
||||
toku_cachefile_unpin_fd(f);
|
||||
|
@ -34,7 +34,7 @@ static int f_fetch (CACHEFILE f,
|
|||
CACHEKEY key,
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void**value,
|
||||
long *sizep,
|
||||
PAIR_ATTR *sizep,
|
||||
int *dirtyp,
|
||||
void*extraargs __attribute__((__unused__))) {
|
||||
void *buf = toku_malloc(BLOCKSIZE);
|
||||
|
@ -42,44 +42,11 @@ static int f_fetch (CACHEFILE f,
|
|||
toku_cachefile_unpin_fd(f);
|
||||
assert(r==BLOCKSIZE);
|
||||
*value = buf;
|
||||
*sizep = BLOCKSIZE;
|
||||
*sizep = make_pair_attr(BLOCKSIZE);
|
||||
*dirtyp = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char fname[] = __FILE__ ".dat";
|
||||
|
||||
CACHETABLE t;
|
||||
|
@ -101,8 +68,8 @@ static void writeit (void) {
|
|||
u_int32_t fullhash = toku_cachetable_hash(f, key);
|
||||
int j;
|
||||
for (j=0; j<BLOCKSIZE; j++) ((char*)buf)[j]=(char)((i+j)%256);
|
||||
r = toku_cachetable_put(f, key, fullhash, buf, BLOCKSIZE, f_flush, pe_est_callback, pe_callback, 0); assert(r==0);
|
||||
r = toku_cachetable_unpin(f, key, fullhash, CACHETABLE_CLEAN, BLOCKSIZE); assert(r==0);
|
||||
r = toku_cachetable_put(f, key, fullhash, buf, make_pair_attr(BLOCKSIZE), f_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0); assert(r==0);
|
||||
r = toku_cachetable_unpin(f, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(BLOCKSIZE)); assert(r==0);
|
||||
}
|
||||
gettimeofday(&end, 0);
|
||||
double diff = toku_tdiff(&end, &start);
|
||||
|
@ -122,8 +89,8 @@ static void readit (void) {
|
|||
for (i=0; i<N; i++) {
|
||||
CACHEKEY key = make_blocknum(i*BLOCKSIZE);
|
||||
u_int32_t fullhash = toku_cachetable_hash(f, key);
|
||||
r=toku_cachetable_get_and_pin(f, key, fullhash, &block, ¤t_size, f_flush, f_fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0); assert(r==0);
|
||||
r=toku_cachetable_unpin(f, key, fullhash, CACHETABLE_CLEAN, BLOCKSIZE); assert(r==0);
|
||||
r=toku_cachetable_get_and_pin(f, key, fullhash, &block, ¤t_size, f_flush, f_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0); assert(r==0);
|
||||
r=toku_cachetable_unpin(f, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(BLOCKSIZE)); assert(r==0);
|
||||
}
|
||||
r = toku_cachefile_close(&f, 0, FALSE, ZERO_LSN); assert(r == 0);
|
||||
r = toku_cachetable_close(&t); assert(r == 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -13,8 +13,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -30,55 +30,16 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
const int test_limit = 12;
|
||||
|
@ -95,15 +56,15 @@ cachetable_test (void) {
|
|||
// nothing in cachetable, so this should fail
|
||||
r = toku_cachetable_maybe_get_and_pin(f1, make_blocknum(1), 1, &v1);
|
||||
assert(r==-1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
// maybe_get_and_pin_clean should succeed, maybe_get_and_pin should fail
|
||||
r = toku_cachetable_maybe_get_and_pin(f1, make_blocknum(1), 1, &v1);
|
||||
assert(r==-1);
|
||||
r = toku_cachetable_maybe_get_and_pin_clean(f1, make_blocknum(1), 1, &v1);
|
||||
assert(r == 0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
// maybe_get_and_pin_clean should succeed, maybe_get_and_pin should fail
|
||||
r = toku_cachetable_maybe_get_and_pin(f1, make_blocknum(1), 1, &v1);
|
||||
assert(r==0);
|
||||
|
@ -112,12 +73,12 @@ cachetable_test (void) {
|
|||
assert(r==-1);
|
||||
r = toku_cachetable_maybe_get_and_pin_clean(f1, make_blocknum(1), 1, &v1);
|
||||
assert(r==-1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
|
||||
// sanity check, this should still succeed, because the PAIR is dirty
|
||||
r = toku_cachetable_maybe_get_and_pin(f1, make_blocknum(1), 1, &v1);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
r = toku_cachetable_begin_checkpoint(ct, NULL); assert(r == 0);
|
||||
// now these should fail, because the node should be pending a checkpoint
|
||||
r = toku_cachetable_maybe_get_and_pin(f1, make_blocknum(1), 1, &v1);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -19,8 +19,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -50,55 +50,16 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = extraargs;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (BOOL write_first, BOOL write_second) {
|
||||
const int test_limit = 12;
|
||||
|
@ -116,8 +77,8 @@ cachetable_test (BOOL write_first, BOOL write_second) {
|
|||
long s1;
|
||||
long s2;
|
||||
long s3;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, &val1, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, &val2, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &val1, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &val2, NULL);
|
||||
|
||||
CACHEFILE dependent_cfs[2];
|
||||
dependent_cfs[0] = f1;
|
||||
|
@ -148,7 +109,7 @@ cachetable_test (BOOL write_first, BOOL write_second) {
|
|||
3,
|
||||
&v3,
|
||||
&s3,
|
||||
flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback,
|
||||
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
|
||||
&val3,
|
||||
NULL,
|
||||
2, //num_dependent_pairs
|
||||
|
@ -161,9 +122,9 @@ cachetable_test (BOOL write_first, BOOL write_second) {
|
|||
assert(v2_written == write_second);
|
||||
|
||||
check_me = FALSE;
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
r = toku_cachetable_end_checkpoint(
|
||||
ct,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -16,8 +16,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -39,55 +39,21 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL true_pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
static BOOL true_def_pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static int true_pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* sizep) {
|
||||
*sizep = 8;
|
||||
static int true_def_pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), PAIR_ATTR* sizep) {
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -97,17 +63,17 @@ static void kibbutz_work(void *fe_v)
|
|||
CACHEFILE f1 = fe_v;
|
||||
sleep(2);
|
||||
foo = TRUE;
|
||||
int r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
int r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert(r==0);
|
||||
notify_cachefile_that_kibbutz_job_finishing(f1);
|
||||
remove_background_job(f1, false);
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
static void my_ydb_lock(void) {
|
||||
assert(!is_fake_locked);
|
||||
is_fake_locked = TRUE;
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
static void my_ydb_unlock(void) {
|
||||
assert(is_fake_locked);
|
||||
is_fake_locked = FALSE;
|
||||
}
|
||||
|
@ -124,7 +90,7 @@ run_test (void) {
|
|||
CACHEFILE f1;
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
toku_cachetable_set_lock_unlock_for_io(ct, fake_ydb_lock, fake_ydb_unlock);
|
||||
toku_cachetable_set_lock_unlock_for_io(ct, my_ydb_lock, my_ydb_unlock);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
|
@ -133,33 +99,33 @@ run_test (void) {
|
|||
// because the PAIR was not in the cachetable.
|
||||
//
|
||||
is_fake_locked = TRUE;
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
|
||||
assert(r==TOKUDB_TRY_AGAIN);
|
||||
assert(is_fake_locked);
|
||||
// now it should succeed
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
|
||||
assert(r==0);
|
||||
assert(is_fake_locked);
|
||||
foo = FALSE;
|
||||
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
|
||||
// because node is in use, should return TOKUDB_TRY_AGAIN
|
||||
assert(is_fake_locked);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
|
||||
assert(is_fake_locked);
|
||||
assert(r==TOKUDB_TRY_AGAIN);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
assert(foo);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8); assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
|
||||
|
||||
// now make sure we get TOKUDB_TRY_AGAIN when a partial fetch is involved
|
||||
assert(is_fake_locked);
|
||||
// first make sure value is there
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
|
||||
assert(is_fake_locked);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8); assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
|
||||
// now make sure that we get TOKUDB_TRY_AGAIN for the partial fetch
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, true_pf_req_callback, true_pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, true_def_pf_req_callback, true_def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
|
||||
assert(is_fake_locked);
|
||||
assert(r==TOKUDB_TRY_AGAIN);
|
||||
|
||||
|
@ -167,21 +133,21 @@ run_test (void) {
|
|||
// now test that if there is a checkpoint pending,
|
||||
// first pin and unpin with dirty
|
||||
//
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
|
||||
assert(is_fake_locked);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, 8); assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8)); assert(r==0);
|
||||
// this should mark the PAIR as pending
|
||||
r = toku_cachetable_begin_checkpoint(ct, NULL); assert(r == 0);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
|
||||
assert(is_fake_locked);
|
||||
assert(r==TOKUDB_TRY_AGAIN);
|
||||
fake_ydb_unlock();
|
||||
my_ydb_unlock();
|
||||
r = toku_cachetable_end_checkpoint(
|
||||
ct,
|
||||
NULL,
|
||||
fake_ydb_lock,
|
||||
fake_ydb_unlock,
|
||||
my_ydb_lock,
|
||||
my_ydb_unlock,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -17,8 +17,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -40,65 +40,26 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void kibbutz_work(void *fe_v)
|
||||
{
|
||||
CACHEFILE f1 = fe_v;
|
||||
sleep(2);
|
||||
foo = TRUE;
|
||||
int r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
int r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert(r==0);
|
||||
notify_cachefile_that_kibbutz_job_finishing(f1);
|
||||
remove_background_job(f1, false);
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
run_test (void) {
|
||||
const int test_limit = 12;
|
||||
|
@ -114,17 +75,17 @@ run_test (void) {
|
|||
//void* v2;
|
||||
long s1;
|
||||
//long s2;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
foo = FALSE;
|
||||
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
assert(foo);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
//now let's do a simple checkpoint test
|
||||
// first dirty the PAIR
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
|
||||
// now this should mark the pair for checkpoint
|
||||
r = toku_cachetable_begin_checkpoint(ct, NULL);
|
||||
|
@ -134,9 +95,9 @@ run_test (void) {
|
|||
//
|
||||
check_me = TRUE;
|
||||
flush_called = FALSE;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
assert(flush_called);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
|
||||
check_me = FALSE;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -19,8 +19,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -50,54 +50,16 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = extraargs;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
static void get_key_and_fullhash(CACHEKEY* cachekey, u_int32_t* fullhash, void* extra) {
|
||||
assert(extra == NULL);
|
||||
cachekey->b = 3;
|
||||
|
@ -120,9 +82,11 @@ cachetable_test (BOOL write_first, BOOL write_second) {
|
|||
void* v2;
|
||||
long s1;
|
||||
long s2;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, &val1, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, &val2, NULL);
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &val1, NULL);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &val2, NULL);
|
||||
assert(r==0);
|
||||
|
||||
CACHEFILE dependent_cfs[2];
|
||||
dependent_cfs[0] = f1;
|
||||
dependent_cfs[1] = f1;
|
||||
|
@ -153,10 +117,11 @@ cachetable_test (BOOL write_first, BOOL write_second) {
|
|||
f1,
|
||||
get_key_and_fullhash,
|
||||
&val3,
|
||||
8,
|
||||
make_pair_attr(8),
|
||||
flush,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_cleaner_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
2, //num_dependent_pairs
|
||||
|
@ -175,9 +140,9 @@ cachetable_test (BOOL write_first, BOOL write_second) {
|
|||
assert(v2_written == write_second);
|
||||
|
||||
check_me = FALSE;
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, 8);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
r = toku_cachetable_end_checkpoint(
|
||||
ct,
|
||||
|
|
|
@ -9,8 +9,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -26,49 +26,16 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 8;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
const int test_limit = 12;
|
||||
|
@ -84,8 +51,8 @@ cachetable_test (void) {
|
|||
//void* v2;
|
||||
long s1;
|
||||
//long s2;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, 8);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
toku_cachetable_verify(ct);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
|
||||
|
|
|
@ -106,8 +106,8 @@ static void flush (CACHEFILE f,
|
|||
CACHEKEY key,
|
||||
void*value,
|
||||
void *extra __attribute__((__unused__)),
|
||||
long size __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR size __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL write_me __attribute__((__unused__)),
|
||||
BOOL keep_me __attribute__((__unused__)),
|
||||
BOOL for_checkpoint __attribute__((__unused__))) {
|
||||
|
@ -146,50 +146,17 @@ static struct item *make_item (u_int64_t key) {
|
|||
}
|
||||
|
||||
static CACHEKEY did_fetch={-1};
|
||||
static int fetch (CACHEFILE f, int UU(fd), CACHEKEY key, u_int32_t fullhash __attribute__((__unused__)), void**value, long *sizep __attribute__((__unused__)), int *dirtyp, void*extraargs) {
|
||||
static int fetch (CACHEFILE f, int UU(fd), CACHEKEY key, u_int32_t fullhash __attribute__((__unused__)), void**value, PAIR_ATTR *sizep __attribute__((__unused__)), int *dirtyp, void*extraargs) {
|
||||
if (verbose) printf("Fetch %" PRId64 "\n", key.b);
|
||||
assert (expect_f==f);
|
||||
assert((long)extraargs==23);
|
||||
*value = make_item(key.b);
|
||||
*sizep = test_object_size;
|
||||
*sizep = make_pair_attr(test_object_size);
|
||||
*dirtyp = 0;
|
||||
did_fetch=key;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void maybe_flush(CACHETABLE t) {
|
||||
toku_cachetable_maybe_flush_some(t);
|
||||
}
|
||||
|
@ -223,37 +190,37 @@ static void test0 (void) {
|
|||
u_int32_t h5 = toku_cachetable_hash(f, make_blocknum(5));
|
||||
u_int32_t h6 = toku_cachetable_hash(f, make_blocknum(6));
|
||||
u_int32_t h7 = toku_cachetable_hash(f, make_blocknum(7));
|
||||
r=toku_cachetable_put(f, make_blocknum(1), h1, make_item(1), test_object_size, flush, pe_est_callback, pe_callback, t3); /* 1P */ /* this is the lru list. 1 is pinned. */
|
||||
r=toku_cachetable_put(f, make_blocknum(1), h1, make_item(1), make_pair_attr(test_object_size), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, t3); /* 1P */ /* this is the lru list. 1 is pinned. */
|
||||
assert(r==0);
|
||||
assert(expect_n_flushes==0);
|
||||
|
||||
expect_init();
|
||||
r=toku_cachetable_put(f, make_blocknum(2), h2, make_item(2), test_object_size, flush, pe_est_callback, pe_callback, t3);
|
||||
r=toku_cachetable_put(f, make_blocknum(2), h2, make_item(2), make_pair_attr(test_object_size), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, t3);
|
||||
assert(r==0);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(2), h2, CACHETABLE_DIRTY, 1); /* 2U 1P */
|
||||
r=toku_cachetable_unpin(f, make_blocknum(2), h2, CACHETABLE_DIRTY, make_pair_attr(1)); /* 2U 1P */
|
||||
assert(expect_n_flushes==0);
|
||||
|
||||
expect_init();
|
||||
r=toku_cachetable_put(f, make_blocknum(3), h3, make_item(3), test_object_size, flush, pe_est_callback, pe_callback, t3);
|
||||
r=toku_cachetable_put(f, make_blocknum(3), h3, make_item(3), make_pair_attr(test_object_size), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, t3);
|
||||
assert(r==0);
|
||||
assert(expect_n_flushes==0); /* 3P 2U 1P */ /* 3 is most recently used (pinned), 2 is next (unpinned), 1 is least recent (pinned) */
|
||||
|
||||
expect_init();
|
||||
r=toku_cachetable_put(f, make_blocknum(4), h4, make_item(4), test_object_size, flush, pe_est_callback, pe_callback, t3);
|
||||
r=toku_cachetable_put(f, make_blocknum(4), h4, make_item(4), make_pair_attr(test_object_size), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, t3);
|
||||
assert(r==0);
|
||||
assert(expect_n_flushes==0); /* 4P 3P 2U 1P */
|
||||
|
||||
expect_init();
|
||||
r=toku_cachetable_put(f, make_blocknum(5), h5, make_item(5), test_object_size, flush, pe_est_callback, pe_callback, t3);
|
||||
r=toku_cachetable_put(f, make_blocknum(5), h5, make_item(5), make_pair_attr(test_object_size), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, t3);
|
||||
assert(r==0);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(5), h5, CACHETABLE_DIRTY, test_object_size);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(5), h5, CACHETABLE_DIRTY, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(3), h3, CACHETABLE_DIRTY, test_object_size);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(3), h3, CACHETABLE_DIRTY, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
assert(expect_n_flushes==0); /* 5U 4P 3U 2U 1P */
|
||||
|
||||
expect1(2); /* 2 is the oldest unpinned item. */
|
||||
r=toku_cachetable_put(f, make_blocknum(6), h6, make_item(6), test_object_size, flush, pe_est_callback, pe_callback, t3); /* 6P 5U 4P 3U 1P */
|
||||
r=toku_cachetable_put(f, make_blocknum(6), h6, make_item(6), make_pair_attr(test_object_size), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, t3); /* 6P 5U 4P 3U 1P */
|
||||
assert(r==0);
|
||||
test_mutex_lock();
|
||||
while (expect_n_flushes != 0) {
|
||||
|
@ -263,7 +230,7 @@ static void test0 (void) {
|
|||
test_mutex_unlock();
|
||||
|
||||
expect1(3);
|
||||
r=toku_cachetable_put(f, make_blocknum(7), h7, make_item(7), test_object_size, flush, pe_est_callback, pe_callback, t3);
|
||||
r=toku_cachetable_put(f, make_blocknum(7), h7, make_item(7), make_pair_attr(test_object_size), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, t3);
|
||||
assert(r==0);
|
||||
test_mutex_lock();
|
||||
while (expect_n_flushes != 0) {
|
||||
|
@ -271,13 +238,13 @@ static void test0 (void) {
|
|||
}
|
||||
assert(expect_n_flushes==0);
|
||||
test_mutex_unlock();
|
||||
r=toku_cachetable_unpin(f, make_blocknum(7), h7, CACHETABLE_DIRTY, test_object_size); /* 7U 6P 5U 4P 1P */
|
||||
r=toku_cachetable_unpin(f, make_blocknum(7), h7, CACHETABLE_DIRTY, make_pair_attr(test_object_size)); /* 7U 6P 5U 4P 1P */
|
||||
assert(r==0);
|
||||
|
||||
{
|
||||
void *item_v=0;
|
||||
expect_init();
|
||||
r=toku_cachetable_get_and_pin(f, make_blocknum(5), toku_cachetable_hash(f, make_blocknum(5)), &item_v, NULL, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, t3, t3); /* 5P 7U 6P 4P 1P */
|
||||
r=toku_cachetable_get_and_pin(f, make_blocknum(5), toku_cachetable_hash(f, make_blocknum(5)), &item_v, NULL, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, t3, t3); /* 5P 7U 6P 4P 1P */
|
||||
assert(r==0);
|
||||
assert(((struct item *)item_v)->key.b==5);
|
||||
assert(strcmp(((struct item *)item_v)->something,"something")==0);
|
||||
|
@ -288,11 +255,11 @@ static void test0 (void) {
|
|||
|
||||
{
|
||||
void *item_v=0;
|
||||
r=toku_cachetable_unpin(f, make_blocknum(4), h4, CACHETABLE_DIRTY, test_object_size);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(4), h4, CACHETABLE_DIRTY, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
expect1(4);
|
||||
did_fetch=make_blocknum(-1);
|
||||
r=toku_cachetable_get_and_pin(f, make_blocknum(2), toku_cachetable_hash(f, make_blocknum(2)), &item_v, NULL, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, t3, t3); /* 2p 5P 7U 6P 1P */
|
||||
r=toku_cachetable_get_and_pin(f, make_blocknum(2), toku_cachetable_hash(f, make_blocknum(2)), &item_v, NULL, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, t3, t3); /* 2p 5P 7U 6P 1P */
|
||||
assert(r==0);
|
||||
assert(did_fetch.b==2); /* Expect that 2 is fetched in. */
|
||||
assert(((struct item *)item_v)->key.b==2);
|
||||
|
@ -305,13 +272,13 @@ static void test0 (void) {
|
|||
test_mutex_unlock();
|
||||
}
|
||||
|
||||
r=toku_cachetable_unpin(f, make_blocknum(2), h2, CACHETABLE_DIRTY, test_object_size);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(2), h2, CACHETABLE_DIRTY, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(5), h5, CACHETABLE_DIRTY, test_object_size);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(5), h5, CACHETABLE_DIRTY, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(6), h6, CACHETABLE_DIRTY, test_object_size);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(6), h6, CACHETABLE_DIRTY, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(1), h1, CACHETABLE_DIRTY, test_object_size);
|
||||
r=toku_cachetable_unpin(f, make_blocknum(1), h1, CACHETABLE_DIRTY, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
r=toku_cachetable_assert_all_unpinned(t);
|
||||
assert(r==0);
|
||||
|
@ -334,8 +301,8 @@ static void test0 (void) {
|
|||
static void flush_n (CACHEFILE f __attribute__((__unused__)), int UU(fd), CACHEKEY key __attribute__((__unused__)),
|
||||
void *value,
|
||||
void *extra __attribute__((__unused__)),
|
||||
long size __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR size __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL write_me __attribute__((__unused__)), BOOL keep_me __attribute__((__unused__)),
|
||||
BOOL for_checkpoint __attribute__ ((__unused__))) {
|
||||
int *v = value;
|
||||
|
@ -343,7 +310,7 @@ static void flush_n (CACHEFILE f __attribute__((__unused__)), int UU(fd), CACHEK
|
|||
}
|
||||
static int fetch_n (CACHEFILE f __attribute__((__unused__)), int UU(fd), CACHEKEY key __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void**value, long *sizep __attribute__((__unused__)),
|
||||
void**value, PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int * dirtyp, void*extraargs) {
|
||||
assert((long)extraargs==42);
|
||||
*value=0;
|
||||
|
@ -370,24 +337,24 @@ static void test_nested_pin (void) {
|
|||
|
||||
i0=0; i1=0;
|
||||
u_int32_t f1hash = toku_cachetable_hash(f, make_blocknum(1));
|
||||
r = toku_cachetable_put(f, make_blocknum(1), f1hash, &i0, 1, flush_n, pe_est_callback, pe_callback, f2);
|
||||
r = toku_cachetable_put(f, make_blocknum(1), f1hash, &i0, make_pair_attr(1), flush_n, def_pe_est_callback, def_pe_callback, def_cleaner_callback, f2);
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(f, make_blocknum(1), f1hash, CACHETABLE_CLEAN, test_object_size);
|
||||
r = toku_cachetable_get_and_pin(f, make_blocknum(1), f1hash, &vv, NULL, flush_n, fetch_n, pe_est_callback, pe_callback, pf_req_callback, pf_callback, f2, f2);
|
||||
r = toku_cachetable_unpin(f, make_blocknum(1), f1hash, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
r = toku_cachetable_get_and_pin(f, make_blocknum(1), f1hash, &vv, NULL, flush_n, fetch_n, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, f2, f2);
|
||||
assert(r==0);
|
||||
assert(vv==&i0);
|
||||
assert(i0==0);
|
||||
r = toku_cachetable_unpin(f, make_blocknum(1), f1hash, CACHETABLE_CLEAN, test_object_size);
|
||||
r = toku_cachetable_unpin(f, make_blocknum(1), f1hash, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
r = toku_cachetable_maybe_get_and_pin(f, make_blocknum(1), f1hash, &vv2);
|
||||
assert(r==0);
|
||||
assert(vv2==vv);
|
||||
r = toku_cachetable_unpin(f, make_blocknum(1), f1hash, CACHETABLE_CLEAN, test_object_size);
|
||||
r = toku_cachetable_unpin(f, make_blocknum(1), f1hash, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
u_int32_t f2hash = toku_cachetable_hash(f, make_blocknum(2));
|
||||
r = toku_cachetable_put(f, make_blocknum(2), f2hash, &i1, test_object_size, flush_n, pe_est_callback, pe_callback, f2);
|
||||
r = toku_cachetable_put(f, make_blocknum(2), f2hash, &i1, make_pair_attr(test_object_size), flush_n, def_pe_est_callback, def_pe_callback, def_cleaner_callback, f2);
|
||||
assert(r==0); // The other one is pinned, but now the cachetable fails gracefully: It allows the pin to happen
|
||||
r = toku_cachetable_unpin(f, make_blocknum(2), f2hash, CACHETABLE_CLEAN, test_object_size);
|
||||
r = toku_cachetable_unpin(f, make_blocknum(2), f2hash, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
// toku_os_usleep(1*1000000);
|
||||
r = toku_cachefile_close(&f, 0, FALSE, ZERO_LSN); assert(r==0);
|
||||
|
@ -400,14 +367,14 @@ static void null_flush (CACHEFILE cf __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *extra __attribute__((__unused__)),
|
||||
long size __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR size __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL write_me __attribute__((__unused__)),
|
||||
BOOL keep_me __attribute__((__unused__)),
|
||||
BOOL for_checkpoint __attribute__((__unused__))) {
|
||||
}
|
||||
|
||||
static int add123_fetch (CACHEFILE cf, int UU(fd), CACHEKEY key, u_int32_t fullhash, void **value, long *sizep __attribute__((__unused__)), int * dirtyp, void*extraargs) {
|
||||
static int add123_fetch (CACHEFILE cf, int UU(fd), CACHEKEY key, u_int32_t fullhash, void **value, PAIR_ATTR *sizep __attribute__((__unused__)), int * dirtyp, void*extraargs) {
|
||||
assert(fullhash==toku_cachetable_hash(cf,key));
|
||||
assert((long)extraargs==123);
|
||||
*value = (void*)((unsigned long)key.b+123L);
|
||||
|
@ -415,7 +382,7 @@ static int add123_fetch (CACHEFILE cf, int UU(fd), CACHEKEY key, u_int32_t fullh
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int add222_fetch (CACHEFILE cf, int UU(fd), CACHEKEY key, u_int32_t fullhash, void **value, long *sizep __attribute__((__unused__)), int * dirtyp, void*extraargs) {
|
||||
static int add222_fetch (CACHEFILE cf, int UU(fd), CACHEKEY key, u_int32_t fullhash, void **value, PAIR_ATTR *sizep __attribute__((__unused__)), int * dirtyp, void*extraargs) {
|
||||
assert(fullhash==toku_cachetable_hash(cf,key));
|
||||
assert((long)extraargs==222);
|
||||
*value = (void*)((unsigned long)key.b+222L);
|
||||
|
@ -445,24 +412,24 @@ static void test_multi_filehandles (void) {
|
|||
assert(f1==f2);
|
||||
assert(f1!=f3);
|
||||
|
||||
r = toku_cachetable_put(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), (void*)124, test_object_size, null_flush, pe_est_callback, pe_callback, (void*)123); assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), CACHETABLE_DIRTY, 0); assert(r==0);
|
||||
r = toku_cachetable_get_and_pin(f2, make_blocknum(1), toku_cachetable_hash(f2, make_blocknum(1)), &v, NULL, null_flush, add123_fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, (void*)123, (void*)123); assert(r==0);
|
||||
r = toku_cachetable_put(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), (void*)124, make_pair_attr(test_object_size), null_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, (void*)123); assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), CACHETABLE_DIRTY, make_pair_attr(0)); assert(r==0);
|
||||
r = toku_cachetable_get_and_pin(f2, make_blocknum(1), toku_cachetable_hash(f2, make_blocknum(1)), &v, NULL, null_flush, add123_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, (void*)123, (void*)123); assert(r==0);
|
||||
assert((unsigned long)v==124);
|
||||
r = toku_cachetable_get_and_pin(f2, make_blocknum(2), toku_cachetable_hash(f2, make_blocknum(2)), &v, NULL, null_flush, add123_fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, (void*)123, (void*)123); assert(r==0);
|
||||
r = toku_cachetable_get_and_pin(f2, make_blocknum(2), toku_cachetable_hash(f2, make_blocknum(2)), &v, NULL, null_flush, add123_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, (void*)123, (void*)123); assert(r==0);
|
||||
assert((unsigned long)v==125);
|
||||
r = toku_cachetable_get_and_pin(f3, make_blocknum(2), toku_cachetable_hash(f3, make_blocknum(2)), &v, NULL, null_flush, add222_fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, (void*)222, (void*)222); assert(r==0);
|
||||
r = toku_cachetable_get_and_pin(f3, make_blocknum(2), toku_cachetable_hash(f3, make_blocknum(2)), &v, NULL, null_flush, add222_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, (void*)222, (void*)222); assert(r==0);
|
||||
assert((unsigned long)v==224);
|
||||
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), CACHETABLE_CLEAN, 0); assert(r==0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), CACHETABLE_CLEAN, make_pair_attr(0)); assert(r==0);
|
||||
// r = toku_cachetable_unpin(f1, make_blocknum(2), toku_cachetable_hash(f1, make_blocknum(2)), CACHETABLE_CLEAN, 0); assert(r==0);
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r==0);
|
||||
|
||||
//r = toku_cachetable_unpin(f2, make_blocknum(1), toku_cachetable_hash(f2, make_blocknum(1)), CACHETABLE_CLEAN, 0); assert(r==0);
|
||||
r = toku_cachetable_unpin(f2, make_blocknum(2), toku_cachetable_hash(f2, make_blocknum(2)), CACHETABLE_CLEAN, 0); assert(r==0);
|
||||
r = toku_cachetable_unpin(f2, make_blocknum(2), toku_cachetable_hash(f2, make_blocknum(2)), CACHETABLE_CLEAN, make_pair_attr(0)); assert(r==0);
|
||||
r = toku_cachefile_close(&f2, 0, FALSE, ZERO_LSN); assert(r==0);
|
||||
|
||||
r = toku_cachetable_unpin(f3, make_blocknum(2), toku_cachetable_hash(f3, make_blocknum(2)), CACHETABLE_CLEAN, 0); assert(r==0);
|
||||
r = toku_cachetable_unpin(f3, make_blocknum(2), toku_cachetable_hash(f3, make_blocknum(2)), CACHETABLE_CLEAN, make_pair_attr(0)); assert(r==0);
|
||||
r = toku_cachefile_close(&f3, 0, FALSE, ZERO_LSN); assert(r==0);
|
||||
|
||||
r = toku_cachetable_close(&t); assert(r==0);
|
||||
|
@ -475,19 +442,19 @@ static void test_dirty_flush(CACHEFILE f,
|
|||
CACHEKEY key,
|
||||
void *value,
|
||||
void *extra __attribute__((__unused__)),
|
||||
long size,
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR size,
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL do_write,
|
||||
BOOL keep,
|
||||
BOOL for_checkpoint __attribute__((__unused__))) {
|
||||
if (verbose) printf("test_dirty_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size, (unsigned)do_write, (unsigned)keep);
|
||||
if (verbose) printf("test_dirty_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size.size, (unsigned)do_write, (unsigned)keep);
|
||||
}
|
||||
|
||||
static int test_dirty_fetch(CACHEFILE f, int UU(fd), CACHEKEY key, u_int32_t fullhash, void **value_ptr, long *size_ptr, int * dirtyp, void *arg) {
|
||||
static int test_dirty_fetch(CACHEFILE f, int UU(fd), CACHEKEY key, u_int32_t fullhash, void **value_ptr, PAIR_ATTR *size_ptr, int * dirtyp, void *arg) {
|
||||
*value_ptr = arg;
|
||||
*dirtyp = 0;
|
||||
assert(fullhash==toku_cachetable_hash(f,key));
|
||||
if (verbose) printf("test_dirty_fetch %p %" PRId64 " %p %ld %p\n", f, key.b, *value_ptr, *size_ptr, arg);
|
||||
if (verbose) printf("test_dirty_fetch %p %" PRId64 " %p %ld %p\n", f, key.b, *value_ptr, size_ptr->size, arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -510,7 +477,7 @@ static void test_dirty(void) {
|
|||
|
||||
key = make_blocknum(1); value = (void*)1;
|
||||
u_int32_t hkey = toku_cachetable_hash(f, key);
|
||||
r = toku_cachetable_put(f, key, hkey, value, test_object_size, test_dirty_flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f, key, hkey, value, make_pair_attr(test_object_size), test_dirty_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
|
||||
// cachetable_print_state(t);
|
||||
|
@ -519,7 +486,7 @@ static void test_dirty(void) {
|
|||
assert(dirty == 1);
|
||||
assert(pinned == 1);
|
||||
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, 0);
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, make_pair_attr(0));
|
||||
assert(r == 0);
|
||||
r = toku_cachetable_get_key_state(t, key, f, &value, &dirty, &pinned, &entry_size);
|
||||
assert(r == 0);
|
||||
|
@ -527,7 +494,7 @@ static void test_dirty(void) {
|
|||
assert(pinned == 0);
|
||||
|
||||
r = toku_cachetable_get_and_pin(f, key, hkey, &value, NULL, test_dirty_flush,
|
||||
test_dirty_fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0);
|
||||
test_dirty_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
|
||||
assert(r == 0);
|
||||
|
||||
// cachetable_print_state(t);
|
||||
|
@ -536,7 +503,7 @@ static void test_dirty(void) {
|
|||
assert(dirty == 1);
|
||||
assert(pinned == 1);
|
||||
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, test_object_size);
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
assert(r == 0);
|
||||
|
||||
// cachetable_print_state(t);
|
||||
|
@ -549,7 +516,7 @@ static void test_dirty(void) {
|
|||
hkey = toku_cachetable_hash(f, key);
|
||||
r = toku_cachetable_get_and_pin(f, key, hkey,
|
||||
&value, NULL, test_dirty_flush,
|
||||
test_dirty_fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0);
|
||||
test_dirty_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
|
||||
assert(r == 0);
|
||||
|
||||
// cachetable_print_state(t);
|
||||
|
@ -558,7 +525,7 @@ static void test_dirty(void) {
|
|||
assert(dirty == 0);
|
||||
assert(pinned == 1);
|
||||
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, test_object_size);
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
assert(r == 0);
|
||||
|
||||
// cachetable_print_state(t);
|
||||
|
@ -569,7 +536,7 @@ static void test_dirty(void) {
|
|||
|
||||
r = toku_cachetable_get_and_pin(f, key, hkey,
|
||||
&value, NULL, test_dirty_flush,
|
||||
test_dirty_fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0);
|
||||
test_dirty_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
|
||||
assert(r == 0);
|
||||
|
||||
// cachetable_print_state(t);
|
||||
|
@ -578,7 +545,7 @@ static void test_dirty(void) {
|
|||
assert(dirty == 0);
|
||||
assert(pinned == 1);
|
||||
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_DIRTY, test_object_size);
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_DIRTY, make_pair_attr(test_object_size));
|
||||
assert(r == 0);
|
||||
|
||||
// cachetable_print_state(t);
|
||||
|
@ -601,12 +568,12 @@ static void test_size_flush_callback(CACHEFILE f,
|
|||
CACHEKEY key,
|
||||
void *value,
|
||||
void *extra __attribute__((__unused__)),
|
||||
long size,
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR size,
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL do_write,
|
||||
BOOL keep,
|
||||
BOOL for_checkpoint __attribute__((__unused__))) {
|
||||
if (test_size_debug && verbose) printf("test_size_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size, (unsigned)do_write, (unsigned)keep);
|
||||
if (test_size_debug && verbose) printf("test_size_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size.size, (unsigned)do_write, (unsigned)keep);
|
||||
if (keep) {
|
||||
if (do_write) {
|
||||
test_mutex_lock();
|
||||
|
@ -641,7 +608,7 @@ static void test_size_resize(void) {
|
|||
|
||||
u_int32_t hkey = toku_cachetable_hash(f, key);
|
||||
|
||||
r = toku_cachetable_put(f, key, hkey, value, size, test_size_flush_callback, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f, key, hkey, value, make_pair_attr(size), test_size_flush_callback, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
|
||||
void *entry_value; int dirty; long long pinned; long entry_size;
|
||||
|
@ -653,17 +620,17 @@ static void test_size_resize(void) {
|
|||
assert(entry_size == size);
|
||||
|
||||
long long new_size = 2*size;
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, new_size);
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, make_pair_attr(new_size));
|
||||
assert(r == 0);
|
||||
|
||||
void *current_value;
|
||||
long current_size;
|
||||
r = toku_cachetable_get_and_pin(f, key, hkey, ¤t_value, ¤t_size, test_size_flush_callback, 0, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0);
|
||||
r = toku_cachetable_get_and_pin(f, key, hkey, ¤t_value, ¤t_size, test_size_flush_callback, 0, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
|
||||
assert(r == 0);
|
||||
assert(current_value == value);
|
||||
assert(current_size == new_size);
|
||||
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, new_size);
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, make_pair_attr(new_size));
|
||||
assert(r == 0);
|
||||
|
||||
r = toku_cachefile_close(&f, 0, FALSE, ZERO_LSN);
|
||||
|
@ -704,7 +671,7 @@ static void test_size_flush(void) {
|
|||
void *value = (void *)(long)-i;
|
||||
// printf("test_size put %lld %p %lld\n", key, value, size);
|
||||
u_int32_t hkey = toku_cachetable_hash(f, key);
|
||||
r = toku_cachetable_put(f, key, hkey, value, size, test_size_flush_callback, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f, key, hkey, value, make_pair_attr(size), test_size_flush_callback, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
|
||||
int n_entries, hash_size; long size_current, size_limit, size_max;
|
||||
|
@ -731,7 +698,7 @@ static void test_size_flush(void) {
|
|||
}
|
||||
test_mutex_unlock();
|
||||
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, size);
|
||||
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, make_pair_attr(size));
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,8 +98,8 @@ static void flush_forchain (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY key,
|
||||
void *value,
|
||||
void *extra __attribute__((__unused__)),
|
||||
long size __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR size __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL write_me __attribute__((__unused__)),
|
||||
BOOL keep_me __attribute__((__unused__)),
|
||||
BOOL for_checkpoint __attribute__((__unused__))) {
|
||||
|
@ -112,7 +112,7 @@ static void flush_forchain (CACHEFILE f __attribute__((__unused__)),
|
|||
//print_ints();
|
||||
}
|
||||
|
||||
static int fetch_forchain (CACHEFILE f, int UU(fd), CACHEKEY key, u_int32_t fullhash, void**value, long *sizep __attribute__((__unused__)), int * dirtyp, void*extraargs) {
|
||||
static int fetch_forchain (CACHEFILE f, int UU(fd), CACHEKEY key, u_int32_t fullhash, void**value, PAIR_ATTR *sizep __attribute__((__unused__)), int * dirtyp, void*extraargs) {
|
||||
assert(toku_cachetable_hash(f, key)==fullhash);
|
||||
assert((long)extraargs==(long)key.b);
|
||||
*value = (void*)(long)key.b;
|
||||
|
@ -120,39 +120,6 @@ static int fetch_forchain (CACHEFILE f, int UU(fd), CACHEKEY key, u_int32_t full
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void verify_cachetable_against_present (void) {
|
||||
int i;
|
||||
|
||||
|
@ -173,7 +140,7 @@ again:
|
|||
&v);
|
||||
if (r == -1) goto again;
|
||||
assert(r==0);
|
||||
r = toku_cachetable_unpin(my_present_items[i].cf, my_present_items[i].key, fullhash, CACHETABLE_CLEAN, test_object_size);
|
||||
r = toku_cachetable_unpin(my_present_items[i].cf, my_present_items[i].key, fullhash, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,10 +163,10 @@ static void test_chaining (void) {
|
|||
int fnum = i%N_FILES;
|
||||
//printf("%s:%d Add %d\n", __FILE__, __LINE__, i);
|
||||
u_int32_t fhash = toku_cachetable_hash(f[fnum], make_blocknum(i));
|
||||
r = toku_cachetable_put(f[fnum], make_blocknum(i), fhash, (void*)i, test_object_size, flush_forchain, pe_est_callback, pe_callback, (void*)i);
|
||||
r = toku_cachetable_put(f[fnum], make_blocknum(i), fhash, (void*)i, make_pair_attr(test_object_size), flush_forchain, def_pe_est_callback, def_pe_callback, def_cleaner_callback, (void*)i);
|
||||
assert(r==0);
|
||||
item_becomes_present(ct, f[fnum], make_blocknum(i));
|
||||
r = toku_cachetable_unpin(f[fnum], make_blocknum(i), fhash, CACHETABLE_CLEAN, test_object_size);
|
||||
r = toku_cachetable_unpin(f[fnum], make_blocknum(i), fhash, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
//print_ints();
|
||||
}
|
||||
|
@ -224,10 +191,11 @@ static void test_chaining (void) {
|
|||
NULL,
|
||||
flush_forchain,
|
||||
fetch_forchain,
|
||||
pe_est_callback,
|
||||
pe_callback,
|
||||
pf_req_callback,
|
||||
pf_callback,
|
||||
def_pe_est_callback,
|
||||
def_pe_callback,
|
||||
def_pf_req_callback,
|
||||
def_pf_callback,
|
||||
def_cleaner_callback,
|
||||
(void*)(long)whichkey.b,
|
||||
(void*)(long)whichkey.b
|
||||
);
|
||||
|
@ -235,7 +203,7 @@ static void test_chaining (void) {
|
|||
r = toku_cachetable_unpin(whichcf,
|
||||
whichkey,
|
||||
fhash,
|
||||
CACHETABLE_CLEAN, test_object_size);
|
||||
CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
}
|
||||
|
||||
|
@ -245,13 +213,13 @@ static void test_chaining (void) {
|
|||
// if i is a duplicate, cachetable_put will return -1
|
||||
// printf("%s:%d Add {%ld,%p}\n", __FILE__, __LINE__, i, f[fnum]);
|
||||
u_int32_t fhash = toku_cachetable_hash(f[fnum], make_blocknum(i));
|
||||
r = toku_cachetable_put(f[fnum], make_blocknum(i), fhash, (void*)i, test_object_size, flush_forchain, pe_est_callback, pe_callback, (void*)i);
|
||||
r = toku_cachetable_put(f[fnum], make_blocknum(i), fhash, (void*)i, make_pair_attr(test_object_size), flush_forchain, def_pe_est_callback, def_pe_callback, def_cleaner_callback, (void*)i);
|
||||
assert(r==0 || r==-1);
|
||||
if (r==0) {
|
||||
item_becomes_present(ct, f[fnum], make_blocknum(i));
|
||||
//print_ints();
|
||||
//cachetable_print_state(ct);
|
||||
r = toku_cachetable_unpin(f[fnum], make_blocknum(i), fhash, CACHETABLE_CLEAN, test_object_size);
|
||||
r = toku_cachetable_unpin(f[fnum], make_blocknum(i), fhash, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
|
||||
assert(r==0);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,28 +3,13 @@
|
|||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL f_ckpt __attribute__((__unused__))
|
||||
) {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp __attribute__((__unused__)),
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
|
@ -32,39 +17,6 @@ fetch (CACHEFILE f __attribute__((__unused__)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// test simple unpin and remove
|
||||
static void
|
||||
cachetable_unpin_and_remove_test (int n) {
|
||||
|
@ -89,7 +41,7 @@ cachetable_unpin_and_remove_test (int n) {
|
|||
// put the keys into the cachetable
|
||||
for (i=0; i<n; i++) {
|
||||
u_int32_t hi = toku_cachetable_hash(f1, make_blocknum(keys[i].b));
|
||||
r = toku_cachetable_put(f1, make_blocknum(keys[i].b), hi, (void *)(long) keys[i].b, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, make_blocknum(keys[i].b), hi, (void *)(long) keys[i].b, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
|
@ -150,15 +102,15 @@ cachetable_put_evict_remove_test (int n) {
|
|||
|
||||
// put 0, 1, 2, ... should evict 0
|
||||
for (i=0; i<n; i++) {
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi[i], (void *)(long)i, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi[i], (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi[i], CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi[i], CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
// get 0
|
||||
void *v; long s;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(0), hi[0], &v, &s, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, 0, 0);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(0), hi[0], &v, &s, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
|
||||
assert(r == 0);
|
||||
|
||||
// remove 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-simple-verify.c 34757 2011-09-14 19:12:42Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -9,75 +9,6 @@ CACHETABLE ct;
|
|||
// This test exposed a bug (#3970) caught only by Valgrind.
|
||||
// freed memory was being accessed by toku_cachetable_unpin_and_remove
|
||||
//
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = 8;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
static void *run_end_chkpt(void *arg) {
|
||||
assert(arg == NULL);
|
||||
int r = toku_cachetable_end_checkpoint(
|
||||
|
@ -107,18 +38,18 @@ run_test (void) {
|
|||
//void* v2;
|
||||
long s1;
|
||||
//long s2;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, def_flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
toku_cachetable_unpin(
|
||||
f1,
|
||||
make_blocknum(1),
|
||||
toku_cachetable_hash(f1, make_blocknum(1)),
|
||||
CACHETABLE_DIRTY,
|
||||
8
|
||||
make_pair_attr(8)
|
||||
);
|
||||
|
||||
// now this should mark the pair for checkpoint
|
||||
r = toku_cachetable_begin_checkpoint(ct, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, flush, fetch, pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, def_flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
|
||||
|
||||
toku_pthread_t mytid;
|
||||
r = toku_pthread_create(&mytid, NULL, run_end_chkpt, NULL);
|
||||
|
|
|
@ -2,45 +2,6 @@
|
|||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
||||
static void
|
||||
flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cachetable_unpin_test (int n) {
|
||||
|
@ -57,7 +18,7 @@ cachetable_unpin_test (int n) {
|
|||
for (i=1; i<=n; i++) {
|
||||
u_int32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, 1, flush, pe_est_callback, pe_callback, 0);
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
|
||||
assert(r == 0);
|
||||
assert(toku_cachefile_count_pinned(f1, 0) == i);
|
||||
|
||||
|
@ -73,7 +34,7 @@ cachetable_unpin_test (int n) {
|
|||
for (i=n; i>0; i--) {
|
||||
u_int32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r == 0);
|
||||
assert(toku_cachefile_count_pinned(f1, 0) == i-1);
|
||||
}
|
||||
|
@ -81,7 +42,7 @@ cachetable_unpin_test (int n) {
|
|||
toku_cachetable_verify(ct);
|
||||
|
||||
CACHEKEY k = make_blocknum(n+1);
|
||||
r = toku_cachetable_unpin(f1, k, toku_cachetable_hash(f1, k), CACHETABLE_CLEAN, 1);
|
||||
r = toku_cachetable_unpin(f1, k, toku_cachetable_hash(f1, k), CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
assert(r != 0);
|
||||
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ident "$Id: cachetable-clock-eviction.c 32940 2011-07-11 18:24:15Z leifwalsh $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2007-2011 Tokutek Inc. All rights reserved."
|
||||
#include "includes.h"
|
||||
#include "test.h"
|
||||
|
@ -14,8 +14,8 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
long s __attribute__((__unused__)),
|
||||
long* new_size __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
|
@ -27,56 +27,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static int
|
||||
pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
long bytes_to_free __attribute__((__unused__)),
|
||||
long* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int
|
||||
fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
long *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 1;
|
||||
*value = NULL;
|
||||
*sizep = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), long* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
cachetable_test (void) {
|
||||
|
@ -92,10 +42,10 @@ cachetable_test (void) {
|
|||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
for (int64_t i = 0; i < num_entries; i++) {
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), i, NULL, 1, flush, pe_est_callback, pe_callback, NULL);
|
||||
r = toku_cachetable_put(f1, make_blocknum(i), i, NULL, make_pair_attr(1), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, NULL);
|
||||
int curr_size = __sync_fetch_and_add(&total_size, 1);
|
||||
assert(curr_size <= test_limit + test_limit/2+1);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), i, CACHETABLE_DIRTY, 4);
|
||||
r = toku_cachetable_unpin(f1, make_blocknum(i), i, CACHETABLE_DIRTY, make_pair_attr(4));
|
||||
}
|
||||
|
||||
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
static TOKUTXN const null_txn = 0;
|
||||
static DB * const null_db = 0;
|
||||
|
||||
static int
|
||||
test_brt_cursor_keycompare(DB *UU(db), const DBT *a, const DBT *b) {
|
||||
static int test_brt_cursor_keycompare(DB *desc __attribute__((unused)), const DBT *a, const DBT *b) {
|
||||
return toku_keycompare(a->data, a->size, b->data, b->size);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ static TOKUTXN const null_txn = 0;
|
|||
static DB * const null_db = 0;
|
||||
|
||||
static int
|
||||
test_keycompare(DB *UU(db), const DBT *a, const DBT *b) {
|
||||
test_keycompare(DB* UU(desc), const DBT *a, const DBT *b) {
|
||||
return toku_keycompare(a->data, a->size, b->data, b->size);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
static TOKUTXN const null_txn = 0;
|
||||
static DB * const null_db = 0;
|
||||
|
||||
static int
|
||||
test_brt_cursor_keycompare(DB *UU(db), const DBT *a, const DBT *b) {
|
||||
static int test_brt_cursor_keycompare(DB *db __attribute__((unused)), const DBT *a, const DBT *b) {
|
||||
return toku_keycompare(a->data, a->size, b->data, b->size);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ insert_into_child_buffer(BRT brt, BRTNODE node, int childnum, int minkey, int ma
|
|||
unsigned int key = htonl(val);
|
||||
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
|
||||
DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
|
||||
toku_brt_append_to_child_buffer(brt, node, childnum, BRT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
|
||||
toku_brt_append_to_child_buffer(brt->compare_fun, NULL, node, childnum, BRT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
|
||||
node->max_msn_applied_to_node_on_disk = msn;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ append_leaf(BRT brt, BRTNODE leafnode, void *key, size_t keylen, void *val, size
|
|||
|
||||
bool made_change;
|
||||
u_int64_t workdone=0;
|
||||
toku_apply_cmd_to_leaf(brt, leafnode, &cmd, &made_change, &workdone, NULL, NULL);
|
||||
toku_apply_cmd_to_leaf(brt->compare_fun, brt->update_fun, &brt->h->descriptor, leafnode, &cmd, &made_change, &workdone, NULL, NULL);
|
||||
{
|
||||
int r = toku_brt_lookup(brt, &thekey, lookup_checkf, &pair);
|
||||
assert(r==0);
|
||||
|
@ -55,7 +55,7 @@ append_leaf(BRT brt, BRTNODE leafnode, void *key, size_t keylen, void *val, size
|
|||
}
|
||||
|
||||
BRT_MSG_S badcmd = { BRT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &badval } };
|
||||
toku_apply_cmd_to_leaf(brt, leafnode, &badcmd, &made_change, &workdone, NULL, NULL);
|
||||
toku_apply_cmd_to_leaf(brt->compare_fun, brt->update_fun, &brt->h->descriptor, leafnode, &badcmd, &made_change, &workdone, NULL, NULL);
|
||||
|
||||
|
||||
// message should be rejected for duplicate msn, row should still have original val
|
||||
|
@ -68,7 +68,7 @@ append_leaf(BRT brt, BRTNODE leafnode, void *key, size_t keylen, void *val, size
|
|||
// now verify that message with proper msn gets through
|
||||
msn = next_dummymsn();
|
||||
BRT_MSG_S cmd2 = { BRT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &val2 } };
|
||||
toku_apply_cmd_to_leaf(brt, leafnode, &cmd2, &made_change, &workdone, NULL, NULL);
|
||||
toku_apply_cmd_to_leaf(brt->compare_fun, brt->update_fun, &brt->h->descriptor, leafnode, &cmd2, &made_change, &workdone, NULL, NULL);
|
||||
|
||||
// message should be accepted, val should have new value
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ append_leaf(BRT brt, BRTNODE leafnode, void *key, size_t keylen, void *val, size
|
|||
// now verify that message with lesser (older) msn is rejected
|
||||
msn.msn = msn.msn - 10;
|
||||
BRT_MSG_S cmd3 = { BRT_INSERT, msn, xids_get_root_xids(), .u.id = { &thekey, &badval } };
|
||||
toku_apply_cmd_to_leaf(brt, leafnode, &cmd3, &made_change, &workdone, NULL, NULL);
|
||||
toku_apply_cmd_to_leaf(brt->compare_fun, brt->update_fun, &brt->h->descriptor, leafnode, &cmd3, &made_change, &workdone, NULL, NULL);
|
||||
|
||||
// message should be rejected, val should still have value in pair2
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ static TOKUTXN const null_txn = 0;
|
|||
static DB * const null_db = 0;
|
||||
static char fname[] = __FILE__ ".brt";
|
||||
|
||||
static int dummy_cmp(DB *e __attribute__((unused)),
|
||||
static int dummy_cmp(DB *db __attribute__((unused)),
|
||||
const DBT *a, const DBT *b) {
|
||||
int c;
|
||||
if (a->size > b->size) {
|
||||
|
@ -116,7 +116,7 @@ insert_random_message_to_leaf(BRT t, BRTNODE leaf, int childnum, BASEMENTNODE bl
|
|||
int r = apply_msg_to_leafentry(result, NULL, &memsize, &disksize, save, NULL, NULL);
|
||||
assert_zero(r);
|
||||
bool made_change;
|
||||
brt_leaf_put_cmd(t, blb, &BP_SUBTREE_EST(leaf, childnum), result, &made_change, NULL, NULL, NULL);
|
||||
brt_leaf_put_cmd(t->compare_fun, t->update_fun, NULL, blb, &BP_SUBTREE_EST(leaf, childnum), result, &made_change, NULL, NULL, NULL);
|
||||
if (msn.msn > blb->max_msn_applied.msn) {
|
||||
blb->max_msn_applied = msn;
|
||||
}
|
||||
|
@ -150,11 +150,11 @@ insert_same_message_to_leaves(BRT t, BRTNODE leaf1, BRTNODE leaf2, int childnum,
|
|||
int r = apply_msg_to_leafentry(result, NULL, &memsize, &disksize, save, NULL, NULL);
|
||||
assert_zero(r);
|
||||
bool made_change;
|
||||
brt_leaf_put_cmd(t, blb1, &BP_SUBTREE_EST(leaf1, childnum), result, &made_change, NULL, NULL, NULL);
|
||||
brt_leaf_put_cmd(t->compare_fun, t->update_fun, NULL, blb1, &BP_SUBTREE_EST(leaf1, childnum), result, &made_change, NULL, NULL, NULL);
|
||||
if (msn.msn > blb1->max_msn_applied.msn) {
|
||||
blb1->max_msn_applied = msn;
|
||||
}
|
||||
brt_leaf_put_cmd(t, blb2, &BP_SUBTREE_EST(leaf2, childnum), result, &made_change, NULL, NULL, NULL);
|
||||
brt_leaf_put_cmd(t->compare_fun, t->update_fun, NULL, blb2, &BP_SUBTREE_EST(leaf2, childnum), result, &made_change, NULL, NULL, NULL);
|
||||
if (msn.msn > blb2->max_msn_applied.msn) {
|
||||
blb2->max_msn_applied = msn;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ struct orthopush_flush_update_fun_extra {
|
|||
};
|
||||
|
||||
static int
|
||||
orthopush_flush_update_fun(DB *UU(db), const DBT *UU(key), const DBT *UU(old_val), const DBT *extra,
|
||||
orthopush_flush_update_fun(DB * UU(db), const DBT *UU(key), const DBT *UU(old_val), const DBT *extra,
|
||||
void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra) {
|
||||
struct orthopush_flush_update_fun_extra *e = extra->data;
|
||||
(*e->num_applications)++;
|
||||
|
@ -252,7 +252,7 @@ flush_to_internal(BRT t) {
|
|||
set_BNC(child, 0, child_bnc);
|
||||
BP_STATE(child, 0) = PT_AVAIL;
|
||||
|
||||
toku_bnc_flush_to_child(t, parent_bnc, child);
|
||||
toku_bnc_flush_to_child(t->compare_fun, t->update_fun, &t->h->descriptor, t->cf, parent_bnc, child);
|
||||
|
||||
int parent_messages_present[num_parent_messages];
|
||||
int child_messages_present[num_child_messages];
|
||||
|
@ -386,7 +386,7 @@ flush_to_internal_multiple(BRT t) {
|
|||
}
|
||||
}
|
||||
|
||||
toku_bnc_flush_to_child(t, parent_bnc, child);
|
||||
toku_bnc_flush_to_child(t->compare_fun, t->update_fun, &t->h->descriptor, t->cf, parent_bnc, child);
|
||||
|
||||
int total_messages = 0;
|
||||
for (i = 0; i < 8; ++i) {
|
||||
|
@ -550,7 +550,7 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) {
|
|||
for (i = 0; i < num_parent_messages; ++i) {
|
||||
if (!parent_messages_is_fresh[i]) {
|
||||
bool made_change;
|
||||
toku_apply_cmd_to_leaf(t, child, parent_messages[i], &made_change, NULL, NULL, NULL);
|
||||
toku_apply_cmd_to_leaf(t->compare_fun, t->update_fun, &t->h->descriptor, child, parent_messages[i], &made_change, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 8; ++i) {
|
||||
|
@ -571,7 +571,7 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) {
|
|||
}
|
||||
|
||||
if (use_flush) {
|
||||
toku_bnc_flush_to_child(t, parent_bnc, child);
|
||||
toku_bnc_flush_to_child(t->compare_fun, t->update_fun, &t->h->descriptor, t->cf, parent_bnc, child);
|
||||
destroy_nonleaf_childinfo(parent_bnc);
|
||||
} else {
|
||||
BRTNODE XMALLOC(parentnode);
|
||||
|
@ -768,7 +768,7 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) {
|
|||
if (dummy_cmp(NULL, parent_messages[i]->u.id.key, &childkeys[7]) <= 0 &&
|
||||
!parent_messages_is_fresh[i]) {
|
||||
bool made_change;
|
||||
toku_apply_cmd_to_leaf(t, child, parent_messages[i], &made_change, NULL, NULL, NULL);
|
||||
toku_apply_cmd_to_leaf(t->compare_fun, t->update_fun, &t->h->descriptor, child, parent_messages[i], &made_change, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 8; ++i) {
|
||||
|
@ -948,8 +948,8 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) {
|
|||
for (i = 0; i < num_parent_messages; ++i) {
|
||||
if (!parent_messages_is_fresh[i]) {
|
||||
bool made_change;
|
||||
toku_apply_cmd_to_leaf(t, child1, parent_messages[i], &made_change, NULL, NULL, NULL);
|
||||
toku_apply_cmd_to_leaf(t, child2, parent_messages[i], &made_change, NULL, NULL, NULL);
|
||||
toku_apply_cmd_to_leaf(t->compare_fun, t->update_fun, &t->h->descriptor, child1, parent_messages[i], &made_change, NULL, NULL, NULL);
|
||||
toku_apply_cmd_to_leaf(t->compare_fun, t->update_fun, &t->h->descriptor, child2, parent_messages[i], &made_change, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 8; ++i) {
|
||||
|
@ -963,7 +963,7 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) {
|
|||
}
|
||||
}
|
||||
|
||||
toku_bnc_flush_to_child(t, parent_bnc, child1);
|
||||
toku_bnc_flush_to_child(t->compare_fun, t->update_fun, &t->h->descriptor, t->cf, parent_bnc, child1);
|
||||
|
||||
BRTNODE XMALLOC(parentnode);
|
||||
BLOCKNUM parentblocknum = { 17 };
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
int found_dup = -1;
|
||||
|
||||
// simple compare func
|
||||
static int test_compare(DB *db, const DBT *dbta, const DBT *dbtb)
|
||||
static int test_compare(DB * UU(db), const DBT *dbta, const DBT *dbtb)
|
||||
{
|
||||
db = db;
|
||||
int a = *((int*)dbta->data);
|
||||
int b = *((int*)dbtb->data);
|
||||
if ( a<b ) return -1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* -*- mode: C; c-basic-offset: 4 -*- */
|
||||
#ident "$Id: test-kibbutz.c 34445 2011-09-06 02:59:44Z zardosht $"
|
||||
#ident "$Id$"
|
||||
#ident "Copyright (c) 2011 Tokutek Inc. All rights reserved."
|
||||
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
|
||||
|
||||
|
|
|
@ -112,6 +112,86 @@ brt_lookup_and_fail_nodup (BRT t, char *keystring)
|
|||
assert(pair.call_count==0);
|
||||
}
|
||||
|
||||
static UU() void fake_ydb_lock(void) {
|
||||
}
|
||||
|
||||
static UU() void fake_ydb_unlock(void) {
|
||||
}
|
||||
|
||||
static UU() void
|
||||
def_flush (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
void *v __attribute__((__unused__)),
|
||||
void *e __attribute__((__unused__)),
|
||||
PAIR_ATTR s __attribute__((__unused__)),
|
||||
PAIR_ATTR* new_size __attribute__((__unused__)),
|
||||
BOOL w __attribute__((__unused__)),
|
||||
BOOL keep __attribute__((__unused__)),
|
||||
BOOL c __attribute__((__unused__))
|
||||
) {
|
||||
}
|
||||
|
||||
static UU() void
|
||||
def_pe_est_callback(
|
||||
void* UU(brtnode_pv),
|
||||
long* bytes_freed_estimate,
|
||||
enum partial_eviction_cost *cost,
|
||||
void* UU(write_extraargs)
|
||||
)
|
||||
{
|
||||
*bytes_freed_estimate = 0;
|
||||
*cost = PE_CHEAP;
|
||||
}
|
||||
|
||||
static UU() int
|
||||
def_pe_callback (
|
||||
void *brtnode_pv __attribute__((__unused__)),
|
||||
PAIR_ATTR bytes_to_free __attribute__((__unused__)),
|
||||
PAIR_ATTR* bytes_freed,
|
||||
void* extraargs __attribute__((__unused__))
|
||||
)
|
||||
{
|
||||
*bytes_freed = bytes_to_free;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static UU() BOOL def_pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static UU() int def_pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), int UU(fd), PAIR_ATTR* UU(sizep)) {
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
static UU() int
|
||||
def_fetch (CACHEFILE f __attribute__((__unused__)),
|
||||
int UU(fd),
|
||||
CACHEKEY k __attribute__((__unused__)),
|
||||
u_int32_t fullhash __attribute__((__unused__)),
|
||||
void **value __attribute__((__unused__)),
|
||||
PAIR_ATTR *sizep __attribute__((__unused__)),
|
||||
int *dirtyp,
|
||||
void *extraargs __attribute__((__unused__))
|
||||
) {
|
||||
*dirtyp = 0;
|
||||
*value = NULL;
|
||||
*sizep = make_pair_attr(8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static UU() int
|
||||
def_cleaner_callback(
|
||||
void* UU(brtnode_pv),
|
||||
BLOCKNUM UU(blocknum),
|
||||
u_int32_t UU(fullhash),
|
||||
void* UU(extraargs)
|
||||
)
|
||||
{
|
||||
assert(FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int verbose=0;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ static int const nodesize = 1<<12, basementnodesize = 1<<9;
|
|||
static int const count = 1000;
|
||||
|
||||
static int
|
||||
string_cmp(DB *UU(db), const DBT *a, const DBT *b)
|
||||
string_cmp(DB* UU(db), const DBT *a, const DBT *b)
|
||||
{
|
||||
return strcmp(a->data, b->data);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ test_split_on_boundary(void)
|
|||
BRTNODE nodea, nodeb;
|
||||
DBT splitk;
|
||||
// if we haven't done it right, we should hit the assert in the top of move_leafentries
|
||||
brtleaf_split(brt, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
|
||||
toku_unpin_brtnode(brt, nodeb);
|
||||
r = toku_close_brt(brt, NULL); assert(r == 0);
|
||||
|
@ -193,7 +193,7 @@ test_split_with_everything_on_the_left(void)
|
|||
BRTNODE nodea, nodeb;
|
||||
DBT splitk;
|
||||
// if we haven't done it right, we should hit the assert in the top of move_leafentries
|
||||
brtleaf_split(brt, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
|
||||
toku_unpin_brtnode(brt, nodeb);
|
||||
r = toku_close_brt(brt, NULL); assert(r == 0);
|
||||
|
@ -287,7 +287,7 @@ test_split_on_boundary_of_last_node(void)
|
|||
BRTNODE nodea, nodeb;
|
||||
DBT splitk;
|
||||
// if we haven't done it right, we should hit the assert in the top of move_leafentries
|
||||
brtleaf_split(brt, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
|
||||
toku_unpin_brtnode(brt, nodeb);
|
||||
r = toku_close_brt(brt, NULL); assert(r == 0);
|
||||
|
@ -388,7 +388,7 @@ test_split_at_begin(void)
|
|||
BRTNODE nodea, nodeb;
|
||||
DBT splitk;
|
||||
// if we haven't done it right, we should hit the assert in the top of move_leafentries
|
||||
brtleaf_split(brt, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
|
||||
toku_unpin_brtnode(brt, nodeb);
|
||||
r = toku_close_brt(brt, NULL); assert(r == 0);
|
||||
|
@ -478,7 +478,7 @@ test_split_at_end(void)
|
|||
BRTNODE nodea, nodeb;
|
||||
DBT splitk;
|
||||
// if we haven't done it right, we should hit the assert in the top of move_leafentries
|
||||
brtleaf_split(brt, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
|
||||
|
||||
toku_unpin_brtnode(brt, nodeb);
|
||||
r = toku_close_brt(brt, NULL); assert(r == 0);
|
||||
|
|
|
@ -68,7 +68,7 @@ insert_into_child_buffer(BRT brt, BRTNODE node, int childnum, int minkey, int ma
|
|||
unsigned int key = htonl(val);
|
||||
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
|
||||
DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
|
||||
toku_brt_append_to_child_buffer(brt, node, childnum, BRT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
|
||||
toku_brt_append_to_child_buffer(brt->compare_fun, NULL, node, childnum, BRT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
|
||||
|
||||
// Create bad tree (don't do following):
|
||||
// node->max_msn_applied_to_node = msn;
|
||||
|
|
|
@ -46,17 +46,6 @@ populate_leaf(BRTNODE leafnode, int seq, int n, int *minkey, int *maxkey) {
|
|||
*maxkey = htonl(seq + n - 1);
|
||||
}
|
||||
|
||||
static UU() void
|
||||
insert_into_child_buffer(BRT brt, BRTNODE node, int childnum, int minkey, int maxkey) {
|
||||
for (unsigned int val = htonl(minkey); val <= htonl(maxkey); val++) {
|
||||
unsigned int key = htonl(val);
|
||||
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
|
||||
DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
|
||||
MSN msn = next_dummymsn();
|
||||
toku_brt_append_to_child_buffer(brt, node, childnum, BRT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
|
||||
}
|
||||
}
|
||||
|
||||
static BRTNODE
|
||||
make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey, int *maxkey) {
|
||||
BRTNODE node;
|
||||
|
|
|
@ -46,17 +46,6 @@ populate_leaf(BRTNODE leafnode, int seq, int n, int *minkey, int *maxkey) {
|
|||
*maxkey = htonl(seq + n - 1);
|
||||
}
|
||||
|
||||
static UU() void
|
||||
insert_into_child_buffer(BRT brt, BRTNODE node, int childnum, int minkey, int maxkey) {
|
||||
for (unsigned int val = htonl(minkey); val <= htonl(maxkey); val++) {
|
||||
unsigned int key = htonl(val);
|
||||
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
|
||||
DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
|
||||
MSN msn = next_dummymsn();
|
||||
toku_brt_append_to_child_buffer(brt, node, childnum, BRT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
|
||||
}
|
||||
}
|
||||
|
||||
static BRTNODE
|
||||
make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey, int *maxkey) {
|
||||
BRTNODE node;
|
||||
|
|
|
@ -56,7 +56,7 @@ insert_into_child_buffer(BRT brt, BRTNODE node, int childnum, int minkey, int ma
|
|||
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
|
||||
DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
|
||||
MSN msn = next_dummymsn();
|
||||
toku_brt_append_to_child_buffer(brt, node, childnum, BRT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
|
||||
toku_brt_append_to_child_buffer(brt->compare_fun, NULL, node, childnum, BRT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,17 +46,6 @@ populate_leaf(BRTNODE leafnode, int seq, int n, int *minkey, int *maxkey) {
|
|||
*maxkey = htonl(seq + n - 1);
|
||||
}
|
||||
|
||||
static UU() void
|
||||
insert_into_child_buffer(BRT brt, BRTNODE node, int childnum, int minkey, int maxkey) {
|
||||
for (unsigned int val = htonl(minkey); val <= htonl(maxkey); val++) {
|
||||
unsigned int key = htonl(val);
|
||||
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
|
||||
DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
|
||||
MSN msn = next_dummymsn();
|
||||
toku_brt_append_to_child_buffer(brt, node, childnum, BRT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval);
|
||||
}
|
||||
}
|
||||
|
||||
static BRTNODE
|
||||
make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey, int *maxkey) {
|
||||
BRTNODE node;
|
||||
|
|
|
@ -37,7 +37,7 @@ typedef enum {
|
|||
TOKU_LT_INCONSISTENT=-1, /**< The member data are in an inconsistent state */
|
||||
} TOKU_LT_ERROR;
|
||||
|
||||
typedef int (*toku_dbt_cmp)(DB*,const DBT*,const DBT*);
|
||||
typedef int (*toku_dbt_cmp)(DB *,const DBT*,const DBT*);
|
||||
|
||||
/** Convert error codes into a human-readable error message */
|
||||
char* toku_lt_strerror(TOKU_LT_ERROR r /**< Error code */)
|
||||
|
@ -105,7 +105,7 @@ struct __toku_lock_tree {
|
|||
/** Function to retrieve the key compare function from the database. */
|
||||
toku_dbt_cmp (*get_compare_fun_from_db)(DB*);
|
||||
/** The key compare function */
|
||||
int (*compare_fun)(DB*,const DBT*,const DBT*);
|
||||
toku_dbt_cmp compare_fun;
|
||||
/** The panic function */
|
||||
int (*panic)(DB*, int);
|
||||
/** The number of references held by DB instances and transactions to this lock tree*/
|
||||
|
|
|
@ -266,6 +266,7 @@ BDB_DONTRUN_TESTS = \
|
|||
test_dupsort_set_range_reverse \
|
||||
test_large_update_broadcast_small_cachetable \
|
||||
test_logflush \
|
||||
test_redirect_func \
|
||||
test_stress1 \
|
||||
test_stress2 \
|
||||
test_stress3 \
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue