diff options
author | Sergei Golubchik <serg@mysql.com> | 2008-07-29 16:10:24 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mysql.com> | 2008-07-29 16:10:24 +0200 |
commit | cca54d3e69b1b07ca49c83f0e93eb74cc3cca63f (patch) | |
tree | 8fc9687df3d7995af94f6a6df09bc646da26592e /storage/maria | |
parent | 8848f6bd2853753e38125bc721a1a68c8c086744 (diff) | |
download | mariadb-git-cca54d3e69b1b07ca49c83f0e93eb74cc3cca63f.tar.gz |
WL#3064 - waiting threads - wait-for graph and deadlock detection
client/mysqltest.c:
compiler warnings
configure.in:
remove old tests for unused programs
disable the use of gcc built-ins if smp assembler atomics were selected explictily.
add waiting_threads.o to THREAD_LOBJECTS
include/lf.h:
replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
scheduler.
constructor/destructor in lf-alloc
include/my_pthread.h:
shuffle set_timespec/set_timespec_nsec macros a bit to be able to fill
several timeout structures with only one my_getsystime() call
include/waiting_threads.h:
waiting threads - wait-for graph and deadlock detection
mysys/Makefile.am:
add waiting_threads.c
mysys/lf_alloc-pin.c:
replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
scheduler.
constructor/destructor in lf-alloc
mysys/lf_hash.c:
constructor/destructor in lf-alloc
mysys/my_thr_init.c:
remember end-of-stack pointer in the mysys_var
mysys/waiting_threads.c:
waiting threads - wait-for graph and deadlock detection
storage/maria/ha_maria.cc:
replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
scheduler.
storage/maria/ma_commit.c:
replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
scheduler.
storage/maria/trnman.c:
replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
scheduler.
storage/maria/trnman_public.h:
replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
scheduler.
storage/maria/unittest/trnman-t.c:
replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
scheduler.
unittest/mysys/Makefile.am:
add waiting_threads-t
unittest/mysys/lf-t.c:
factor out the common code for multi-threaded stress unit tests
move lf tests to a separate file
unittest/mysys/my_atomic-t.c:
factor out the common code for multi-threaded stress unit tests
move lf tests to a separate file
unittest/mysys/thr_template.c:
factor out the common code for multi-threaded stress unit tests
unittest/mysys/waiting_threads-t.c:
wt tests
Diffstat (limited to 'storage/maria')
-rw-r--r-- | storage/maria/ha_maria.cc | 10 | ||||
-rw-r--r-- | storage/maria/ma_commit.c | 4 | ||||
-rw-r--r-- | storage/maria/trnman.c | 7 | ||||
-rw-r--r-- | storage/maria/trnman_public.h | 2 | ||||
-rw-r--r-- | storage/maria/unittest/trnman-t.c | 9 |
5 files changed, 13 insertions, 19 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 5e9554b19d8..e4d91257a43 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2246,10 +2246,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) /* Start of new statement */ if (!trn) /* no transaction yet - open it now */ { - trn= trnman_new_trn(& thd->mysys_var->mutex, - & thd->mysys_var->suspend, - thd->thread_stack + STACK_DIRECTION * - (my_thread_stack_size - STACK_MIN_SIZE)); + trn= trnman_new_trn(& thd->mysys_var->mutex, & thd->mysys_var->suspend); if (unlikely(!trn)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); THD_TRN= trn; @@ -2389,10 +2386,7 @@ int ha_maria::implicit_commit(THD *thd) tables may be under LOCK TABLES, and so they will start the next statement assuming they have a trn (see ha_maria::start_stmt()). */ - trn= trnman_new_trn(& thd->mysys_var->mutex, - & thd->mysys_var->suspend, - thd->thread_stack + STACK_DIRECTION * - (my_thread_stack_size - STACK_MIN_SIZE)); + trn= trnman_new_trn(& thd->mysys_var->mutex, & thd->mysys_var->suspend); /* This is just a commit, tables stay locked if they were: */ trnman_reset_locked_tables(trn, locked_tables); THD_TRN= trn; diff --git a/storage/maria/ma_commit.c b/storage/maria/ma_commit.c index e7c82d651c5..02a07fe5f15 100644 --- a/storage/maria/ma_commit.c +++ b/storage/maria/ma_commit.c @@ -108,9 +108,7 @@ int maria_begin(MARIA_HA *info) { TRN *trn; struct st_my_thread_var *mysys_var= my_thread_var; - trn= trnman_new_trn(&mysys_var->mutex, - &mysys_var->suspend, - (char*) &mysys_var + STACK_DIRECTION *1024*128); + trn= trnman_new_trn(&mysys_var->mutex, &mysys_var->suspend); if (unlikely(!trn)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); diff --git a/storage/maria/trnman.c b/storage/maria/trnman.c index 1c2385e9476..ad742c132e0 100644 --- a/storage/maria/trnman.c +++ b/storage/maria/trnman.c @@ -260,8 +260,7 @@ static void set_short_trid(TRN *trn) mutex and cond will be used for lock waits */ -TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond, - void *stack_end) +TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond) { TRN *trn; DBUG_ENTER("trnman_new_trn"); @@ -308,7 +307,7 @@ TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond, } trnman_allocated_transactions++; } - trn->pins= lf_hash_get_pins(&trid_to_committed_trn, stack_end); + trn->pins= lf_hash_get_pins(&trid_to_committed_trn); if (!trn->pins) { trnman_free_trn(trn); @@ -761,7 +760,7 @@ TRN *trnman_recreate_trn_from_recovery(uint16 shortid, TrID longid) TrID old_trid_generator= global_trid_generator; TRN *trn; DBUG_ASSERT(maria_in_recovery && !maria_multi_threaded); - if (unlikely((trn= trnman_new_trn(NULL, NULL, NULL)) == NULL)) + if (unlikely((trn= trnman_new_trn(NULL, NULL)) == NULL)) return NULL; /* deallocate excessive allocations of trnman_new_trn() */ global_trid_generator= old_trid_generator; diff --git a/storage/maria/trnman_public.h b/storage/maria/trnman_public.h index 0005e556eb1..4286ec7e0a2 100644 --- a/storage/maria/trnman_public.h +++ b/storage/maria/trnman_public.h @@ -38,7 +38,7 @@ extern my_bool (*trnman_end_trans_hook)(TRN *trn, my_bool commit, int trnman_init(TrID); void trnman_destroy(void); -TRN *trnman_new_trn(pthread_mutex_t *, pthread_cond_t *, void *); +TRN *trnman_new_trn(pthread_mutex_t *, pthread_cond_t *); my_bool trnman_end_trn(TRN *trn, my_bool commit); #define trnman_commit_trn(T) trnman_end_trn(T, TRUE) #define trnman_abort_trn(T) trnman_end_trn(T, FALSE) diff --git a/storage/maria/unittest/trnman-t.c b/storage/maria/unittest/trnman-t.c index 439df10e66e..0873761c0a2 100644 --- a/storage/maria/unittest/trnman-t.c +++ b/storage/maria/unittest/trnman-t.c @@ -42,6 +42,8 @@ pthread_handler_t test_trnman(void *arg) pthread_cond_t conds[MAX_ITER]; int m= (*(int *)arg); + my_thread_init(); + for (i= 0; i < MAX_ITER; i++) { pthread_mutex_init(&mutexes[i], MY_MUTEX_INIT_FAST); @@ -54,7 +56,7 @@ pthread_handler_t test_trnman(void *arg) m-= n= x % MAX_ITER; for (i= 0; i < n; i++) { - trn[i]= trnman_new_trn(&mutexes[i], &conds[i], &m + STACK_SIZE); + trn[i]= trnman_new_trn(&mutexes[i], &conds[i]); if (!trn[i]) { diag("trnman_new_trn() failed"); @@ -76,6 +78,8 @@ pthread_handler_t test_trnman(void *arg) rt_num_threads--; pthread_mutex_unlock(&rt_mutex); + my_thread_end(); + return 0; } #undef MAX_ITER @@ -114,7 +118,7 @@ void run_test(const char *test, pthread_handler handler, int n, int m) i= trnman_can_read_from(trn[T1], trid[T2]); \ ok(i == RES, "trn" #T1 " %s read from trn" #T2, i ? "can" : "cannot") #define start_transaction(T) \ - trn[T]= trnman_new_trn(&mutexes[T], &conds[T], &i + STACK_SIZE); \ + trn[T]= trnman_new_trn(&mutexes[T], &conds[T]); \ trid[T]= trn[T]->trid #define commit(T) trnman_commit_trn(trn[T]) #define abort(T) trnman_abort_trn(trn[T]) @@ -159,7 +163,6 @@ void test_trnman_read_from() int main(int argc __attribute__((unused)), char **argv) { MY_INIT(argv[0]); - my_init(); plan(7); |