Control: tags -1 pending -=| Damyan Ivanov, 07.09.2013 23:23:16 +0300 |=- > I managed to reproduce this on eder.d.o (mipsel) and on my laptop > (amd64). The test needs to be run several times for the hang to > happen. > > The test that fails waits for asynchronous database event posted by > another thread.
I have found the reason for this. What the test does is the following: * start a worker thread that connects to the DB and performs some event-triggering operations, then disconnects and quits. * in the main thread, call ib_wait_event capturing the triggered events The nature of the ib_wait_event call is that it stops execution, waiting for events to come, synchronously. Usually, the main thread manages to reach the ib_wait_event call before the worker thread starts posting events. However, sometimes the worker thread is run before the main thread, and does all of its job before the main thread reaches ib_wait_event, meaning that the events that ib_wait_event wants to see never come and the test hangs at the ib_wait_event call. I believe this is exactly what happens in this test when it hangs. To make it reproducible, add a small sleep before calling ib_wait_event. Ideally, we should suspend the worker thread and resume it only when the main thread has called ib_wait_event. However, because of the synchronous nature of ib_wait_event, this is not possible (this is not firebird fault, there is an asynchronous interface which we also test earlier in that test and which works). My first idea for fixing this was to add a small delay in the worker thread, giving time to the main thread to reach ib_wait_event before starting triggering events. This seems to work at first glance, but fails even with a 5 seconds delay when the system is heavily loaded (for example by a -j5 build of firebird server on a 4 CPU laptop). My next idea is to skip these sub-tests when AUTOMATED_TESTING is present in the environment, which is the case when the Debian package is building. If somebody has other ideas, please shout.
signature.asc
Description: Digital signature