Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions internal/coord/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ func (ts *QueryBehaviourBaseTestSuite) TestNotifiesQueryFinished() {
}

func TestPooledQuery_deadlock_regression(t *testing.T) {
t.Skip()
ctx := kadtest.CtxShort(t)
msg := &pb.Message{}
queryID := coordt.QueryID("test")
Expand Down Expand Up @@ -341,10 +340,17 @@ func TestPooledQuery_deadlock_regression(t *testing.T) {

// Advance the query pool state machine. Because we returned a new node
// above, the query pool state machine wants to send another outbound query
ev, _ = c.queryBehaviour.Perform(ctx)
require.IsType(t, &EventAddNode{}, ev) // event to notify the routing table
ev, _ = c.queryBehaviour.Perform(ctx)
require.IsType(t, &EventOutboundSendMessage{}, ev)
// and will notify the routing table

_, ok := c.queryBehaviour.Perform(ctx)
require.True(t, ok)

_, ok = c.queryBehaviour.Perform(ctx)
require.True(t, ok)

// no more work outstanding
_, ok = c.queryBehaviour.Perform(ctx)
require.False(t, ok)

hasLock := make(chan struct{})
var once sync.Once
Expand All @@ -361,7 +367,10 @@ func TestPooledQuery_deadlock_regression(t *testing.T) {
// of 1, the channel cannot hold both events. At the same time, the waiter
// doesn't consume the messages because it's busy processing the previous
// query event (because we haven't released the blocking waiterMsg call above).
go c.queryBehaviour.Notify(ctx, successMsg(nodes[2].NodeID))
go func() {
c.queryBehaviour.Notify(ctx, successMsg(nodes[2].NodeID))
c.queryBehaviour.Perform(ctx)
}()

// wait until the above Notify call was handled by waiting until the hasLock
// channel was closed in the above BeforeNotify hook. If that hook is called
Expand Down