Ideas for improving Concurrency Tests

From: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Ideas for improving Concurrency Tests
Date: 2013-03-26 07:31:10
Message-ID: 004201ce29f3$e36b12c0$aa413840$@kapila@huawei.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ideas for improving Concurrency testing

1. Synchronization points in server code - To have better control for
concurrency testing, define synchronization points in server code which can
be used as follows:

heap_truncate(..)
{
....

SYNC_POINT(procid,'before_heap_open')
rel = heap_open(rid,
AccessExclusiveLock);
relations = lappend(relations, rel);
}

exec_simple_query(..)
{
...

finish_xact_command();

SYNC_POINT(procid,'finish_xact_command')

/*
* If there were no parsetrees,
return EmptyQueryResponse message.
*/
if (!parsetree_list)
NullCommand(dest);
...
}


When code reaches at sync point it can
either emit a signal
or wait for a signal

Signal
A value of a shared memory variable that
will be interpretted by different
SYNC POINTS based on it's value.

Emit a signal
Assign the value (the signal) to the
shared memory variable ("set a flag") and
broadcast a global condition to wake
those waiting for a signal.

Wait for a signal
Loop over waiting for the global
condition until the global value matches
the wait-for signal

To activate Synchronization points appropriate
actions can be set.
For Example,
SET SYNC_POINT = 'before_heap_open WAIT_FOR
commit';
SET SYNC_POINT = 'after_finish_xact_command
SIGNAL commit';

This above commands can activate the synchronization
points named 'before_heap_open'
and 'after_finish_xact_command'.


session "s1"
step s11 {SET SYNC_POINT = 'before_heap_open
WAIT_FOR commit';}
step s12 {Truncate tbl;}
session "s2"
step s21 {SET SYNC_POINT =
'after_finish_xact_command SIGNAL commit';}
step s22 {Insert into tbl values(1);}

The first activation requests the synchronization
point to wait for
another backend to emit the signal 'commit', and
second activation requests
the synchronization point to emit the signal
'commit', when the process's execution runs through
the synchronization point.

Above defined test will allow Truncate table to wait
for Insert to finish

2. Enhance Isolation Framework - Currently, at most one step can be waiting
at a time. Enhance Concurrency test framework (isolation tester) to make
multiple sessions wait and then allow to release it serially.

This might help in
generating complex dead lock scenario's.

Above ideas could be useful to improve concurrency testing and can also be
helpful to generate test cases for some of the complicated bugs for which
there is no direct test.

This work is not a patch for 9.3, I just wanted an initial feedback.

Feedback/Suggestions?

Reference : http://dev.mysql.com/doc/internals/en/debug-sync-facility.html

With Regards,

Amit Kapila.

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-03-26 07:51:50 Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
Previous Message Tom Lane 2013-03-26 04:49:10 Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)