diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2024-01-23 09:34:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 09:34:20 +0100 |
commit | 033a654389f026c7690294db080ef4e2e69aea73 (patch) | |
tree | 0799bbe6ef1d1d73ed096f908802d52de0392182 /lib/private/DB | |
parent | 9bce24bf0fa7b5d6a47fc5b7cacd9c118a4a18ca (diff) | |
parent | f54b08c2248149ccdb3cfc18fd87655c2eed9ca2 (diff) | |
download | nextcloud-server-033a654389f026c7690294db080ef4e2e69aea73.tar.gz nextcloud-server-033a654389f026c7690294db080ef4e2e69aea73.zip |
Merge pull request #42929 from nextcloud/fix/db/transacted-read-not-dirty
fix(db): Do not log transacted reads as dirty read
Diffstat (limited to 'lib/private/DB')
-rw-r--r-- | lib/private/DB/Connection.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index e55de12f18c..09c321aedb8 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -265,13 +265,16 @@ class Connection extends PrimaryReadReplicaConnection { */ public function executeQuery(string $sql, array $params = [], $types = [], QueryCacheProfile $qcp = null): Result { $tables = $this->getQueriedTables($sql); - if (count(array_intersect($this->tableDirtyWrites, $tables)) === 0 && !$this->isTransactionActive()) { + if ($this->isTransactionActive()) { + // Transacted queries go to the primary. The consistency of the primary guarantees that we can not run + // into a dirty read. + } elseif (count(array_intersect($this->tableDirtyWrites, $tables)) === 0) { // No tables read that could have been written already in the same request and no transaction active // so we can switch back to the replica for reading as long as no writes happen that switch back to the primary // We cannot log here as this would log too early in the server boot process $this->ensureConnectedToReplica(); } else { - // Read to a table that was previously written to + // Read to a table that has been written to previously // While this might not necessarily mean that we did a read after write it is an indication for a code path to check $this->logger->debug('dirty table reads: ' . $sql, ['tables' => $this->tableDirtyWrites, 'reads' => $tables, 'exception' => new \Exception()]); } |