Herewith I propose a new facility to be used in the test suite to make
race conditions repeatable and get rid of sleeps.
The facility is controlled by user variables. For example, if you have a
"synchronization point" in the code like this:
then you can control it by a user variable in the test case like so:
SET @mysql_test_sync_after_insert= 'inserted:flushed';
When the code execution in a thread reaches the synchronization point,
it "sends" the 'inserted' signal (it sets a global String to "inserted"
and broadcasts a global condition). Then the thread waits until another
thread sends the 'flushed' signal (sets the global String to "flushed"
and broadcasts the global condition).
The patch http://lists.mysql.com/commits/39659 contains the main part
and documentation in item_func.cc. It does also contain functions for
convenient access to user variable values, an example test case with
changes to show how to use the facility, and synchronization points used
by the changed test case. It removes some sleeps and could reduce test
case execution time from 7 seconds to 0.4 seconds.
Please send me your thoughts. Do you think we should include it in the
Ingo Strüwing, Senior Software Developer
MySQL GmbH, Dachauer Str. 37, D-80335 München
Geschäftsführer: Kaj Arnö - HRB München 162140