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

fix(db): Do not log transacted reads as dirty read #42929

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

ChristophWurst
Copy link
Member

Summary

Starting a transaction makes \Doctrine\DBAL\Connections\PrimaryReadReplicaConnection::beginTransaction switch over to the primary. That means reading implicitly becomes safe because we are not connected to an outdated replica.

Reads are only dirty if data has been written to the primary within the same request and we are now reading from a replica.

How to test

tail -f nextcloud.log

master: lots of logs for dirty reads. On closer inspection the majority is written as dirty not because there was a preceding write but because there is an ongoing transaction.
here: only a few logs when we indeed write+read without a transaction within the same request.

Checklist

@ChristophWurst ChristophWurst added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jan 18, 2024
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@ChristophWurst ChristophWurst merged commit 033a654 into master Jan 23, 2024
50 checks passed
@ChristophWurst ChristophWurst deleted the fix/db/transacted-read-not-dirty branch January 23, 2024 08:34
@blizzz blizzz mentioned this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants