jenkins-bot has submitted this change and it was merged.
Change subject: [FileRepo] Changed LocalFile locking to avoid breaking
transactions.
......................................................................
[FileRepo] Changed LocalFile locking to avoid breaking transactions.
* Only BEGIN on lock() if no trx was in progress.
Likewise, only COMMIT in unlock() if the lock() call started a trx.
* This can avoid problems with commiting page update transactions
prematurely, which could leave broken page stub rows. (bug 40178)
Change-Id: I9a0adb25ee107df9a6bf70c6103ddfb7f034be25
---
M includes/filerepo/file/LocalFile.php
1 file changed, 8 insertions(+), 2 deletions(-)
Approvals:
Demon: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index ee49448..27386b4 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -71,6 +71,7 @@
$extraDataLoaded, # Whether or not lazy-loaded data has been
loaded from the database
$upgraded, # Whether the row was upgraded on load
$locked, # True if the image row is locked
+ $lockedOwnTrx, # True if the image row is locked with a
lock initiated transaction
$missing, # True if file is not present in file
system. Not to be cached in memcached
$deleted; # Bitfield akin to rev_deleted
@@ -1669,7 +1670,10 @@
$dbw = $this->repo->getMasterDB();
if ( !$this->locked ) {
- $dbw->begin( __METHOD__ );
+ if ( !$dbw->trxLevel() ) {
+ $dbw->begin( __METHOD__ );
+ $this->lockedOwnTrx = true;
+ }
$this->locked++;
}
@@ -1684,9 +1688,10 @@
function unlock() {
if ( $this->locked ) {
--$this->locked;
- if ( !$this->locked ) {
+ if ( !$this->locked && $this->lockedOwnTrx ) {
$dbw = $this->repo->getMasterDB();
$dbw->commit( __METHOD__ );
+ $this->lockedOwnTrx = false;
}
}
}
@@ -1698,6 +1703,7 @@
$this->locked = false;
$dbw = $this->repo->getMasterDB();
$dbw->rollback( __METHOD__ );
+ $this->lockedOwnTrx = false;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/50037
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9a0adb25ee107df9a6bf70c6103ddfb7f034be25
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Demon <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits