Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/257532
Change subject: Replace DB begin()/commit() with startAtomic()/endAtomic() as
needed
......................................................................
Replace DB begin()/commit() with startAtomic()/endAtomic() as needed
Bug: T120791
Change-Id: Iccdaa72a2e439b07f06c230891dc42539d68f3ff
---
M includes/Contest.class.php
1 file changed, 6 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Contest
refs/changes/32/257532/1
diff --git a/includes/Contest.class.php b/includes/Contest.class.php
index aacf9a2..dc5b79e 100644
--- a/includes/Contest.class.php
+++ b/includes/Contest.class.php
@@ -337,14 +337,14 @@
$dbw = wfGetDB( DB_MASTER );
$success = true;
- $dbw->begin();
+ $dbw->startAtomic( __METHOD__ );
foreach ( $this->challenges as /* ContestChallenge */
$challenge ) {
$challenge->setField( 'contest_id', $this->getId() );
$success &= $challenge->writeToDB();
}
- $dbw->commit();
+ $dbw->endAtomic( __METHOD__ );
return $success;
}
@@ -363,21 +363,16 @@
$dbw = wfGetDB( DB_MASTER );
$success = true;
- $nr = 0;
- $dbw->begin();
-
+ $dbw->startAtomic( __METHOD__ );
+ // @TODO: this used to be batched but did not wait for slaves.
+ // If large inserts are needed, a proper Job class can be
written.
foreach ( $this->contestants as /* ContestContestant */
$contestant ) {
$contestant->setField( 'contest_id', $this->getId() );
$success &= $contestant->writeToDB();
-
- if ( ++$nr % 500 == 0 ) {
- $dbw->commit();
- $dbw->begin();
- }
}
- $dbw->commit();
+ $dbw->endAtomic( __METHOD__ );
return $success;
}
--
To view, visit https://gerrit.wikimedia.org/r/257532
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iccdaa72a2e439b07f06c230891dc42539d68f3ff
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Contest
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits