From 97152de9bf496e2cb797dfc7ee694616ecac53db Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 18 Jan 2024 12:44:14 +0100 Subject: [PATCH] fix(db): Execute dirty reads on the primary node Signed-off-by: Christoph Wurst --- lib/private/DB/Connection.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 5affa2c3d48..ed322bc90f0 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -285,6 +285,10 @@ class Connection extends PrimaryReadReplicaConnection { 'exception' => new \Exception(), ], ); + // To prevent a dirty read on a replica that is slightly out of sync, we + // switch back to the primary. This is detrimental for performance but + // safer for consistency. + $this->ensureConnectedToPrimary(); } $sql = $this->replaceTablePrefix($sql); -- 2.39.5