clientv3: fix barrier.Wait() still block after barrier.Release() in some cases

Signed-off-by: Wenkang Zhang <314830391@qq.com>
This commit is contained in:
zhangwenkang 2023-07-11 20:59:25 +08:00 committed by Wenkang Zhang
parent a639ecd4ee
commit c3e5201972
2 changed files with 8 additions and 2 deletions

View File

@ -60,7 +60,7 @@ func (b *Barrier) Wait() error {
_, err = WaitEvents(
b.client,
b.key,
resp.Header.Revision,
[]mvccpb.Event_EventType{mvccpb.PUT, mvccpb.DELETE})
resp.Header.Revision+1,
[]mvccpb.Event_EventType{mvccpb.DELETE})
return err
}

View File

@ -15,6 +15,7 @@
package recipes_test
import (
"context"
"testing"
"time"
@ -46,6 +47,11 @@ func testBarrier(t *testing.T, waiters int, chooseClient func() *clientv3.Client
t.Fatalf("able to double-hold barrier")
}
// put a random key to move the revision forward
if _, err := chooseClient().Put(context.Background(), "x", ""); err != nil {
t.Errorf("could not put x (%v)", err)
}
donec := make(chan struct{})
stopc := make(chan struct{})
defer close(stopc)