d1vanov/libquentier

Investigate occasional failures of sync test with API rate limit breach on attempt to download a new note from a linked notebook

Closed this issue · 5 comments

One of tests for the synchronization logic implemented in #54 seems to occasionally fail and for some reason only on builds which run on launchpad build agents. I cannot reproduce the failure on any local machine of mine so we have a classic heisenbug here...

The tactics of nailing it down is going to be the following:

  • Add some kind of diagnostic output to print on test failure so that at least some bits of useful information can be extracted from the failing test's output
  • Use Lenin's squint i.e. stare at the source code of the sync algorithm as long as required to figure out where the error can be

Yay, managed to reproduce it on Travis CI and now the trace-level log of a failing test is available. So fixing this issue should now be just a matter of time for me to sit and examine this log carefully to understand the root cause of the issue.

Oh crap. Travis CI truncated the log after it reached 4 Mb 😢 I can't use it to diagnose the problem. Well, will see how would things be going on launchpad this time.

Managed to reproduce on launchpad, log is available, attaching it here just in case.
buildlog_ubuntu-xenial-i386.libquentier_0.4.0-4_ppa_quentier_201806161648_ubuntu16.04.1_BUILDING.txt.gz

It seems I finally managed to find the reason and fix this bug correctly. At least it no longer reproduces even on launchpad. In addition to fixing the logic causing test failures I also removed the necessity to have LocalStorageManagerAsync and SynchronizationManager in different threads of execution, now they can perfectly fine work within the same thread. I used this circumstance to simplify the setup of tests as sometimes they failed due to some problems caused by premature thread termination.

Finished after commit 175f4a9 in branch development.