Fix a newly-introduced deadlock in RelationCounterField.
Review Request #9633 — Created Feb. 13, 2018 and submitted
The recent fix for tracking multiple instances in
introduced a deadlock that manifested during a Review Board test suite
run. It was possible for a weak reference to drop while adding a new
_reset_stateto grab a locl while
running (as part of the instantiation of an
We now delay setting up
InstanceStateuntil we leave the lock,
allowing the lock to just center around manipulating the state map, and
allowing setup/destroying to be in its own locks.
My reliably-broken unit test run no longer deadlocks.
All Djblets and Review Board unit tests pass.