gitCommitResolver should not do lazy OID resolution
Created by: slimsag
Because Zoekt-produced file matches do not contain a commit ID, this is an empty string for Zoekt search results:
Due to this you could not fetch information about the Git commit for Zoekt-produced file match search results, as documented:
Because customers wanted to do this via GraphQL however, we began supporting it by lazily resolving the Git commit OID when it is an empty string: https://github.com/sourcegraph/sourcegraph/pull/2318
This is not a good change for several reasons:
- It was the source of a bad perf regression in v3.2.0: https://github.com/sourcegraph/sourcegraph/pull/3685
- Due to the frequency at which it is called, and variety of circumstances under which it is called, it is difficult to make changes to that resolution logic without introducing perf regressions. e.g. see misconception about removing sync.Once logic here: https://github.com/sourcegraph/sourcegraph/issues/3746
- The "lookup zoekt-indexed revision if there is none" behavior is not even always desirable, as noted by @keegancsmith and @ijsnow in https://github.com/sourcegraph/sourcegraph/pull/2318#issuecomment-468403967
- There is a race condition where the commit is inaccurate: Zoekt produces the results from master
revisionA
, then indexes masterrevisionB
and we tell callers ofOID
the results were from masterrevisionB
incorrectly.
What we should do:
- Effectively revert back to the state we were in before https://github.com/sourcegraph/sourcegraph/pull/2318 and https://github.com/sourcegraph/sourcegraph/pull/3685 were merged, without doing on-the-fly OID resolution.
- Refactor Zoekt codepaths so that when it produces
fileMatchResolver
s, they contain the commit ID that the result came from. Zoekt has this information already and can just pass it down to us, sparing us from major complexity and the need for many caches.