Skip to content

Commit 6594360

Browse files
Merge pull request #42933 from nextcloud/fix/db/dirty-read-on-primary
fix(db): Execute dirty reads on the primary node
2 parents 7cb7b8b + 97152de commit 6594360

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/private/DB/Connection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ public function executeQuery(string $sql, array $params = [], $types = [], Query
285285
'exception' => new \Exception(),
286286
],
287287
);
288+
// To prevent a dirty read on a replica that is slightly out of sync, we
289+
// switch back to the primary. This is detrimental for performance but
290+
// safer for consistency.
291+
$this->ensureConnectedToPrimary();
288292
}
289293

290294
$sql = $this->replaceTablePrefix($sql);

0 commit comments

Comments
 (0)