From 813133743d9ee02c58eb9b6012a9e312742c50e9 Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Mon, 5 Mar 2018 16:44:11 -0300 Subject: [PATCH] [JobQueueSecondTestQueue] Support read-only mode. In order to switch non-idempotent jobs without losing the backlog in redis we should support read-only mode in the queue, where the messages only gets written into the new queue. Change-Id: I2e9cb2d9cbbd2d657d042b55d4ea0819d21cdd6f --- includes/jobqueue/JobQueueSecondTestQueue.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/jobqueue/JobQueueSecondTestQueue.php b/includes/jobqueue/JobQueueSecondTestQueue.php index 4e3409af73..01f467f20b 100644 --- a/includes/jobqueue/JobQueueSecondTestQueue.php +++ b/includes/jobqueue/JobQueueSecondTestQueue.php @@ -27,6 +27,11 @@ class JobQueueSecondTestQueue extends JobQueue { */ private $debugQueue; + /** + * @var bool + */ + private $onlyWriteToDebugQueue; + protected function __construct( array $params ) { if ( !isset( $params['mainqueue'] ) ) { throw new MWException( "mainqueue parameter must be provided to the debug queue" ); @@ -39,6 +44,7 @@ class JobQueueSecondTestQueue extends JobQueue { $conf = [ 'wiki' => $params['wiki'], 'type' => $params['type'] ]; $this->mainQueue = JobQueue::factory( $params['mainqueue'] + $conf ); $this->debugQueue = JobQueue::factory( $params['debugqueue'] + $conf ); + $this->onlyWriteToDebugQueue = isset( $params['readonly'] ) ? $params['readonly'] : false; // We need to construct parent after creating the main and debug queue // because super constructor calls some methods we delegate to the main queue. @@ -118,7 +124,9 @@ class JobQueueSecondTestQueue extends JobQueue { * @param int $flags */ protected function doBatchPush( array $jobs, $flags ) { - $this->mainQueue->doBatchPush( $jobs, $flags ); + if ( !$this->onlyWriteToDebugQueue ) { + $this->mainQueue->doBatchPush( $jobs, $flags ); + } try { $this->debugQueue->doBatchPush( $jobs, $flags ); -- 2.20.1