mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-18030 waiting_threads-t is disabled
enabled. updated to use mysql_* pthread wrappers. reduced the number of iterations to finish in mtr-appropriate time
This commit is contained in:
@@ -13,12 +13,12 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
|
||||||
|
|
||||||
MY_ADD_TESTS(bitmap base64 my_atomic my_rdtsc lf my_malloc my_getopt dynstring
|
MY_ADD_TESTS(base64 bitmap byte_order crc32 dynstring lf my_atomic my_getopt
|
||||||
byte_order
|
my_malloc my_rdtsc queues stack_allocation stacktrace waiting_threads
|
||||||
queues stacktrace stack_allocation crc32 LINK_LIBRARIES mysys)
|
LINK_LIBRARIES mysys)
|
||||||
MY_ADD_TESTS(my_vsnprintf LINK_LIBRARIES strings mysys)
|
MY_ADD_TESTS(my_vsnprintf LINK_LIBRARIES strings mysys)
|
||||||
MY_ADD_TESTS(aes LINK_LIBRARIES mysys mysys_ssl)
|
|
||||||
ADD_DEFINITIONS(${SSL_DEFINES})
|
ADD_DEFINITIONS(${SSL_DEFINES})
|
||||||
|
MY_ADD_TESTS(aes LINK_LIBRARIES mysys mysys_ssl)
|
||||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
|
||||||
MY_ADD_TESTS(ma_dyncol LINK_LIBRARIES mysys)
|
MY_ADD_TESTS(ma_dyncol LINK_LIBRARIES mysys)
|
||||||
|
|
||||||
|
@@ -91,7 +91,7 @@ pthread_handler_t test_lf_alloc(void *arg)
|
|||||||
lf_alloc_free(pins, node2);
|
lf_alloc_free(pins, node2);
|
||||||
}
|
}
|
||||||
lf_alloc_put_pins(pins);
|
lf_alloc_put_pins(pins);
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
bad+= y;
|
bad+= y;
|
||||||
|
|
||||||
if (--N == 0)
|
if (--N == 0)
|
||||||
@@ -102,7 +102,7 @@ pthread_handler_t test_lf_alloc(void *arg)
|
|||||||
bad|= lf_allocator.mallocs - lf_alloc_pool_count(&lf_allocator);
|
bad|= lf_allocator.mallocs - lf_alloc_pool_count(&lf_allocator);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mutex);
|
mysql_mutex_unlock(&mutex);
|
||||||
|
|
||||||
if (with_my_thread_init)
|
if (with_my_thread_init)
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
@@ -157,7 +157,7 @@ pthread_handler_t test_lf_hash(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
lf_hash_put_pins(pins);
|
lf_hash_put_pins(pins);
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
bad+= sum;
|
bad+= sum;
|
||||||
inserts+= ins;
|
inserts+= ins;
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ pthread_handler_t test_lf_hash(void *arg)
|
|||||||
lf_hash.size, inserts, scans);
|
lf_hash.size, inserts, scans);
|
||||||
bad|= lf_hash.count;
|
bad|= lf_hash.count;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mutex);
|
mysql_mutex_unlock(&mutex);
|
||||||
if (with_my_thread_init)
|
if (with_my_thread_init)
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
#include <tap.h>
|
#include <tap.h>
|
||||||
|
|
||||||
volatile uint32 bad;
|
volatile uint32 bad;
|
||||||
pthread_mutex_t mutex;
|
mysql_mutex_t mutex;
|
||||||
|
|
||||||
void do_tests();
|
void do_tests();
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ int main(int argc __attribute__((unused)), char **argv)
|
|||||||
if (argv[1] && *argv[1])
|
if (argv[1] && *argv[1])
|
||||||
DBUG_SET_INITIAL(argv[1]);
|
DBUG_SET_INITIAL(argv[1]);
|
||||||
|
|
||||||
pthread_mutex_init(&mutex, 0);
|
mysql_mutex_init(PSI_NOT_INSTRUMENTED, &mutex, 0);
|
||||||
|
|
||||||
#define CYCLES 30000
|
#define CYCLES 30000
|
||||||
#define THREADS 30
|
#define THREADS 30
|
||||||
@@ -66,7 +66,7 @@ int main(int argc __attribute__((unused)), char **argv)
|
|||||||
|
|
||||||
do_tests();
|
do_tests();
|
||||||
|
|
||||||
pthread_mutex_destroy(&mutex);
|
mysql_mutex_destroy(&mutex);
|
||||||
my_end(0);
|
my_end(0);
|
||||||
return exit_status();
|
return exit_status();
|
||||||
}
|
}
|
||||||
|
@@ -16,15 +16,16 @@
|
|||||||
#include "thr_template.c"
|
#include "thr_template.c"
|
||||||
#include <waiting_threads.h>
|
#include <waiting_threads.h>
|
||||||
#include <m_string.h>
|
#include <m_string.h>
|
||||||
|
#include <my_rnd.h>
|
||||||
|
|
||||||
struct test_wt_thd {
|
struct test_wt_thd {
|
||||||
WT_THD thd;
|
WT_THD thd;
|
||||||
pthread_mutex_t lock;
|
mysql_mutex_t lock;
|
||||||
} thds[THREADS];
|
} thds[THREADS];
|
||||||
|
|
||||||
uint i, cnt;
|
uint i, cnt;
|
||||||
pthread_mutex_t lock;
|
mysql_mutex_t lock;
|
||||||
pthread_cond_t thread_sync;
|
mysql_cond_t thread_sync;
|
||||||
|
|
||||||
ulong wt_timeout_short=100, wt_deadlock_search_depth_short=4;
|
ulong wt_timeout_short=100, wt_deadlock_search_depth_short=4;
|
||||||
ulong wt_timeout_long=10000, wt_deadlock_search_depth_long=15;
|
ulong wt_timeout_long=10000, wt_deadlock_search_depth_long=15;
|
||||||
@@ -49,7 +50,7 @@ pthread_handler_t test_wt(void *arg)
|
|||||||
|
|
||||||
my_thread_init();
|
my_thread_init();
|
||||||
|
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
id= cnt++;
|
id= cnt++;
|
||||||
wt_thd_lazy_init(& thds[id].thd,
|
wt_thd_lazy_init(& thds[id].thd,
|
||||||
& wt_deadlock_search_depth_short, & wt_timeout_short,
|
& wt_deadlock_search_depth_short, & wt_timeout_short,
|
||||||
@@ -57,11 +58,11 @@ pthread_handler_t test_wt(void *arg)
|
|||||||
|
|
||||||
/* now, wait for everybody to be ready to run */
|
/* now, wait for everybody to be ready to run */
|
||||||
if (cnt >= THREADS)
|
if (cnt >= THREADS)
|
||||||
pthread_cond_broadcast(&thread_sync);
|
mysql_cond_broadcast(&thread_sync);
|
||||||
else
|
else
|
||||||
while (cnt < THREADS)
|
while (cnt < THREADS)
|
||||||
pthread_cond_wait(&thread_sync, &mutex);
|
mysql_cond_wait(&thread_sync, &mutex);
|
||||||
pthread_mutex_unlock(&mutex);
|
mysql_mutex_unlock(&mutex);
|
||||||
|
|
||||||
my_rnd_init(&rand, (ulong)(intptr)&m, id);
|
my_rnd_init(&rand, (ulong)(intptr)&m, id);
|
||||||
if (kill_strategy == YOUNGEST)
|
if (kill_strategy == YOUNGEST)
|
||||||
@@ -72,7 +73,7 @@ pthread_handler_t test_wt(void *arg)
|
|||||||
for (m= *(int *)arg; m ; m--)
|
for (m= *(int *)arg; m ; m--)
|
||||||
{
|
{
|
||||||
WT_RESOURCE_ID resid;
|
WT_RESOURCE_ID resid;
|
||||||
int blockers[THREADS/10], j, k;
|
int blockers[THREADS/10]={0}, j, k;
|
||||||
|
|
||||||
resid.value= id;
|
resid.value= id;
|
||||||
resid.type= &restype;
|
resid.type= &restype;
|
||||||
@@ -94,25 +95,25 @@ retry:
|
|||||||
if (kill_strategy == RANDOM)
|
if (kill_strategy == RANDOM)
|
||||||
thds[id].thd.weight= rnd();
|
thds[id].thd.weight= rnd();
|
||||||
|
|
||||||
pthread_mutex_lock(& thds[i].lock);
|
mysql_mutex_lock(& thds[i].lock);
|
||||||
res= wt_thd_will_wait_for(& thds[id].thd, & thds[i].thd, &resid);
|
res= wt_thd_will_wait_for(& thds[id].thd, & thds[i].thd, &resid);
|
||||||
pthread_mutex_unlock(& thds[i].lock);
|
mysql_mutex_unlock(& thds[i].lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&lock);
|
mysql_mutex_lock(&lock);
|
||||||
res= wt_thd_cond_timedwait(& thds[id].thd, &lock);
|
res= wt_thd_cond_timedwait(& thds[id].thd, &lock);
|
||||||
pthread_mutex_unlock(&lock);
|
mysql_mutex_unlock(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(& thds[id].lock);
|
mysql_mutex_lock(& thds[id].lock);
|
||||||
pthread_mutex_lock(&lock);
|
mysql_mutex_lock(&lock);
|
||||||
wt_thd_release_all(& thds[id].thd);
|
wt_thd_release_all(& thds[id].thd);
|
||||||
pthread_mutex_unlock(&lock);
|
mysql_mutex_unlock(&lock);
|
||||||
pthread_mutex_unlock(& thds[id].lock);
|
mysql_mutex_unlock(& thds[id].lock);
|
||||||
if (kill_strategy == LOCKS)
|
if (kill_strategy == LOCKS)
|
||||||
thds[id].thd.weight= 0;
|
thds[id].thd.weight= 0;
|
||||||
if (kill_strategy == YOUNGEST)
|
if (kill_strategy == YOUNGEST)
|
||||||
@@ -122,21 +123,21 @@ retry:
|
|||||||
thds[id].thd.weight++;
|
thds[id].thd.weight++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
/* wait for everybody to finish */
|
/* wait for everybody to finish */
|
||||||
if (!--cnt)
|
if (!--cnt)
|
||||||
pthread_cond_broadcast(&thread_sync);
|
mysql_cond_broadcast(&thread_sync);
|
||||||
else
|
else
|
||||||
while (cnt)
|
while (cnt)
|
||||||
pthread_cond_wait(&thread_sync, &mutex);
|
mysql_cond_wait(&thread_sync, &mutex);
|
||||||
|
|
||||||
pthread_mutex_lock(& thds[id].lock);
|
mysql_mutex_lock(& thds[id].lock);
|
||||||
pthread_mutex_lock(&lock);
|
mysql_mutex_lock(&lock);
|
||||||
wt_thd_release_all(& thds[id].thd);
|
wt_thd_release_all(& thds[id].thd);
|
||||||
pthread_mutex_unlock(&lock);
|
mysql_mutex_unlock(&lock);
|
||||||
pthread_mutex_unlock(& thds[id].lock);
|
mysql_mutex_unlock(& thds[id].lock);
|
||||||
wt_thd_destroy(& thds[id].thd);
|
wt_thd_destroy(& thds[id].thd);
|
||||||
pthread_mutex_unlock(&mutex);
|
mysql_mutex_unlock(&mutex);
|
||||||
|
|
||||||
DBUG_PRINT("wt", ("exiting"));
|
DBUG_PRINT("wt", ("exiting"));
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
@@ -152,7 +153,8 @@ void do_one_test()
|
|||||||
reset(wt_wait_stats);
|
reset(wt_wait_stats);
|
||||||
wt_success_stats=0;
|
wt_success_stats=0;
|
||||||
cnt=0;
|
cnt=0;
|
||||||
test_concurrently("waiting_threads", test_wt, THREADS, CYCLES);
|
test_concurrently("waiting_threads", test_wt, THREADS,
|
||||||
|
CYCLES/(skip_big_tests?500:10));
|
||||||
|
|
||||||
sum=sum0=0;
|
sum=sum0=0;
|
||||||
for (cnt=0; cnt < WT_CYCLE_STATS; cnt++)
|
for (cnt=0; cnt < WT_CYCLE_STATS; cnt++)
|
||||||
@@ -179,21 +181,16 @@ void do_one_test()
|
|||||||
void do_tests()
|
void do_tests()
|
||||||
{
|
{
|
||||||
DBUG_ENTER("do_tests");
|
DBUG_ENTER("do_tests");
|
||||||
if (skip_big_tests)
|
|
||||||
{
|
|
||||||
skip(1, "Big test skipped");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
plan(13);
|
plan(13);
|
||||||
compile_time_assert(THREADS >= 4);
|
compile_time_assert(THREADS >= 4);
|
||||||
|
|
||||||
DBUG_PRINT("wt", ("================= initialization ==================="));
|
DBUG_PRINT("wt", ("================= initialization ==================="));
|
||||||
|
|
||||||
pthread_cond_init(&thread_sync, 0);
|
mysql_cond_init(PSI_NOT_INSTRUMENTED, &thread_sync, 0);
|
||||||
pthread_mutex_init(&lock, 0);
|
mysql_mutex_init(PSI_NOT_INSTRUMENTED, &lock, 0);
|
||||||
wt_init();
|
wt_init();
|
||||||
for (cnt=0; cnt < THREADS; cnt++)
|
for (cnt=0; cnt < THREADS; cnt++)
|
||||||
pthread_mutex_init(& thds[cnt].lock, 0);
|
mysql_mutex_init(PSI_NOT_INSTRUMENTED, & thds[cnt].lock, 0);
|
||||||
{
|
{
|
||||||
WT_RESOURCE_ID resid[4];
|
WT_RESOURCE_ID resid[4];
|
||||||
for (i=0; i < array_elements(resid); i++)
|
for (i=0; i < array_elements(resid); i++)
|
||||||
@@ -218,16 +215,16 @@ void do_tests()
|
|||||||
ok_wait(0,2,0);
|
ok_wait(0,2,0);
|
||||||
ok_wait(0,3,0);
|
ok_wait(0,3,0);
|
||||||
|
|
||||||
pthread_mutex_lock(&lock);
|
mysql_mutex_lock(&lock);
|
||||||
bad= wt_thd_cond_timedwait(& thds[0].thd, &lock);
|
bad= wt_thd_cond_timedwait(& thds[0].thd, &lock);
|
||||||
pthread_mutex_unlock(&lock);
|
mysql_mutex_unlock(&lock);
|
||||||
ok(bad == WT_TIMEOUT, "timeout test returned %d", bad);
|
ok(bad == WT_TIMEOUT, "timeout test returned %d", bad);
|
||||||
|
|
||||||
ok_wait(0,1,0);
|
ok_wait(0,1,0);
|
||||||
ok_wait(1,2,1);
|
ok_wait(1,2,1);
|
||||||
ok_deadlock(2,0,2);
|
ok_deadlock(2,0,2);
|
||||||
|
|
||||||
pthread_mutex_lock(&lock);
|
mysql_mutex_lock(&lock);
|
||||||
ok(wt_thd_cond_timedwait(& thds[0].thd, &lock) == WT_TIMEOUT, "as always");
|
ok(wt_thd_cond_timedwait(& thds[0].thd, &lock) == WT_TIMEOUT, "as always");
|
||||||
ok(wt_thd_cond_timedwait(& thds[1].thd, &lock) == WT_TIMEOUT, "as always");
|
ok(wt_thd_cond_timedwait(& thds[1].thd, &lock) == WT_TIMEOUT, "as always");
|
||||||
wt_thd_release_all(& thds[0].thd);
|
wt_thd_release_all(& thds[0].thd);
|
||||||
@@ -240,7 +237,7 @@ void do_tests()
|
|||||||
wt_thd_release_all(& thds[i].thd);
|
wt_thd_release_all(& thds[i].thd);
|
||||||
wt_thd_destroy(& thds[i].thd);
|
wt_thd_destroy(& thds[i].thd);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&lock);
|
mysql_mutex_unlock(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
wt_deadlock_search_depth_short=6;
|
wt_deadlock_search_depth_short=6;
|
||||||
@@ -277,10 +274,10 @@ void do_tests()
|
|||||||
|
|
||||||
DBUG_PRINT("wt", ("================= cleanup ==================="));
|
DBUG_PRINT("wt", ("================= cleanup ==================="));
|
||||||
for (cnt=0; cnt < THREADS; cnt++)
|
for (cnt=0; cnt < THREADS; cnt++)
|
||||||
pthread_mutex_destroy(& thds[cnt].lock);
|
mysql_mutex_destroy(& thds[cnt].lock);
|
||||||
wt_end();
|
wt_end();
|
||||||
pthread_mutex_destroy(&lock);
|
mysql_mutex_destroy(&lock);
|
||||||
pthread_cond_destroy(&thread_sync);
|
mysql_cond_destroy(&thread_sync);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user