Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/311386
Change subject: Code comment and style cleanups to MysqlLockManager ...................................................................... Code comment and style cleanups to MysqlLockManager Change-Id: Idf05c0c44f5f6fbb373625c0aebe015e385700ce --- M includes/filebackend/lockmanager/MySqlLockManager.php 1 file changed, 17 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/86/311386/1 diff --git a/includes/filebackend/lockmanager/MySqlLockManager.php b/includes/filebackend/lockmanager/MySqlLockManager.php index 441ffea..f4ff71e 100644 --- a/includes/filebackend/lockmanager/MySqlLockManager.php +++ b/includes/filebackend/lockmanager/MySqlLockManager.php @@ -2,7 +2,11 @@ /** * MySQL version of DBLockManager that supports shared locks. * - * All lock servers must have the innodb table defined in locking/filelocks.sql. + * Do NOT use this on connection handles that are also being used for anything + * else as the transaction isolation will be wrong and all the other changes will + * get rolled back when the locks release! + * + * All lock servers must have the innodb table defined in maintenance/locking/filelocks.sql. * All locks are non-blocking, which avoids deadlocks. * * @ingroup LockManager @@ -46,7 +50,7 @@ $keys[] = $key; $data[] = [ 'fls_key' => $key, 'fls_session' => $this->session ]; if ( !isset( $this->locksHeld[$path][self::LOCK_EX] ) ) { - $checkEXKeys[] = $key; + $checkEXKeys[] = $key; // this has no EX lock on $key itself } } @@ -54,13 +58,16 @@ $db->insert( 'filelocks_shared', $data, __METHOD__, [ 'IGNORE' ] ); # Actually do the locking queries... if ( $type == self::LOCK_SH ) { // reader locks - $blocked = false; # Bail if there are any existing writers... if ( count( $checkEXKeys ) ) { - $blocked = $db->selectField( 'filelocks_exclusive', '1', + $blocked = $db->selectField( + 'filelocks_exclusive', + '1', [ 'fle_key' => $checkEXKeys ], __METHOD__ ); + } else { + $blocked = false; } # Other prospective writers that haven't yet updated filelocks_exclusive # will recheck filelocks_shared after doing so and bail due to this entry. @@ -69,7 +76,9 @@ # Bail if there are any existing writers... # This may detect readers, but the safe check for them is below. # Note: if two writers come at the same time, both bail :) - $blocked = $db->selectField( 'filelocks_shared', '1', + $blocked = $db->selectField( + 'filelocks_shared', + '1', [ 'fls_key' => $keys, "fls_session != $encSession" ], __METHOD__ ); @@ -82,7 +91,9 @@ # Block new readers/writers... $db->insert( 'filelocks_exclusive', $data, __METHOD__ ); # Bail if there are any existing readers... - $blocked = $db->selectField( 'filelocks_shared', '1', + $blocked = $db->selectField( + 'filelocks_shared', + '1', [ 'fls_key' => $keys, "fls_session != $encSession" ], __METHOD__ ); -- To view, visit https://gerrit.wikimedia.org/r/311386 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idf05c0c44f5f6fbb373625c0aebe015e385700ce Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits