Skip to content

Fix ChainInstrumentation misses to pass down calls chained contexts causes hanging #1090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

tinnou
Copy link
Contributor

@tinnou tinnou commented Jun 20, 2018

Description

When using the ChainedInstrumentation along with the DataLoaderInstrumentation any GraphQL query containing lists of lists will hang indefinitely. The reason is, the chained instrumentation is not correctly passing calls back to the chained contexts, which will cause to never trigger dispatches. For reference this is the offending line/commit

Steps to reproduce

I reused the DataLoaderPerformanceTest but instead with a ChainedInstrumentation to reproduce the issue/hanging.
Note the use of ChainedInstrumentation below.

    void setup() {
        DataLoaderRegistry dataLoaderRegistry = setupDataLoaderRegistry()
        Instrumentation instrumentation = new ChainedInstrumentation(
                Collections.singletonList(new DataLoaderDispatcherInstrumentation(dataLoaderRegistry)))
        graphQL = setupGraphQL(instrumentation)
    }

    def "chainedInstrumentation: 760 ensure data loader is performant for lists"() {
        when:

        ExecutionInput executionInput = ExecutionInput.newExecutionInput().query(query).build()
        def result = graphQL.execute(executionInput)

        then:
        result.data == expectedData
        //
        //  eg 1 for shops-->departments and one for departments --> products
        BatchCompareDataFetchers.departmentsForShopsBatchLoaderCounter.get() == 1
        BatchCompareDataFetchers.productsForDepartmentsBatchLoaderCounter.get() == 1
    }

Fix & Testing

I created custom InstrumentationContexts that override onFieldValuesInfo and onDeferredField, onFieldValueInforespectively and passed down the calls to the instrumentations.

Regarding the tests, I did not want to parameterize every single existing test (using spock where:) inside the DataLoaderPerformanceTest specification as I believe would increase the already cognitive load of these tests. Instead, I duplicated them and I separated them while extracting the common logic. Let me know if that's ok.

Since bug results in the DataLoaderDispatcherInstrumentation never getting
called hence never dispatching calls and hanging the execution
Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again thanks for the excellent PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants