Skip to content

Conversation

@kamilkisiela
Copy link
Contributor

@kamilkisiela kamilkisiela commented Jul 18, 2025

The logic for merging sibling fetch steps was missing a check to prevent cycles in the fetch graph, leading to infinite loops. This commit adds a check to ensure that two steps are not ancestors/descendants of each other before merging them.

Closes #281

The logic for merging sibling fetch steps was missing a check to prevent
cycles in the fetch graph, leading to infinite loops. This commit adds a
check to ensure that two steps are not ancestors/descendants of each
other before merging them.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @kamilkisiela, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers a critical fix to the query planner by addressing an infinite loop bug that arose during the merging of sibling fetch steps. The core of the solution involves enhancing the merge logic to detect and prevent cyclical dependencies in the fetch graph, ensuring the stability and correctness of query plan generation. The changes are accompanied by a new, targeted test case to validate the fix.

Highlights

  • Cycle Prevention: Implemented a new check within the can_merge_with logic for fetch steps. Merges are now prevented if the two steps are found to be ancestors or descendants of each other, thereby avoiding the creation of problematic cycles.
  • New Utility Function: Added a new public method, is_ancestor_or_descendant, to the FetchGraph struct. This function efficiently determines if a given pair of nodes in the graph has an ancestor-descendant relationship, which is crucial for the cycle prevention logic.
  • Test Coverage: Introduced a new test case, issue_281_test, along with a dedicated supergraph fixture (281.supergraph.graphql). This test specifically targets the scenario that previously led to the infinite loop, ensuring the fix is effective and prevents future regressions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively fixes a potential infinite loop during the sibling merge optimization in the query planner. The approach of checking for an ancestor-descendant relationship before merging is sound and directly addresses the root cause of the issue. The addition of a dedicated test case and GraphQL fixture ensures this scenario is covered against regressions. The changes are clear and well-implemented.

@github-actions
Copy link

github-actions bot commented Jul 18, 2025

TestsPassed ✅SkippedFailedTime ⏱
federation-audit | abstract-types.xml18 ran18 ✅441ms
federation-audit | child-type-mismatch.xml4 ran4 ✅95ms
federation-audit | circular-reference-interface.xml2 ran2 ✅46ms
federation-audit | complex-entity-call.xml1 ran1 ✅85ms
federation-audit | corrupted-supergraph-node-id.xml10 ran10 ✅127ms
federation-audit | enum-intersection.xml5 ran5 ✅70ms
federation-audit | fed1-external-extends-resolvable.xml1 ran1 ✅23ms
federation-audit | fed1-external-extends.xml4 ran4 ✅61ms
federation-audit | fed1-external-extension.xml4 ran4 ✅63ms
federation-audit | fed2-external-extends.xml4 ran4 ✅67ms
federation-audit | fed2-external-extension.xml4 ran4 ✅69ms
federation-audit | include-skip.xml4 ran4 ✅90ms
federation-audit | input-object-intersection.xml3 ran3 ✅37ms
federation-audit | interface-object-indirect-extension.xml1 ran1 ✅37ms
federation-audit | interface-object-with-requires.xml7 ran7 ✅114ms
federation-audit | keys-mashup.xml1 ran1 ✅32ms
federation-audit | mutations.xml4 ran4 ✅96ms
federation-audit | mysterious-external.xml2 ran2 ✅39ms
federation-audit | nested-provides.xml2 ran2 ✅40ms
federation-audit | node.xml1 ran1 ✅26ms
federation-audit | non-resolvable-interface-object.xml7 ran7 ✅83ms
federation-audit | null-keys.xml1 ran1 ✅31ms
federation-audit | override-type-interface.xml4 ran4 ✅62ms
federation-audit | override-with-requires.xml4 ran4 ✅90ms
federation-audit | parent-entity-call-complex.xml1 ran1 ✅45ms
federation-audit | parent-entity-call.xml1 ran1 ✅26ms
federation-audit | provides-on-interface.xml2 ran2 ✅39ms
federation-audit | provides-on-union.xml2 ran2 ✅38ms
federation-audit | requires-interface.xml5 ran5 ✅81ms
federation-audit | requires-requires.xml5 ran5 ✅117ms
federation-audit | requires-with-argument.xml5 ran5 ✅106ms
federation-audit | requires-with-fragments.xml6 ran6 ✅101ms
federation-audit | shared-root.xml2 ran2 ✅47ms
federation-audit | simple-entity-call.xml1 ran1 ✅24ms
federation-audit | simple-inaccessible.xml4 ran4 ✅56ms
federation-audit | simple-interface-object.xml13 ran13 ✅187ms
federation-audit | simple-override.xml2 ran2 ✅41ms
federation-audit | simple-requires-provides.xml12 ran12 ✅168ms
federation-audit | typename.xml6 ran6 ✅90ms
federation-audit | unavailable-override.xml2 ran2 ✅35ms
federation-audit | union-interface-distributed.xml10 ran10 ✅107ms
federation-audit | union-intersection.xml12 ran12 ✅149ms

@github-actions
Copy link

github-actions bot commented Jul 18, 2025

k6-benchmark results

     ✓ response code was 200
     ✓ no graphql errors
     ✓ valid response structure

     █ setup

     checks.........................: 100.00% ✓ 14808      ✗ 0   
     data_received..................: 435 MB  14 MB/s
     data_sent......................: 5.8 MB  192 kB/s
     http_req_blocked...............: avg=36.79µs  min=1.12µs  med=2.64µs   max=11.18ms  p(90)=3.93µs   p(95)=4.61µs  
     http_req_connecting............: avg=30.89µs  min=0s      med=0s       max=11ms     p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=300.98ms min=5.18ms  med=296.37ms max=600.72ms p(90)=382.66ms p(95)=414.49ms
       { expected_response:true }...: avg=300.98ms min=5.18ms  med=296.37ms max=600.72ms p(90)=382.66ms p(95)=414.49ms
     http_req_failed................: 0.00%   ✓ 0          ✗ 4956
     http_req_receiving.............: avg=322.03µs min=35.34µs med=98.93µs  max=74.18ms  p(90)=242.38µs p(95)=1.07ms  
     http_req_sending...............: avg=63.71µs  min=7.52µs  med=16.02µs  max=10.32ms  p(90)=25.99µs  p(95)=39.94µs 
     http_req_tls_handshaking.......: avg=0s       min=0s      med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=300.6ms  min=5.1ms   med=296.05ms max=598.34ms p(90)=381.57ms p(95)=413.75ms
     http_reqs......................: 4956    163.505361/s
     iteration_duration.............: avg=304.99ms min=114.3ms med=297.12ms max=827.89ms p(90)=384.54ms p(95)=418.28ms
     iterations.....................: 4936    162.845533/s
     vus............................: 50      min=50       max=50
     vus_max........................: 50      min=50       max=50

@kamilkisiela kamilkisiela requested a review from dotansimha July 18, 2025 13:07
@dotansimha dotansimha merged commit 24e5e6b into main Jul 19, 2025
12 checks passed
@dotansimha dotansimha deleted the kamil-circular-reference branch July 19, 2025 15:16
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.

bug: cycle between steps causes an infinite loop

3 participants