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

APQ: Add cache-control header on PERSISTED_QUERY_NOT_FOUND #2503

Merged
merged 9 commits into from
Jan 31, 2023

Conversation

o0Ignition0o
Copy link
Contributor

@o0Ignition0o o0Ignition0o commented Jan 30, 2023

Fixes #2502

The router now sends cache-control: private, no-cache, must-revalidate when a persisted query hash was not found.

@github-actions

This comment has been minimized.

@o0Ignition0o o0Ignition0o marked this pull request as ready for review January 30, 2023 20:14
Comment on lines 117 to 119
if let Some(sender) = self.wait_map.lock().await.remove(&key) {
let _ = sender.send(value.clone());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @Geal @garypen because I honestly don't understand all the intricacies of the cache, all I know is the test used to fail, and not it passes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the problem you are resolving is that there may be waiters who are not notified that a value has been inserted. The bit I don't understand is that, if there are waiters, then something should be "getting" the cached value and that should resolve at some point.

Logically, it's probably not safe to insert() a value to the cache if there are waiters for that key, so I think that aspect of your change is correct, but I don't like the fact that waiters should be resolved at some point and maybe insert should be ordered behind the existing get?

I think it needs input from @Geal .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, we paired on this and it turns out to be a corner case we hit because the test runs in the single threaded flavor. the actual observable behavior is that if it ever happens, one(1) client will need to send the apq and the query once more, which is totally ok.

Moreover this allows us to /not/ send the value like that. the core issue stems from the fact that the cache assumes the first person who tries to get is going to insert, which doesn't apply to APQ.

@@ -79,6 +83,7 @@ async fn apq_request(
request.supergraph_request.body_mut().query = Some(cached_query);
Ok(request)
} else {
let _ = request.context.insert("persisted_query_miss", true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it still used ? I can't find the corresponding get. But if it's still relevant then please use a constant with some namespacing like apq::persisted_query_miss

NEXT_CHANGELOG.md Outdated Show resolved Hide resolved
o0Ignition0o and others added 2 commits January 31, 2023 12:08
Co-authored-by: Jesse Rosenberger <git@jro.cc>
@o0Ignition0o o0Ignition0o merged commit 9b8acdc into dev Jan 31, 2023
@o0Ignition0o o0Ignition0o deleted the igni/apq_cache_control branch January 31, 2023 11:45
abernix added a commit that referenced this pull request Feb 1, 2023
This follows up #2457 and
#2497 which
both attempted to update `libgit2-sys`.

The changeset of #2503
inadvertently resulted in a reversion of that version bump, which brought
back the offending version and upset our compliance check.

Thankfully, we have tooling that catches this stuff (even if it wasn't on
the PR itself).
abernix added a commit that referenced this pull request Feb 1, 2023
This follows up #2457 and
#2497 which both attempted
to update `libgit2-sys`.

The changeset of #2503
inadvertently resulted in a reversion of that version bump, which
brought back the offending version and upset our compliance check.

Thankfully, we have tooling that catches this stuff (even if it wasn't
on the PR itself).
@abernix abernix mentioned this pull request Feb 1, 2023
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.

APQ: Add cache-control header on PERSISTED_QUERY_NOT_FOUND
5 participants