Skip to content
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

Fix introspection query deduplication #6257

Merged
merged 4 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changesets/fix_geal_introspection_dedup_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Fix introspection query deduplication ([Issue #6249](https://github.com/apollographql/router/issues/6249))

To reduce CPU usage, query planning and introspection queries are deduplicated. In some cases, deduplicated introspection queries were not receiving their result. This makes sure that answers are sent in all cases.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/6257
18 changes: 17 additions & 1 deletion apollo-router/src/query_planner/caching_query_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,19 @@ where
// of restarting the query planner until another timeout
tokio::task::spawn(
async move {
let res = self.delegate.ready().await?.call(request).await;
let service = match self.delegate.ready().await {
Ok(service) => service,
Err(error) => {
let e = Arc::new(error);
let err = e.clone();
tokio::spawn(async move {
entry.insert(Err(err)).await;
});
return Err(CacheResolverError::RetrievalError(e));
}
};

let res = service.call(request).await;

match res {
Ok(QueryPlannerResponse { content, errors }) => {
Expand All @@ -536,6 +548,10 @@ where
tokio::spawn(async move {
entry.insert(Ok(content)).await;
});
} else {
tokio::spawn(async move {
entry.send(Ok(content)).await;
});
}
}

Expand Down