Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/305931
Change subject: Remove commit() hack from User::addToDatabase()
......................................................................
Remove commit() hack from User::addToDatabase()
This is likely not needed anymore to avoid deadlocks anymore
as AuthManagar uses a lock in autoCreateUser() before hand.
Change-Id: I19ae6562011854495efcb0dd832b7ae99ebbb224
---
M includes/user/User.php
1 file changed, 9 insertions(+), 18 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/31/305931/1
diff --git a/includes/user/User.php b/includes/user/User.php
index 83cfa40..2f2d5d8 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -3961,7 +3961,6 @@
$noPass = PasswordFactory::newInvalidPassword()->toString();
$dbw = wfGetDB( DB_MASTER );
- $inWrite = $dbw->writesOrCallbacksPending();
$seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
$dbw->insert( 'user',
[
@@ -3980,25 +3979,17 @@
[ 'IGNORE' ]
);
if ( !$dbw->affectedRows() ) {
- // The queries below cannot happen in the same
REPEATABLE-READ snapshot.
- // Handle this by COMMIT, if possible, or by LOCK IN
SHARE MODE otherwise.
- if ( $inWrite ) {
- // Can't commit due to pending writes that may
need atomicity.
- // This may cause some lock contention unlike
the case below.
- $options = [ 'LOCK IN SHARE MODE' ];
- $flags = self::READ_LOCKING;
- } else {
- // Often, this case happens early in views
before any writes when
- // using CentralAuth. It's should be OK to
commit and break the snapshot.
- $dbw->commit( __METHOD__, 'flush' );
- $options = [];
- $flags = self::READ_LATEST;
- }
- $this->mId = $dbw->selectField( 'user', 'user_id',
- [ 'user_name' => $this->mName ], __METHOD__,
$options );
+ // Use locking reads to bypass any REPEATABLE-READ
snapshot.
+ $this->mId = $dbw->selectField(
+ 'user',
+ 'user_id',
+ [ 'user_name' => $this->mName ],
+ __METHOD__,
+ [ 'LOCK IN SHARE MODE' ]
+ );
$loaded = false;
if ( $this->mId ) {
- if ( $this->loadFromDatabase( $flags ) ) {
+ if ( $this->loadFromDatabase(
self::READ_LOCKING ) ) {
$loaded = true;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/305931
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I19ae6562011854495efcb0dd832b7ae99ebbb224
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits