Fix race condition in relation state handling
Make sure we use the same timestamp to insert the new
syncroton_relations_state entry even if we execute this multiple times.
Not using a current timestamp and instead using the sync timestamp
isn't strictily necessary, but makes the execution more deterministicWe had a variety of issues in the syncroton handling code:
(less moving parts). It's either way racy, which is going to be* Race conditions where sometimes we wouldn't detect changes or attempt duplicate inserts
addressed in a separate commit.
Checking for empty leads to duplicate inserts when the new set of members is empty
Avoid resetting the cache on read
Otherwise our check which makes sure that we don't insert twice doesn't* Invalid handling of an empty set of members in the cache (use of empty instead of isset)
work.* Invalid resetting of the cache before reading, resulting in duplicate inserts
Deal with collisions in the cacheThe solution is somewhat messy because we really shouldn't be using timestamps for this, but rather attach the information to the syncstate, but this seems to fix most of the issues and gets the test to reliably pass.
Adjust cleanup to preserve the "before" timestamp.Supersedes https://git.kolab.org/D4896