Skip to content

Cooperative Cancellation#7604

Merged
Velfi merged 26 commits intodevfrom
zelda/feature-cooperative-cancellation
Jun 18, 2025
Merged

Cooperative Cancellation#7604
Velfi merged 26 commits intodevfrom
zelda/feature-cooperative-cancellation

Conversation

@Velfi
Copy link
Contributor

@Velfi Velfi commented Jun 3, 2025

Cooperative Cancellation for Query Planning

This release introduces cooperative cancellation support for query planning operations. This feature allows the router to gracefully handle query planning timeouts and cancellations, improving resource utilization. Metrics are emitted for cooperative cancellation:

Records the "outcome" of query planning on the apollo.router.query_planning.plan.duration metric.
Records the "outcome" of query planning on the query_planning span.


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@github-actions

This comment has been minimized.

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Jun 3, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 4f4ae430826a6c8c371b08ae

@apollo-librarian
Copy link

apollo-librarian bot commented Jun 12, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 11 changed, 0 removed
* (developer-tools)/apollo-mcp-server/(latest)/command-reference.mdx
* (developer-tools)/apollo-mcp-server/(latest)/guides/index.mdx
* (developer-tools)/kotlin/(latest)/index.mdx
* (developer-tools)/kotlin/(latest)/advanced/apollo-ast.mdx
* (developer-tools)/kotlin/(latest)/advanced/compiler-plugins.mdx
* (developer-tools)/kotlin/(latest)/advanced/no-runtime.mdx
* (developer-tools)/kotlin/(latest)/caching/http-cache.mdx
* (developer-tools)/kotlin/(latest)/caching/normalized-cache.mdx
* (developer-tools)/kotlin/(latest)/testing/apollo-debug-server.mdx
* (developer-tools)/kotlin/(latest)/testing/mocking-graphql-responses.mdx
* graphos/routing/(latest)/performance/caching/in-memory.mdx

Build ID: ac25c6586d8308e5efbeae6c

URL: https://www.apollographql.com/docs/deploy-preview/ac25c6586d8308e5efbeae6c

@Velfi Velfi marked this pull request as ready for review June 13, 2025 15:50
@Velfi Velfi requested a review from a team June 13, 2025 15:50
@Velfi Velfi requested review from a team as code owners June 13, 2025 15:50
Copy link
Member

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

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

Mostly minor comments, the actual feature is a little more involved than I expected and I overall like the solution :) My only real objection is the config shape.

Copy link
Member

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

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

Pre-approval assuming comments are addressed in a manner considered adequate by the PR author 🫡

Copy link
Contributor

@BrynCooke BrynCooke left a comment

Choose a reason for hiding this comment

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

Locking as reviewing

// When cooperative cancellation is enabled, we want to cancel the query planner
// task if the request is canceled.
if self.cooperative_cancellation.is_enabled() {
let outcome_recorded = Arc::new(AtomicU8::new(Outcome::None as u8));
Copy link
Contributor

Choose a reason for hiding this comment

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

Outcome needs to be documented in the docs.

Copy link
Member

Choose a reason for hiding this comment

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

I think docs will be a follow up, because merging docs for unreleased features into dev goes straight to the public docs website...

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to include comments in our MDX doc files? That way releasing the feature would just involve uncommenting the docs that were added as part of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Popping in here from Edu team! I'm not as familiar with the router side of docs, but I did come across this PR on the MCP server that uncomments out the part of the docs so it seems like it should be possible!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added docs that explain outcome to the metric docs.

Copy link
Contributor

@BrynCooke BrynCooke left a comment

Choose a reason for hiding this comment

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

Approved, but make sure to manually check the spans.

@Velfi Velfi enabled auto-merge June 18, 2025 15:27
@Velfi Velfi merged commit cdc3ebb into dev Jun 18, 2025
15 checks passed
@Velfi Velfi deleted the zelda/feature-cooperative-cancellation branch June 18, 2025 15:48
@abernix abernix mentioned this pull request Jul 1, 2025
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.

7 participants