nautilus/gateway

MinQueriesPlanner freeze on large selection sets affecting different locations

prokaktus opened this issue · 1 comments

Hello, @AlecAivazis!

When selection sets is large than 10 and planner starts to collect steps, it's freezing, because of current buffer size.

Example to reproduce the problem:

Schema:

type User {  # location: 1
	photo: Photo
}

type Photo {  # location: 2
	url: String!
	user: User
}

type Query {  # location: 1
	allUsers: [User!]!
}

Query (actual query could consists of different types from different locations, but to illustrate the problem I add only photo):

{
	users: allUsers {
		p1: photo {
			url
		}
		p2: photo {
			url
		}
		p3: photo {
			url
		}
		p4: photo {
			url
		}
		p5: photo {
			url
		}
		p6: photo {
			url
		}
		p7: photo {
			url
		}
		p8: photo {
			url
		}
		p9: photo {
			url
		}
		p10: photo {
			url
		}
		p11: photo {
			url
		}
	}
}

In that case, MinQueriesPlanner freeze, because of buffered channel has len 10

Here the channel declaration:

gateway/plan.go

Line 146 in 1078926

stepCh := make(chan *newQueryPlanStepPayload, 10)

And here is possible, that extracting process with the step channel run for every field from location set:

gateway/plan.go

Lines 430 to 442 in 1078926

subSelection, err := p.extractSelection(&extractSelectionConfig{
stepCh: config.stepCh,
stepWg: config.stepWg,
step: config.step,
locations: config.locations,
parentLocation: config.parentLocation,
plan: config.plan,
parentType: coreFieldType(selection).Name(),
selection: selection.SelectionSet,
insertionPoint: insertionPoint,
wrapper: wrapper,
})

I suggest to bump buffer size for channel, what do you think? I'll provide PR for that.

Thanks!

Closing because PR got merged