Skip to content

Commit

Permalink
clientv3: fix barrier.Wait() still block after barrier.Release() in s…
Browse files Browse the repository at this point in the history
…ome cases

Signed-off-by: Wenkang Zhang <[email protected]>
  • Loading branch information
kensou97 committed Jul 18, 2023
1 parent a639ecd commit c3e5201
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/v3/experimental/recipes/barrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package recipes_test

import (
"context"
"testing"
"time"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c3e5201

Please sign in to comment.