diff --git a/t/08_busy.t b/t/08_busy.t index 7703d25..51ac532 100644 --- a/t/08_busy.t +++ b/t/08_busy.t @@ -58,6 +58,17 @@ foreach my $call_func (@CALL_FUNCS) { $dbh2->disconnect; undef($dbh2); + # NOTE: The second test is to see what happens if a lock is + # is released while waiting. When both parent and child are + # ready, the database is locked by the child. The parent + # starts waiting for a long enough time (apparently we need + # to wait much longer than we expected, as testers may use + # very slow (virtual) machines to test, but don't worry, + # it's only for the slowest environment). After a short sleep, + # the child commits and releases the lock. Eventually the parent + # notices that, and does the pended INSERT (hopefully before + # it is timed out). As both the parent and the child wait till + # both are ready, we don't need to sleep for a long time. pipe(READER, WRITER); my $pid = fork; if (!defined($pid)) { @@ -75,7 +86,7 @@ foreach my $call_func (@CALL_FUNCS) { $dbh2->do("INSERT INTO Blah VALUES ( 3, 'Test3' )"); select WRITER; $| = 1; select STDOUT; print WRITER "Ready\n"; - sleep(5); + sleep(2); $dbh2->commit; $dbh2->disconnect; exit; @@ -85,7 +96,7 @@ foreach my $call_func (@CALL_FUNCS) { my $line = ; chomp($line); ok($line, "Ready"); - ok($dbh->$call_func(10000, 'busy_timeout')); + ok($dbh->$call_func(100000, 'busy_timeout')); ok($dbh->do("INSERT INTO Blah VALUES (4, 'Test4' )")); $dbh->commit; wait;