Skip to content

Commit

Permalink
Merge pull request #42933 from nextcloud/fix/db/dirty-read-on-primary
Browse files Browse the repository at this point in the history
fix(db): Execute dirty reads on the primary node
  • Loading branch information
ChristophWurst authored Jan 31, 2024
2 parents 7cb7b8b + 97152de commit 6594360
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/private/DB/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ public function executeQuery(string $sql, array $params = [], $types = [], Query
'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);
Expand Down

0 comments on commit 6594360

Please sign in to comment.