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

make possibly conflicting optimistic cache updates write to each other #1772

Merged
merged 2 commits into from
Dec 27, 2024

Conversation

huumn
Copy link
Member

@huumn huumn commented Dec 27, 2024

My theory as to why #1655 and #1669 occur is that an earlier and conflicting optimistic mutation fails while another optimistic mutation is in progress. When the optimistic mutation fails, it rolls back the cache to its initial state which causes the in-progress optimistic mutation to have its cache updates overwritten.

In the case of #1655, I believe that this occurs when an earlier zap (in a succession of zaps) fails. In the case of #1669, I believe this occurs when a poll is zapped, then voted on.

I've made the relevant cache updates write to each other. It's very hard to reproduce so I'm not sure I got all the relevant cache.modify calls, but I'll continue looking for any cache updates on the optimistic response path in the few places we do it (zaps/boosts/polls) ... it's unclear if there are consequences to doing it on every cache.modify call.


Update: I've made all the cache.modify calls on items update optimistic caches. This might be unnecessary overhead but afaict it shouldn't cause anything bad to happen, and should prevent optimistic rollbacks from affecting these cache updates.

@huumn
Copy link
Member Author

huumn commented Dec 27, 2024

I'm going to leave those issues open just in case this doesn't fix it.

@huumn huumn merged commit eb22fda into master Dec 27, 2024
6 checks passed
@huumn huumn deleted the maybe-fix-racing-apollo-cache branch December 27, 2024 20:52
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.

1 participant