Search expressions (e.g. "tag:funny location:Portland") can now be
evaluated server-side (expr.go and expr_test.go, still nascent). Next
step is to remove this parsing and construction from the javascript UI
code.
In addition, the search result now contains a continuation token to
continue interating through the result sets in a subsequent query.
The Javascript UI should use this now instead of parsing out
modification times of things and altering the search. If there's no
continuation token, that either means the end has been reached, or
that search type doesn't [yet] support iteration. Currently only
permanode-based queries are supported at many layers, including
continuation, but will be implemented later.
For now, the web UI should send a search query "expression" value of
non-zero length but just whitespace (like a single space: " ") to get
the home page (recently-modified permanodes") because setting both to
the zero value is an input validation error. We should probably make
an expression operator to be more clear here (like "want:permanode
sort:recent"). But the empty space hack works for now.
Change-Id: I3ea92eb8c776159f53c49db1a7439a91c507940a
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