fix: ignore spurious node updates while waiting for errors (#10175)

fixes #9921
This commit is contained in:
Spike Curtis
2023-10-11 09:22:20 +04:00
committed by GitHub
parent b0d2828f9e
commit fbabb43cbb
+14 -6
View File
@@ -645,12 +645,20 @@ func (c *testConn) recvNodes(ctx context.Context, t *testing.T) []*agpl.Node {
func (c *testConn) recvErr(ctx context.Context, t *testing.T) error {
t.Helper()
select {
case <-ctx.Done():
t.Fatal("timeout receiving error")
return ctx.Err()
case err := <-c.errChan:
return err
// pgCoord works on eventual consistency, so it sometimes sends extra node
// updates, and these block errors if not read from the nodes channel.
for {
select {
case nodes := <-c.nodeChan:
t.Logf("ignoring nodes update while waiting for error; id=%s, nodes=%+v",
c.id.String(), nodes)
continue
case <-ctx.Done():
t.Fatal("timeout receiving error")
return ctx.Err()
case err := <-c.errChan:
return err
}
}
}