Synchronize access to ReplicationTasksStorage

The ReplicationTasksStorage can be subject to concurrency issues when a
replication task is moved across directories (waiting/running/building)
concurrently with the listing.

The result of the uncontrolled concurrency could be lead to:

1. Flaky tests because of the replication tasks found two or more times
   in different directories
2. Flaky tests because of the failure to list replication tasks
   that are escaping across directories because of the rename
3. File-based exceptions when replication tasks are moved concurrently
   by two threads to different directories.

The replication tasks storage is supposed to contain only small files and only
in-flight operations: the overhead of the additional synchronisation is thus
negligible compared to the overall latency of the replication itself.

To eliminate all residual latency, cleanup all the replication tasks
on all subdirectories at the start of the tests.

Bug: Issue 11843
Change-Id: I5f6293b3f22f0943df79f8ab2cb2c217210e5236
2 files changed
tree: 150d53254d13c382418ee96e7a849a3449847b03
  1. .gitignore
  2. .mailmap
  3. .settings/
  4. BUILD
  6. src/