Commit 3967b6cf authored by unknown's avatar unknown

WL#4401 "Maria - deserialize translog_flush() calls"

storage/maria/ma_loghandler.c:
  New flush procedure added.
storage/maria/unittest/Makefile.am:
  Test of many multi-thread flush added
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Test of many multi-thread flush added
parent 39049add
This diff is collapsed.
...@@ -42,6 +42,7 @@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \ ...@@ -42,6 +42,7 @@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \
ma_test_loghandler-t \ ma_test_loghandler-t \
ma_test_loghandler_multigroup-t \ ma_test_loghandler_multigroup-t \
ma_test_loghandler_multithread-t \ ma_test_loghandler_multithread-t \
ma_test_loghandler_multiflush-t \
ma_test_loghandler_pagecache-t \ ma_test_loghandler_pagecache-t \
ma_test_loghandler_long-t \ ma_test_loghandler_long-t \
ma_test_loghandler_noflush-t \ ma_test_loghandler_noflush-t \
...@@ -54,6 +55,8 @@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \ ...@@ -54,6 +55,8 @@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \
ma_test_loghandler_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_test_loghandler_multigroup_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c sequence_storage.c sequence_storage.h ma_test_loghandler_multigroup_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c sequence_storage.c sequence_storage.h
ma_test_loghandler_multithread_t_SOURCES = ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_multithread_t_SOURCES = ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_test_loghandler_multiflush_t_SOURCES = ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_test_loghandler_multiflush_t_CPPFLAGS = -DMULTIFLUSH_TEST
ma_test_loghandler_pagecache_t_SOURCES = ma_test_loghandler_pagecache-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_pagecache_t_SOURCES = ma_test_loghandler_pagecache-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_test_loghandler_long_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_long_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_test_loghandler_long_t_CPPFLAGS = -DLONG_LOG_TEST ma_test_loghandler_long_t_CPPFLAGS = -DLONG_LOG_TEST
......
...@@ -28,16 +28,35 @@ static const char *default_dbug_option; ...@@ -28,16 +28,35 @@ static const char *default_dbug_option;
#define PCACHE_SIZE (1024*1024*10) #define PCACHE_SIZE (1024*1024*10)
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
/*#define LOG_FLAGS TRANSLOG_SECTOR_PROTECTION | TRANSLOG_PAGE_CRC */ /*#define LOG_FLAGS TRANSLOG_SECTOR_PROTECTION | TRANSLOG_PAGE_CRC */
#define LOG_FLAGS 0 #define LOG_FLAGS 0
/*#define LONG_BUFFER_SIZE (1024L*1024L*1024L + 1024L*1024L*512)*/ /*#define LONG_BUFFER_SIZE (1024L*1024L*1024L + 1024L*1024L*512)*/
#ifdef MULTIFLUSH_TEST
#define LONG_BUFFER_SIZE (16384L)
#define MIN_REC_LENGTH 10
#define SHOW_DIVIDER 20
#define ITERATIONS 10000
#define FLUSH_ITERATIONS 1000
#define WRITERS 2
#define FLUSHERS 10
#else
#define LONG_BUFFER_SIZE (512L*1024L*1024L) #define LONG_BUFFER_SIZE (512L*1024L*1024L)
#define MIN_REC_LENGTH 30 #define MIN_REC_LENGTH 30
#define SHOW_DIVIDER 10 #define SHOW_DIVIDER 10
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
#define ITERATIONS 3 #define ITERATIONS 3
#define FLUSH_ITERATIONS 0
#define WRITERS 3 #define WRITERS 3
#define FLUSHERS 0
#endif
static uint number_of_writers= WRITERS; static uint number_of_writers= WRITERS;
static uint number_of_flushers= FLUSHERS;
static pthread_cond_t COND_thread_count; static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count; static pthread_mutex_t LOCK_thread_count;
...@@ -48,6 +67,9 @@ static LSN lsns1[WRITERS][ITERATIONS]; ...@@ -48,6 +67,9 @@ static LSN lsns1[WRITERS][ITERATIONS];
static LSN lsns2[WRITERS][ITERATIONS]; static LSN lsns2[WRITERS][ITERATIONS];
static uchar *long_buffer; static uchar *long_buffer;
static LSN last_lsn; /* For test purposes the variable allow dirty read/write */
/* /*
Get pseudo-random length of the field in Get pseudo-random length of the field in
limits [MIN_REC_LENGTH..LONG_BUFFER_SIZE] limits [MIN_REC_LENGTH..LONG_BUFFER_SIZE]
...@@ -177,6 +199,7 @@ void writer(int num) ...@@ -177,6 +199,7 @@ void writer(int num)
return; return;
} }
lsns2[num][i]= lsn; lsns2[num][i]= lsn;
last_lsn= lsn;
pthread_mutex_lock(&LOCK_thread_count); pthread_mutex_lock(&LOCK_thread_count);
ok(1, "write records"); ok(1, "write records");
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
...@@ -205,6 +228,33 @@ static void *test_thread_writer(void *arg) ...@@ -205,6 +228,33 @@ static void *test_thread_writer(void *arg)
} }
static void *test_thread_flusher(void *arg)
{
int param= *((int*) arg);
int i;
my_thread_init();
for(i= 0; i < FLUSH_ITERATIONS; i++)
{
translog_flush(last_lsn);
pthread_mutex_lock(&LOCK_thread_count);
ok(1, "-- flush %d", param);
pthread_mutex_unlock(&LOCK_thread_count);
}
pthread_mutex_lock(&LOCK_thread_count);
thread_count--;
ok(1, "flusher finished"); /* just to show progress */
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are
ready */
pthread_mutex_unlock(&LOCK_thread_count);
free((uchar*) arg);
my_thread_end();
return(0);
}
int main(int argc __attribute__((unused)), int main(int argc __attribute__((unused)),
char **argv __attribute__ ((unused))) char **argv __attribute__ ((unused)))
{ {
...@@ -219,7 +269,8 @@ int main(int argc __attribute__((unused)), ...@@ -219,7 +269,8 @@ int main(int argc __attribute__((unused)),
int *param, error; int *param, error;
int rc; int rc;
plan(WRITERS + ITERATIONS * WRITERS * 3); plan(WRITERS + FLUSHERS +
ITERATIONS * WRITERS * 3 + FLUSH_ITERATIONS * FLUSHERS );
bzero(&pagecache, sizeof(pagecache)); bzero(&pagecache, sizeof(pagecache));
maria_data_root= (char *)"."; maria_data_root= (char *)".";
...@@ -329,19 +380,36 @@ int main(int argc __attribute__((unused)), ...@@ -329,19 +380,36 @@ int main(int argc __attribute__((unused)),
pthread_mutex_lock(&LOCK_thread_count); pthread_mutex_lock(&LOCK_thread_count);
while (number_of_writers != 0) while (number_of_writers != 0 || number_of_flushers != 0)
{ {
param= (int*) malloc(sizeof(int)); if (number_of_writers)
*param= number_of_writers - 1;
if ((error= pthread_create(&tid, &thr_attr, test_thread_writer,
(void*) param)))
{ {
fprintf(stderr, "Got error: %d from pthread_create (errno: %d)\n", param= (int*) malloc(sizeof(int));
error, errno); *param= number_of_writers - 1;
exit(1); if ((error= pthread_create(&tid, &thr_attr, test_thread_writer,
(void*) param)))
{
fprintf(stderr, "Got error: %d from pthread_create (errno: %d)\n",
error, errno);
exit(1);
}
thread_count++;
number_of_writers--;
}
if (number_of_flushers)
{
param= (int*) malloc(sizeof(int));
*param= number_of_flushers - 1;
if ((error= pthread_create(&tid, &thr_attr, test_thread_flusher,
(void*) param)))
{
fprintf(stderr, "Got error: %d from pthread_create (errno: %d)\n",
error, errno);
exit(1);
}
thread_count++;
number_of_flushers--;
} }
thread_count++;
number_of_writers--;
} }
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
......
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