[clangd] Narrow and document a loophole in blockUntilIdle
authorSam McCall <sam.mccall@gmail.com>
Wed, 17 Feb 2021 11:59:25 +0000 (12:59 +0100)
committerSam McCall <sam.mccall@gmail.com>
Mon, 22 Feb 2021 22:08:52 +0000 (23:08 +0100)
commit2d9cfcfef029952511462ee45c49c1bf223b9495
tree3eb077ecd27c91d1f5f06433bf1d2dc31a5685cc
parentc24b7a16b1001a8978335183d958fd0aa482c1d9
[clangd] Narrow and document a loophole in blockUntilIdle

blockUntilIdle of a parent can't always be correctly implemented as
  return ChildA.blockUntilIdle() && ChildB.blockUntilIdle()
The problem is that B can schedule work on A while we're waiting on it.

I believe this is theoretically possible today between CDB and background index.
Modules open more possibilities and it's hard to reason about all of them.

I don't have a perfect fix, and the abstraction is too good to lose. this patch:
 - calls out why we block on workscheduler first, and asserts correctness
 - documents the issue
 - reduces the practical possibility of spuriously returning true significantly

This function is ultimately only for testing, so we're driving down flake rate.

Differential Revision: https://reviews.llvm.org/D96856
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h