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

Preserve collection changes until transaction has succeeded #2635

Merged
merged 2 commits into from
May 10, 2024

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented May 10, 2024

Q A
Type bug
BC Break no
Fixed issues

Summary

While debugging test failures on sharded clusters, I noticed that UnitOfWork loses track of collection changes if a subsequent operation fails. This is due to collection snapshots being taken directly after a document operation, which means the collection sees itself as unmodified when the transaction is retried.

To fix this, we need to hold off on taking collection snapshots until all writes have completed. Unfortunately, this means that the behaviour for collections modified in post events changes. Previously, these collections were considered dirty, whereas they are now considered clean. Note that it is not advised to change documents in post, as other operations may or may not influenced by such operations, depending on execution order.

Fixing this would require us to compute collection changes way earlier in the flow, which would also change the expectation that changes to collections happening in pre events are properly handled. As there is no good way of fixing this, I'm more comfortable breaking the flow of changing collections in post rather than in pre.

@alcaeus alcaeus added the Bug label May 10, 2024
@alcaeus alcaeus added this to the 2.7.1 milestone May 10, 2024
@alcaeus alcaeus self-assigned this May 10, 2024
@alcaeus alcaeus force-pushed the fix-transaction-collection-snapshots branch from b58c270 to fa72250 Compare May 10, 2024 09:47
@alcaeus alcaeus force-pushed the fix-transaction-collection-snapshots branch from ca84d2b to 1b59ce8 Compare May 10, 2024 11:39
@alcaeus alcaeus requested a review from jmikola May 10, 2024 11:39
@alcaeus alcaeus enabled auto-merge (squash) May 10, 2024 11:43
@alcaeus alcaeus merged commit 3c49a87 into doctrine:2.7.x May 10, 2024
20 checks passed
@alcaeus alcaeus deleted the fix-transaction-collection-snapshots branch May 10, 2024 12:39
@alcaeus alcaeus removed the request for review from jmikola May 10, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants