jenkins-bot has submitted this change and it was merged.

Change subject: Replace DB begin()/commit() with startAtomic()/endAtomic() as 
needed
......................................................................


Replace DB begin()/commit() with startAtomic()/endAtomic() as needed

This removes batching adding a TODO / FIXME

Bug: T120791
Change-Id: Iccdaa72a2e439b07f06c230891dc42539d68f3ff
---
M includes/Contest.class.php
1 file changed, 6 insertions(+), 11 deletions(-)

Approvals:
  Addshore: Looks good to me, approved
  jenkins-bot: Verified



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: merged
Gerrit-Change-Id: Iccdaa72a2e439b07f06c230891dc42539d68f3ff
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Contest
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to