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

Ensure that failed unis are not cached #39762

Merged
merged 1 commit into from
Mar 28, 2024
Merged

Ensure that failed unis are not cached #39762

merged 1 commit into from
Mar 28, 2024

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Mar 28, 2024

@geoand
Copy link
Contributor Author

geoand commented Mar 28, 2024

@cescoffier does this seems correct to you?

I did a few manual tests and it does seem to behave correctly. If you agree, I can look into adding a test

@cescoffier
Copy link
Member

A test would be good.

@geoand
Copy link
Contributor Author

geoand commented Mar 28, 2024

Test added

@geoand geoand marked this pull request as ready for review March 28, 2024 09:36
@geoand geoand added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Mar 28, 2024
@geoand geoand merged commit b18f8d6 into quarkusio:main Mar 28, 2024
34 of 36 checks passed
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Mar 28, 2024
@geoand geoand deleted the #39677 branch March 28, 2024 10:14
@quarkus-bot quarkus-bot bot added this to the 3.10 - main milestone Mar 28, 2024
Copy link

quarkus-bot bot commented Mar 28, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit fdcac73.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@gsmet gsmet modified the milestones: 3.10 - main, 3.8.4 Apr 2, 2024
@gsmet gsmet modified the milestones: 3.8.4, 3.9.2 Apr 11, 2024
@gsmet
Copy link
Member

gsmet commented Apr 11, 2024

Made it clear that it was also backported to 3.9.2.

}).onFailure().call(new Function<>() {
@Override
public Uni<?> apply(Throwable throwable) {
return cache.invalidate(key).replaceWith(throwable);
Copy link
Member

Choose a reason for hiding this comment

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

I was considering backporting this one and I have a question: my understanding is that we invalidate the cache key if we have an error?
I would expect us to not store anything in this case? And thus we wouldn't have to invalidate the cache? I'm especially worried in the case of concurrent accesses because I wouldn't expect us to invalidate a cache entry that could have been stored from another thread.

Now it's reactive code so I'm not understanding exactly what it does but this concerns me a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your understanding is correct, but given the API, I am not sure how it can be done differently

Copy link
Member

Choose a reason for hiding this comment

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

Yeah my problem is that again IIUC we have a very short period of time when the error is cached so another thread can get it.
Also we have a short period of time when we might invalidate an actually valid key but this is probably more theoretical (as I wouldn't expect another thread to store a cache entry) and less problematic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's certainly true

Copy link
Member

Choose a reason for hiding this comment

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

@gwenneg could we have some feedback from you here? Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

@gsmet, you are right. There is a chance to have concurrent access and replace a correct value. Reactive or not does not change anything here.

For Redis, we could imagine using a Redis transaction (be careful, it is not a database transaction). For others, I'm not sure. We could imagine adding an atomic operation doing this.

@gsmet gsmet removed this from the 3.8.4 milestone Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quarkus caches Failures
3 participants