syncutil: more debugging and paranoia

Change-Id: I9dcb903e4f0918097130a93c14c498c260832294
typo: use Errorf instead of Error in test

Change-Id: Idaa1b8870975d50d22789ed6fd6787f213d0d0d3
Fix corpus/search locking bugs.

The WebSockets live queries exposed a latent locking bug: the search
code was acquiring the Corpus read lock multiple times.  If a write
came in during the middle of a search, between two read locks, the
second RLock would hang (since a writer lock was pending) and then the
search and write would deadlock.

Instead, just acquire the read lock once at the beginning of the query and
never re-acquire it.  For now: new "Locked" versions of all the Corpus APIs.
In the future: will probably just add the locked-or-not into the context, and make
sure all Corpus methods require a *context.Context.

Also fix two potential data races: one with LogicalCondition (which
might've raced on the scratch ss buffer, depending on the query), and
a test-only race that didn't matter in production, but was annoying in
tsan output regardless, so fixed.

More tests to follow later. Unblocking Aaron for now.

Change-Id: Ie1edcbd061235f1ef04f9b4c68b86814c84361af
Revert "This patch hangs the server." (the websockets live query code)

I accidentally committed this earlier, but it was still a WIP.

This reverts commit aef2fba3e11886ab4c02958f33cf80c496b44961.