Commit 40c9499d authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#4013 change the lock wait timeout from microseconds to milliseconds closes[t:4013]

git-svn-id: file:///svn/toku/tokudb@35555 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4b6e1f0b
......@@ -345,8 +345,8 @@ struct __toku_db_env {
int (*set_lk_max_memory) (DB_ENV *env, uint64_t max);
int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max);
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_usec);
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_usec);
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];
char __toku_dummy1[64];
void *api1_internal; /* 32-bit offset=212 size=4, 64=bit offset=360 size=8 */
......
......@@ -347,8 +347,8 @@ struct __toku_db_env {
int (*set_lk_max_memory) (DB_ENV *env, uint64_t max);
int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max);
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_usec);
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_usec);
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];
char __toku_dummy1[96];
void *api1_internal; /* 32-bit offset=244 size=4, 64=bit offset=392 size=8 */
......
......@@ -347,8 +347,8 @@ struct __toku_db_env {
int (*set_lk_max_memory) (DB_ENV *env, uint64_t max);
int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max);
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_usec);
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_usec);
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];
char __toku_dummy1[128];
void *api1_internal; /* 32-bit offset=336 size=4, 64=bit offset=544 size=8 */
......
......@@ -347,8 +347,8 @@ struct __toku_db_env {
int (*set_lk_max_memory) (DB_ENV *env, uint64_t max);
int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max);
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_usec);
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_usec);
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];
char __toku_dummy1[128];
void *api1_internal; /* 32-bit offset=336 size=4, 64=bit offset=544 size=8 */
......
......@@ -348,8 +348,8 @@ struct __toku_db_env {
int (*set_lk_max_memory) (DB_ENV *env, uint64_t max);
int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max);
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_usec);
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_usec);
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];
char __toku_dummy1[144];
void *api1_internal; /* 32-bit offset=356 size=4, 64=bit offset=568 size=8 */
......
......@@ -652,8 +652,8 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
"int (*set_lk_max_memory) (DB_ENV *env, uint64_t max)",
"int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max)",
"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_usec)",
"int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_usec)",
"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)",
NULL};
print_struct("db_env", 1, db_env_fields32, db_env_fields64, sizeof(db_env_fields32)/sizeof(db_env_fields32[0]), extra);
}
......
......@@ -348,8 +348,8 @@ struct __toku_db_env {
int (*set_lk_max_memory) (DB_ENV *env, uint64_t max);
int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max);
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_usec);
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_usec);
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 *api1_internal;
int (*close) (DB_ENV *, u_int32_t);
int (*dbremove) (DB_ENV *, DB_TXN *, const char *, const char *, u_int32_t);
......
......@@ -348,8 +348,8 @@ struct __toku_db_env {
int (*set_lk_max_memory) (DB_ENV *env, uint64_t max);
int (*get_lk_max_memory) (DB_ENV *env, uint64_t *max);
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_usec);
int (*get_lock_timeout) (DB_ENV *env, uint64_t *lock_wait_time_usec);
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 *api1_internal;
int (*close) (DB_ENV *, u_int32_t);
int (*dbremove) (DB_ENV *, DB_TXN *, const char *, const char *, u_int32_t);
......
......@@ -2650,17 +2650,17 @@ toku_lt_get_lock_request_conflicts(toku_lock_tree *tree, toku_lock_request *lock
}
void
toku_ltm_set_lock_wait_time(toku_ltm *mgr, uint64_t lock_wait_time_usec) {
if (lock_wait_time_usec == UINT64_MAX)
toku_ltm_set_lock_wait_time(toku_ltm *mgr, uint64_t lock_wait_time_msec) {
if (lock_wait_time_msec == UINT64_MAX)
mgr->lock_wait_time = max_timeval;
else
mgr->lock_wait_time = (struct timeval) { lock_wait_time_usec / 1000000, lock_wait_time_usec % 1000000 };
mgr->lock_wait_time = (struct timeval) { lock_wait_time_msec / 1000, (lock_wait_time_msec % 1000) * 1000 };
}
void
toku_ltm_get_lock_wait_time(toku_ltm *mgr, uint64_t *lock_wait_time_usec) {
toku_ltm_get_lock_wait_time(toku_ltm *mgr, uint64_t *lock_wait_time_msec) {
if (mgr->lock_wait_time.tv_sec == max_timeval.tv_sec && mgr->lock_wait_time.tv_usec == max_timeval.tv_usec)
*lock_wait_time_usec = UINT64_MAX;
*lock_wait_time_msec = UINT64_MAX;
else
*lock_wait_time_usec = mgr->lock_wait_time.tv_sec * 1000000 + mgr->lock_wait_time.tv_usec;
*lock_wait_time_msec = mgr->lock_wait_time.tv_sec * 1000 + mgr->lock_wait_time.tv_usec / 1000;
}
......@@ -615,11 +615,11 @@ void toku_ltm_lock_mutex(toku_ltm *mgr);
// unlock the lock tree
void toku_ltm_unlock_mutex(toku_ltm *mgr);
// set the default lock timeout. units are microseconds.
void toku_ltm_set_lock_wait_time(toku_ltm *mgr, uint64_t lock_wait_time_usec);
// set the default lock timeout. units are milliseconds
void toku_ltm_set_lock_wait_time(toku_ltm *mgr, uint64_t lock_wait_time_msec);
// get the default lock timeout
void toku_ltm_get_lock_wait_time(toku_ltm *mgr, uint64_t *lock_wait_time_usec);
void toku_ltm_get_lock_wait_time(toku_ltm *mgr, uint64_t *lock_wait_time_msec);
#if defined(__cplusplus)
}
......
......@@ -62,7 +62,7 @@ int main(int argc, const char *argv[]) {
r = write_lock(lt, txn_a, "L"); assert(r == 0);
for (int t = 1; t < 10; t++) {
toku_ltm_set_lock_wait_time(ltm, t * 1000000);
toku_ltm_set_lock_wait_time(ltm, t * 1000);
r = read_lock(lt, txn_b, "L");
assert(r == DB_LOCK_NOTGRANTED);
r = write_lock(lt, txn_b, "L");
......
......@@ -38,12 +38,12 @@ int main(int argc, const char *argv[]) {
toku_ltm_get_lock_wait_time(ltm, &the_wait_time);
assert(the_wait_time == 0);
target_wait_time = 1*1000000 + 0;
target_wait_time = 1*1000 + 0;
toku_ltm_set_lock_wait_time(ltm, target_wait_time);
toku_ltm_get_lock_wait_time(ltm, &the_wait_time);
assert(the_wait_time == target_wait_time);
target_wait_time = 2*1000000 + 3;
target_wait_time = 2*1000 + 3;
toku_ltm_set_lock_wait_time(ltm, target_wait_time);
toku_ltm_get_lock_wait_time(ltm, &the_wait_time);
assert(the_wait_time == target_wait_time);
......
......@@ -39,7 +39,7 @@ main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic, get_compare_fun_from_db, toku_malloc, toku_free, toku_realloc);
assert(r == 0 && ltm);
toku_ltm_set_lock_wait_time(ltm, 5000000);
toku_ltm_set_lock_wait_time(ltm, 5000);
toku_pthread_mutex_t my_mutex = TOKU_PTHREAD_MUTEX_INITIALIZER;
toku_ltm_set_mutex(ltm, &my_mutex);
......
......@@ -69,7 +69,7 @@ int main(int argc, const char *argv[]) {
r = write_lock(ltm, lt, txn_a, "L"); assert(r == 0);
for (int t = 1; t < 10; t++) {
toku_ltm_set_lock_wait_time(ltm, t * 1000000);
toku_ltm_set_lock_wait_time(ltm, t * 1000);
r = read_lock(ltm, lt, txn_b, "L");
assert(r == DB_LOCK_NOTGRANTED);
r = write_lock(ltm, lt, txn_b, "L");
......
......@@ -1762,29 +1762,29 @@ locked_env_set_redzone(DB_ENV *env, int redzone) {
}
static int
env_get_lock_timeout(DB_ENV *env, uint64_t *lock_timeout_usec) {
toku_ltm_get_lock_wait_time(env->i->ltm, lock_timeout_usec);
env_get_lock_timeout(DB_ENV *env, uint64_t *lock_timeout_msec) {
toku_ltm_get_lock_wait_time(env->i->ltm, lock_timeout_msec);
return 0;
}
static int
locked_env_get_lock_timeout(DB_ENV *env, uint64_t *lock_timeout_usec) {
locked_env_get_lock_timeout(DB_ENV *env, uint64_t *lock_timeout_msec) {
toku_ydb_lock();
int r = env_get_lock_timeout(env, lock_timeout_usec);
int r = env_get_lock_timeout(env, lock_timeout_msec);
toku_ydb_unlock();
return r;
}
static int
env_set_lock_timeout(DB_ENV *env, uint64_t lock_timeout_usec) {
toku_ltm_set_lock_wait_time(env->i->ltm, lock_timeout_usec);
env_set_lock_timeout(DB_ENV *env, uint64_t lock_timeout_msec) {
toku_ltm_set_lock_wait_time(env->i->ltm, lock_timeout_msec);
return 0;
}
static int
locked_env_set_lock_timeout(DB_ENV *env, uint64_t lock_timeout_usec) {
locked_env_set_lock_timeout(DB_ENV *env, uint64_t lock_timeout_msec) {
toku_ydb_lock();
int r = env_set_lock_timeout(env, lock_timeout_usec);
int r = env_set_lock_timeout(env, lock_timeout_msec);
toku_ydb_unlock();
return r;
}
......
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