[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_29]: Use AutoCommitUpdate instead of Database->onTransactionIdle

2017-06-08 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/357560 )

Change subject: Use AutoCommitUpdate instead of Database->onTransactionIdle
..


Use AutoCommitUpdate instead of Database->onTransactionIdle

This is needed for deferred updates LinksDeletionUpdate and LinksUpdate, else
callbacks registered with onTransactionIdle prevent other transactions from
being executed, at least in this case.

Bug: T154425
Bug: T154438
Bug: T157679
Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
(cherry picked from commit 24842cfac0f392e2ba60dfcbf419d89c8895c7ed)
---
M includes/MediaWiki.php
M includes/jobqueue/JobQueueDB.php
M includes/jobqueue/JobQueueGroup.php
M includes/jobqueue/JobRunner.php
4 files changed, 17 insertions(+), 15 deletions(-)

Approvals:
  Seb35: Looks good to me, but someone else must approve
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index b80bcab..8dab16b 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -898,11 +898,12 @@
__METHOD__
);
 
+   // Push lazilly-pushed jobs
+   // Important: this must be the last deferred update added 
(T100085, T154425)
+   DeferredUpdates::addCallableUpdate( [ 'JobQueueGroup', 
'pushLazyJobs' ] );
+
// Do any deferred jobs
DeferredUpdates::doUpdates( 'enqueue' );
-
-   // Make sure any lazy jobs are pushed
-   JobQueueGroup::pushLazyJobs();
 
// Now that everything specific to this request is done,
// try to occasionally run jobs (if enabled) from the queues
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index 924aacc..5e45730 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -185,15 +185,13 @@
 * @return void
 */
protected function doBatchPush( array $jobs, $flags ) {
-   $dbw = $this->getMasterDB();
-
-   $method = __METHOD__;
-   $dbw->onTransactionIdle(
-   function () use ( $dbw, $jobs, $flags, $method ) {
-   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $method );
-   },
-   __METHOD__
-   );
+   DeferredUpdates::addUpdate( new AutoCommitUpdate(
+   wfGetDB( DB_MASTER ),
+   __METHOD__,
+   function ( IDatabase $dbw, $fname ) use ( $jobs, $flags 
) {
+   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $fname );
+   }
+   ) );
}
 
/**
diff --git a/includes/jobqueue/JobQueueGroup.php 
b/includes/jobqueue/JobQueueGroup.php
index 9f78404..5d5ea26 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -163,7 +163,9 @@
/**
 * Buffer jobs for insertion via push() or call it now if in CLI mode
 *
-* Note that MediaWiki::restInPeace() calls pushLazyJobs()
+* Note that pushLazyJobs() is registered as a deferred update just 
before
+* DeferredUpdates::doUpdates() in MediaWiki and JobRunner classes in 
order
+* to be executed as the very last deferred update (T100085, T154425).
 *
 * @param IJobSpecification|IJobSpecification[] $jobs A single Job or a 
list of Jobs
 * @return void
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index a1aeaba..0a0e9e0 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -289,10 +289,11 @@
$status = $job->run();
$error = $job->getLastError();
$this->commitMasterChanges( $lbFactory, $job, 
$fnameTrxOwner );
+   // Push lazilly-pushed jobs
+   // Important: this must be the last deferred update 
added (T100085, T154425)
+   DeferredUpdates::addCallableUpdate( [ 'JobQueueGroup', 
'pushLazyJobs' ] );
// Run any deferred update tasks; doUpdates() manages 
transactions itself
DeferredUpdates::doUpdates();
-   // Push lazy jobs added by the job or its deferred 
udpates
-   JobQueueGroup::pushLazyJobs();
} catch ( Exception $e ) {
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
$status = false;

-- 
To view, visit https://gerrit.wikimedia.org/r/357560
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
Gerrit-PatchSet: 1
Gerrit-Project: 

[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_29]: Use AutoCommitUpdate instead of Database->onTransactionIdle

2017-06-07 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357560 )

Change subject: Use AutoCommitUpdate instead of Database->onTransactionIdle
..

Use AutoCommitUpdate instead of Database->onTransactionIdle

This is needed for deferred updates LinksDeletionUpdate and LinksUpdate, else
callbacks registered with onTransactionIdle prevent other transactions from
being executed, at least in this case.

Bug: T154425
Bug: T154438
Bug: T157679
Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
(cherry picked from commit 24842cfac0f392e2ba60dfcbf419d89c8895c7ed)
---
M includes/MediaWiki.php
M includes/jobqueue/JobQueueDB.php
M includes/jobqueue/JobQueueGroup.php
M includes/jobqueue/JobRunner.php
4 files changed, 17 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/60/357560/1

diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index b80bcab..8dab16b 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -898,11 +898,12 @@
__METHOD__
);
 
+   // Push lazilly-pushed jobs
+   // Important: this must be the last deferred update added 
(T100085, T154425)
+   DeferredUpdates::addCallableUpdate( [ 'JobQueueGroup', 
'pushLazyJobs' ] );
+
// Do any deferred jobs
DeferredUpdates::doUpdates( 'enqueue' );
-
-   // Make sure any lazy jobs are pushed
-   JobQueueGroup::pushLazyJobs();
 
// Now that everything specific to this request is done,
// try to occasionally run jobs (if enabled) from the queues
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index 924aacc..5e45730 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -185,15 +185,13 @@
 * @return void
 */
protected function doBatchPush( array $jobs, $flags ) {
-   $dbw = $this->getMasterDB();
-
-   $method = __METHOD__;
-   $dbw->onTransactionIdle(
-   function () use ( $dbw, $jobs, $flags, $method ) {
-   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $method );
-   },
-   __METHOD__
-   );
+   DeferredUpdates::addUpdate( new AutoCommitUpdate(
+   wfGetDB( DB_MASTER ),
+   __METHOD__,
+   function ( IDatabase $dbw, $fname ) use ( $jobs, $flags 
) {
+   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $fname );
+   }
+   ) );
}
 
/**
diff --git a/includes/jobqueue/JobQueueGroup.php 
b/includes/jobqueue/JobQueueGroup.php
index 9f78404..5d5ea26 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -163,7 +163,9 @@
/**
 * Buffer jobs for insertion via push() or call it now if in CLI mode
 *
-* Note that MediaWiki::restInPeace() calls pushLazyJobs()
+* Note that pushLazyJobs() is registered as a deferred update just 
before
+* DeferredUpdates::doUpdates() in MediaWiki and JobRunner classes in 
order
+* to be executed as the very last deferred update (T100085, T154425).
 *
 * @param IJobSpecification|IJobSpecification[] $jobs A single Job or a 
list of Jobs
 * @return void
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index a1aeaba..0a0e9e0 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -289,10 +289,11 @@
$status = $job->run();
$error = $job->getLastError();
$this->commitMasterChanges( $lbFactory, $job, 
$fnameTrxOwner );
+   // Push lazilly-pushed jobs
+   // Important: this must be the last deferred update 
added (T100085, T154425)
+   DeferredUpdates::addCallableUpdate( [ 'JobQueueGroup', 
'pushLazyJobs' ] );
// Run any deferred update tasks; doUpdates() manages 
transactions itself
DeferredUpdates::doUpdates();
-   // Push lazy jobs added by the job or its deferred 
udpates
-   JobQueueGroup::pushLazyJobs();
} catch ( Exception $e ) {
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
$status = false;

-- 
To view, visit https://gerrit.wikimedia.org/r/357560
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_29
Gerrit-Owner: Seb35