worker/txnpruner: sporadic test failure

Bug #1618560 reported by Roger Peppe
This bug report is a duplicate of:  Bug #1471770: TestPrunes fails occasionally still. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
New
Undecided
Unassigned

Bug Description

Revision history for this message
Roger Peppe (rogpeppe) wrote :

The reason for the failure is that the test relies on the scheduler.

There are two goroutines in play here.

When the test works, this happens:

   txnpruner: receives on timer channe
   txnpruner: calls MaybePruneTransaction, which sends on the test channel
   test: receives on test channel
   test: set t0
   txnpruner: reset timer to 10ms
   txnpruner: receives on timer channel at t0+10ms+something small
   txnpruner: calls MaybePruneTransaction, which sends on the test channel
   test: receives on test channel
   test: set t1
   test: t1 >= t0 + 10ms, all ok

But this can happen instead:

   txnpruner: receives on timer channe
   txnpruner: calls MaybePruneTransaction, which sends on the test channel
   test: receives on test channel
   txnpruner: reset timer to 10ms
   test: set t0
   txnpruner: receives on timer channel at t0+10ms+something small
   txnpruner: calls MaybePruneTransaction, which sends on the test channel
   test: receives on test channel
   test: set t1
   test: t1 < t0 + 10ms, fail

That is, there's nothing stopping the timer from resetting before the
test has decided on what time the previous event was set.

To fix this, the time should be set deterministically before the
code can continue running (for example by using a reply channel
or changing the test mock to send the time on the channel)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.