Query Cache mangled if saved by-reference#6552
Merged
derrabus merged 4 commits intodoctrine:4.2.xfrom Oct 21, 2024
Merged
Conversation
Member
|
We can probably solve this by cloning the |
Contributor
Author
I disagree: we have in production many long-running processes where this kind of cache is enough and more performant than the alternatives |
Member
|
I mean, you do you, but you're like asking for the kind of trouble that you see here. No other cache would behave this way. What you call "the by-reference tecnique" is simply put non-standard behavior. |
derrabus
reviewed
Oct 17, 2024
derrabus
approved these changes
Oct 21, 2024
Member
|
Thank you. |
derrabus
added a commit
that referenced
this pull request
Oct 21, 2024
* 4.3.x: Create stubs instead of mocks (#6564) [Bug] Query Cache mangled if saved by-reference (#6552) test: remove ->expects(self::any()) Fix typo in PostgreSql documentation reference fix Acknowledge the existence of 3.10 (#6553) Simplify tracking implicitly created indexes Remove handling unuique constraint column names as associative array (#6549) test: cover nested transactions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug emerged in #6510 (comment)
The current implementation of query cache relies on the cache not saved by-reference; the bug has never been seen before because by default
new ArrayAdapter()saves the cache with serialization, hence breaking the by-reference pointer.Once the by-reference tecnique is used, two issues pop up:
\Doctrine\DBAL\Cache\ArrayResult::$numis never reset, so once it gets incremented in the first\Doctrine\DBAL\Cache\ArrayResult::fetchcall, the following calls will always fail$numproperty reset, a manual call on\Doctrine\DBAL\Result::freewill by cascade call the\Doctrine\DBAL\Cache\ArrayResult::freemethod erasing all the saved resultsI think that the
ArrayResultimplementation is not the culprit, but rather the #6510 giving to the cache backend the internal object by reference instead of giving it a copy.