Commit c2d7fd1f authored by Yoni Fogel's avatar Yoni Fogel

Fixes #1686 Added ydb-level functions to get/set interval for automatic recurring checkpointing.

git-svn-id: file:///svn/toku/tokudb@11298 c7de825b-a66e-492c-adef-691d508d4ae1
parent 82a33bb3
......@@ -125,55 +125,56 @@ typedef enum {
struct __toku_db_env {
struct __toku_db_env_internal *i;
#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 (*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 (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
void* __toku_dummy0[2];
void *app_private; /* 32-bit offset=36 size=4, 64=bit offset=72 size=8 */
void* __toku_dummy1[27];
char __toku_dummy2[64];
void* __toku_dummy0[27];
char __toku_dummy1[64];
void *api1_internal; /* 32-bit offset=212 size=4, 64=bit offset=360 size=8 */
void* __toku_dummy3[7];
void* __toku_dummy2[7];
int (*close) (DB_ENV *, u_int32_t); /* 32-bit offset=244 size=4, 64=bit offset=424 size=8 */
void* __toku_dummy4[2];
void* __toku_dummy3[2];
void (*err) (const DB_ENV *, int, const char *, ...); /* 32-bit offset=256 size=4, 64=bit offset=448 size=8 */
void* __toku_dummy5[1];
void* __toku_dummy4[1];
int (*open) (DB_ENV *, const char *, u_int32_t, int); /* 32-bit offset=264 size=4, 64=bit offset=464 size=8 */
void* __toku_dummy6[1];
void* __toku_dummy5[1];
int (*set_data_dir) (DB_ENV *, const char *); /* 32-bit offset=272 size=4, 64=bit offset=480 size=8 */
void* __toku_dummy7[3];
void* __toku_dummy6[3];
void (*set_errcall) (DB_ENV *, void (*)(const char *, char *)); /* 32-bit offset=288 size=4, 64=bit offset=512 size=8 */
void (*set_errfile) (DB_ENV *, FILE*); /* 32-bit offset=292 size=4, 64=bit offset=520 size=8 */
void (*set_errpfx) (DB_ENV *, const char *); /* 32-bit offset=296 size=4, 64=bit offset=528 size=8 */
void* __toku_dummy8[1];
void* __toku_dummy7[1];
int (*set_flags) (DB_ENV *, u_int32_t, int); /* 32-bit offset=304 size=4, 64=bit offset=544 size=8 */
void* __toku_dummy9[4];
void* __toku_dummy8[4];
int (*set_tmp_dir) (DB_ENV *, const char *); /* 32-bit offset=324 size=4, 64=bit offset=584 size=8 */
int (*set_verbose) (DB_ENV *, u_int32_t, int); /* 32-bit offset=328 size=4, 64=bit offset=592 size=8 */
void* __toku_dummy10[1];
void* __toku_dummy9[1];
int (*set_lg_bsize) (DB_ENV *, u_int32_t); /* 32-bit offset=336 size=4, 64=bit offset=608 size=8 */
int (*set_lg_dir) (DB_ENV *, const char *); /* 32-bit offset=340 size=4, 64=bit offset=616 size=8 */
int (*set_lg_max) (DB_ENV *, u_int32_t); /* 32-bit offset=344 size=4, 64=bit offset=624 size=8 */
void* __toku_dummy11[1];
void* __toku_dummy10[1];
int (*log_archive) (DB_ENV *, char **[], u_int32_t); /* 32-bit offset=352 size=4, 64=bit offset=640 size=8 */
void* __toku_dummy12[2];
void* __toku_dummy11[2];
int (*log_flush) (DB_ENV *, const DB_LSN *); /* 32-bit offset=364 size=4, 64=bit offset=664 size=8 */
void* __toku_dummy13[4];
void* __toku_dummy12[4];
int (*set_lk_detect) (DB_ENV *, u_int32_t); /* 32-bit offset=384 size=4, 64=bit offset=704 size=8 */
int (*set_lk_max) (DB_ENV *, u_int32_t); /* 32-bit offset=388 size=4, 64=bit offset=712 size=8 */
int (*set_lk_max_locks) (DB_ENV *, u_int32_t); /* 32-bit offset=392 size=4, 64=bit offset=720 size=8 */
void* __toku_dummy14[14];
void* __toku_dummy13[14];
int (*set_cachesize) (DB_ENV *, u_int32_t, u_int32_t, int); /* 32-bit offset=452 size=4, 64=bit offset=840 size=8 */
void* __toku_dummy15[21];
void* __toku_dummy14[21];
int (*txn_begin) (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t); /* 32-bit offset=540 size=4, 64=bit offset=1016 size=8 */
int (*txn_checkpoint) (DB_ENV *, u_int32_t, u_int32_t, u_int32_t); /* 32-bit offset=544 size=4, 64=bit offset=1024 size=8 */
void* __toku_dummy16[2];
void* __toku_dummy15[2];
int (*txn_stat) (DB_ENV *, DB_TXN_STAT **, u_int32_t); /* 32-bit offset=556 size=4, 64=bit offset=1048 size=8 */
void* __toku_dummy17[2]; /* Padding at the end */
char __toku_dummy18[8]; /* Padding at the end */
void* __toku_dummy16[2]; /* Padding at the end */
char __toku_dummy17[8]; /* Padding at the end */
};
struct __toku_db_key_range {
double less; /* 32-bit offset=0 size=8, 64=bit offset=0 size=8 */
......
......@@ -127,13 +127,15 @@ typedef enum {
struct __toku_db_env {
struct __toku_db_env_internal *i;
#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 (*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 (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
void* __toku_dummy0[4];
void* __toku_dummy0[2];
void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */
void* __toku_dummy1[25];
char __toku_dummy2[96];
......
......@@ -128,13 +128,15 @@ typedef enum {
struct __toku_db_env {
struct __toku_db_env_internal *i;
#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 (*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 (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
void* __toku_dummy0[4];
void* __toku_dummy0[2];
void *app_private; /* 32-bit offset=44 size=4, 64=bit offset=88 size=8 */
void* __toku_dummy1[40];
char __toku_dummy2[128];
......
......@@ -128,13 +128,15 @@ typedef enum {
struct __toku_db_env {
struct __toku_db_env_internal *i;
#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 (*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 (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
void* __toku_dummy0[6];
void* __toku_dummy0[4];
void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */
void* __toku_dummy1[38];
char __toku_dummy2[128];
......
......@@ -130,13 +130,15 @@ typedef enum {
struct __toku_db_env {
struct __toku_db_env_internal *i;
#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 (*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 (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */;
void* __toku_dummy0[6];
void* __toku_dummy0[4];
void *app_private; /* 32-bit offset=52 size=4, 64=bit offset=104 size=8 */
void* __toku_dummy1[39];
char __toku_dummy2[144];
......
......@@ -347,6 +347,8 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
assert(sizeof(db_env_fields32)==sizeof(db_env_fields64));
{
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 (*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 */",
......
......@@ -130,6 +130,8 @@ typedef enum {
struct __toku_db_env {
struct __toku_db_env_internal *i;
#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 (*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 */;
......
......@@ -130,6 +130,8 @@ typedef enum {
struct __toku_db_env {
struct __toku_db_env_internal *i;
#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 (*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 */;
......
......@@ -217,6 +217,10 @@ int toku_set_checkpoint_period (CACHETABLE ct, u_int32_t new_period) {
return toku_minicron_change_period(&ct->checkpointer, new_period);
}
u_int32_t toku_get_checkpoint_period (CACHETABLE ct) {
return toku_minicron_get_period(&ct->checkpointer);
}
int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_lsn), TOKULOGGER logger) {
#if defined __linux__
{
......
......@@ -3,6 +3,11 @@
#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."
#ident "$Id$"
int toku_set_checkpoint_period(CACHETABLE ct, u_int32_t new_period);
u_int32_t toku_get_checkpoint_period(CACHETABLE ct);
//Effect: Change [end checkpoint (n) - begin checkpoint (n+1)] delay to
// new_period seconds. 0 means disable.
/******
*
* NOTE: multi_operation_lock is highest level lock
......
......@@ -113,6 +113,15 @@ toku_minicron_change_period(struct minicron *p, u_int32_t new_period)
return 0;
}
u_int32_t
toku_minicron_get_period(struct minicron *p)
{
int r = toku_pthread_mutex_lock(&p->mutex); assert(r==0);
u_int32_t retval = p->period_in_seconds;
r = toku_pthread_mutex_unlock(&p->mutex); assert(r==0);
return retval;
}
int
toku_minicron_shutdown(struct minicron *p) {
int r = toku_pthread_mutex_lock(&p->mutex); assert(r==0);
......
......@@ -34,5 +34,6 @@ struct minicron {
int toku_minicron_setup (struct minicron *s, u_int32_t period_in_seconds, int(*f)(void *), void *arg);
int toku_minicron_change_period(struct minicron *p, u_int32_t new_period);
u_int32_t toku_minicron_get_period(struct minicron *p);
int toku_minicron_shutdown(struct minicron *p);
BOOL toku_minicron_has_been_shutdown(struct minicron *p);
......@@ -789,6 +789,36 @@ static int locked_env_txn_stat(DB_ENV * env, DB_TXN_STAT ** statp, u_int32_t fla
toku_ydb_lock(); int r = toku_env_txn_stat(env, statp, flags); toku_ydb_unlock(); return r;
}
static int
env_checkpointing_set_period(DB_ENV * env, u_int32_t seconds) {
HANDLE_PANICKED_ENV(env);
int r;
if (!env_opened(env)) r = EINVAL;
else
r = toku_set_checkpoint_period(env->i->cachetable, seconds);
return r;
}
static int
locked_env_checkpointing_set_period(DB_ENV * env, u_int32_t seconds) {
toku_ydb_lock(); int r = env_checkpointing_set_period(env, seconds); toku_ydb_unlock(); return r;
}
static int
env_checkpointing_get_period(DB_ENV * env, u_int32_t *seconds) {
HANDLE_PANICKED_ENV(env);
int r = 0;
if (!env_opened(env)) r = EINVAL;
else
*seconds = toku_get_checkpoint_period(env->i->cachetable);
return r;
}
static int
locked_env_checkpointing_get_period(DB_ENV * env, u_int32_t *seconds) {
toku_ydb_lock(); int r = env_checkpointing_get_period(env, seconds); toku_ydb_unlock(); return r;
}
static int
env_checkpointing_postpone(DB_ENV * env) {
HANDLE_PANICKED_ENV(env);
......@@ -882,6 +912,8 @@ static int toku_env_create(DB_ENV ** envp, u_int32_t flags) {
result->err = (void (*)(const DB_ENV * env, int error, const char *fmt, ...)) toku_locked_env_err;
result->set_default_bt_compare = locked_env_set_default_bt_compare;
result->set_default_dup_compare = locked_env_set_default_dup_compare;
result->checkpointing_set_period = locked_env_checkpointing_set_period;
result->checkpointing_get_period = locked_env_checkpointing_get_period;
result->checkpointing_postpone = env_checkpointing_postpone;
result->checkpointing_resume = env_checkpointing_resume;
result->checkpointing_begin_atomic_operation = env_checkpointing_begin_atomic_operation;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment