Skip to content

Commit a1da0a4

Browse files
fix(db): Execute dirty reads on the primary node
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
1 parent 1334055 commit a1da0a4

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
@@ -274,6 +274,10 @@ public function executeQuery(string $sql, array $params = [], $types = [], Query
274274
// Read to a table that was previously written to
275275
// While this might not necessarily mean that we did a read after write it is an indication for a code path to check
276276
$this->logger->debug('dirty table reads: ' . $sql, ['tables' => $this->tableDirtyWrites, 'reads' => $tables, 'exception' => new \Exception()]);
277+
// To prevent a dirty read on a replica that is slightly out of sync, we
278+
// switch back to the primary. This is detrimental for performance but
279+
// safer for consistency.
280+
$this->ensureConnectedToPrimary();
277281
}
278282

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

0 commit comments

Comments
 (0)