Fix race condition relating to change updates

The gerrit event processing thread performs its own queries and
updates of change objects outside of the main thread, possibly
while those objects are being used in the main thread.  Generally
this is okay because typically only new data are being added to
changes, and if any of the new data are relevant, the main thread
will receive an event about it and update accordingly.

However, in the process of updating changes in the event processing
thread, some attributes of the change may be temporarily set to
incorrect values, such as empty lists.  Switch to atomic updates
of those values so that if the main thread consults the change object,
it has reasonably valid values.

This may have caused sporadic failures of test_dependent_changes_dequeue,
but is also capable of happening in production.

Change-Id: I134d50fe2da8ef344ee8d4fb68a1eed0692b04e2
1 file changed