nautilus / gateway

A federated api gateway for graphql services. https://gateway.nautilus.dev/
MIT License
397 stars 49 forks source link

MinQueriesPlanner freeze on large selection sets affecting different locations #129

Closed prokaktus closed 3 years ago

prokaktus commented 3 years ago

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: https://github.com/nautilus/gateway/blob/107892653e275349638cf703482d2c91573d25a3/plan.go#L146

And here is possible, that extracting process with the step channel run for every field from location set: https://github.com/nautilus/gateway/blob/107892653e275349638cf703482d2c91573d25a3/plan.go#L430-L442

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

Thanks!

prokaktus commented 3 years ago

Closing because PR got merged