3 * Redis-backed job queue code.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @author Aaron Schulz
25 * Class to handle job queues stored in Redis
27 * This is faster, less resource intensive, queue that JobQueueDB.
28 * All data for a queue using this class is placed into one redis server.
30 * There are eight main redis keys used to track jobs:
31 * - l-unclaimed : A list of job IDs used for ready unclaimed jobs
32 * - z-claimed : A sorted set of (job ID, UNIX timestamp as score) used for job retries
33 * - z-abandoned : A sorted set of (job ID, UNIX timestamp as score) used for broken jobs
34 * - z-delayed : A sorted set of (job ID, UNIX timestamp as score) used for delayed jobs
35 * - h-idBySha1 : A hash of (SHA1 => job ID) for unclaimed jobs used for de-duplication
36 * - h-sha1ById : A hash of (job ID => SHA1) for unclaimed jobs used for de-duplication
37 * - h-attempts : A hash of (job ID => attempt count) used for job claiming/retries
38 * - h-data : A hash of (job ID => serialized blobs) for job storage
39 * A job ID can be in only one of z-delayed, l-unclaimed, z-claimed, and z-abandoned.
40 * If an ID appears in any of those lists, it should have a h-data entry for its ID.
41 * If a job has a SHA1 de-duplication value and its ID is in l-unclaimed or z-delayed, then
42 * there should be no other such jobs with that SHA1. Every h-idBySha1 entry has an h-sha1ById
43 * entry and every h-sha1ById must refer to an ID that is l-unclaimed. If a job has its
44 * ID in z-claimed or z-abandoned, then it must also have an h-attempts entry for its ID.
46 * Additionally, "rootjob:* keys track "root jobs" used for additional de-duplication.
47 * Aside from root job keys, all keys have no expiry, and are only removed when jobs are run.
48 * All the keys are prefixed with the relevant wiki ID information.
50 * This class requires Redis 2.6 as it makes use Lua scripts for fast atomic operations.
51 * Additionally, it should be noted that redis has different persistence modes, such
52 * as rdb snapshots, journaling, and no persistent. Appropriate configuration should be
53 * made on the servers based on what queues are using it and what tolerance they have.
59 class JobQueueRedis
extends JobQueue
{
60 /** @var RedisConnectionPool */
63 protected $server; // string; server address
65 const MAX_AGE_PRUNE
= 604800; // integer; seconds a job can live once claimed (7 days)
67 protected $key; // string; key to prefix the queue keys with (used for testing)
71 * - redisConfig : An array of parameters to RedisConnectionPool::__construct().
72 * Note that the serializer option is ignored "none" is always used.
73 * - redisServer : A hostname/port combination or the absolute path of a UNIX socket.
74 * If a hostname is specified but no port, the standard port number
75 * 6379 will be used. Required.
76 * @param array $params
78 public function __construct( array $params ) {
79 parent
::__construct( $params );
80 $params['redisConfig']['serializer'] = 'none'; // make it easy to use Lua
81 $this->server
= $params['redisServer'];
82 $this->redisPool
= RedisConnectionPool
::singleton( $params['redisConfig'] );
85 protected function supportedOrders() {
86 return array( 'timestamp', 'fifo' );
89 protected function optimalOrder() {
93 protected function supportsDelayedJobs() {
98 * @see JobQueue::doIsEmpty()
100 * @throws MWException
102 protected function doIsEmpty() {
103 return $this->doGetSize() == 0;
107 * @see JobQueue::doGetSize()
109 * @throws MWException
111 protected function doGetSize() {
112 $conn = $this->getConnection();
114 return $conn->lSize( $this->getQueueKey( 'l-unclaimed' ) );
115 } catch ( RedisException
$e ) {
116 $this->throwRedisException( $this->server
, $conn, $e );
121 * @see JobQueue::doGetAcquiredCount()
123 * @throws MWException
125 protected function doGetAcquiredCount() {
126 if ( $this->claimTTL
<= 0 ) {
127 return 0; // no acknowledgements
129 $conn = $this->getConnection();
131 $conn->multi( Redis
::PIPELINE
);
132 $conn->zSize( $this->getQueueKey( 'z-claimed' ) );
133 $conn->zSize( $this->getQueueKey( 'z-abandoned' ) );
134 return array_sum( $conn->exec() );
135 } catch ( RedisException
$e ) {
136 $this->throwRedisException( $this->server
, $conn, $e );
141 * @see JobQueue::doGetDelayedCount()
143 * @throws MWException
145 protected function doGetDelayedCount() {
146 if ( !$this->checkDelay
) {
147 return 0; // no delayed jobs
149 $conn = $this->getConnection();
151 return $conn->zSize( $this->getQueueKey( 'z-delayed' ) );
152 } catch ( RedisException
$e ) {
153 $this->throwRedisException( $this->server
, $conn, $e );
158 * @see JobQueue::doGetAbandonedCount()
160 * @throws MWException
162 protected function doGetAbandonedCount() {
163 if ( $this->claimTTL
<= 0 ) {
164 return 0; // no acknowledgements
166 $conn = $this->getConnection();
168 return $conn->zSize( $this->getQueueKey( 'z-abandoned' ) );
169 } catch ( RedisException
$e ) {
170 $this->throwRedisException( $this->server
, $conn, $e );
175 * @see JobQueue::doBatchPush()
179 * @throws MWException
181 protected function doBatchPush( array $jobs, $flags ) {
182 // Convert the jobs into field maps (de-duplicated against each other)
183 $items = array(); // (job ID => job fields map)
184 foreach ( $jobs as $job ) {
185 $item = $this->getNewJobFields( $job );
186 if ( strlen( $item['sha1'] ) ) { // hash identifier => de-duplicate
187 $items[$item['sha1']] = $item;
189 $items[$item['uuid']] = $item;
193 if ( !count( $items ) ) {
194 return true; // nothing to do
197 $conn = $this->getConnection();
199 // Actually push the non-duplicate jobs into the queue...
200 if ( $flags & self
::QOS_ATOMIC
) {
201 $batches = array( $items ); // all or nothing
203 $batches = array_chunk( $items, 500 ); // avoid tying up the server
207 foreach ( $batches as $itemBatch ) {
208 $added = $this->pushBlobs( $conn, $itemBatch );
209 if ( is_int( $added ) ) {
212 $failed +
= count( $itemBatch );
216 wfDebugLog( 'JobQueueRedis', "Could not insert {$failed} {$this->type} job(s)." );
219 wfIncrStats( 'job-insert', count( $items ) );
220 wfIncrStats( 'job-insert-duplicate', count( $items ) - $failed - $pushed );
221 } catch ( RedisException
$e ) {
222 $this->throwRedisException( $this->server
, $conn, $e );
229 * @param RedisConnRef $conn
230 * @param array $items List of results from JobQueueRedis::getNewJobFields()
231 * @return integer Number of jobs inserted (duplicates are ignored)
232 * @throws RedisException
234 protected function pushBlobs( RedisConnRef
$conn, array $items ) {
235 $args = array(); // ([id, sha1, rtime, blob [, id, sha1, rtime, blob ... ] ] )
236 foreach ( $items as $item ) {
237 $args[] = (string)$item['uuid'];
238 $args[] = (string)$item['sha1'];
239 $args[] = (string)$item['rtimestamp'];
240 $args[] = (string)serialize( $item );
244 if #ARGV % 4 ~= 0 then return redis.error_reply('Unmatched arguments') end
247 local id,sha1,rtimestamp,blob = ARGV[i],ARGV[i+1],ARGV[i+2],ARGV[i+3]
248 if sha1 == '' or redis.call('hExists',KEYS[3],sha1) == 0 then
249 if 1*rtimestamp > 0 then
250 -- Insert into delayed queue (release time as score)
251 redis.call('zAdd',KEYS[4],rtimestamp,id)
253 -- Insert into unclaimed queue
254 redis.call('lPush',KEYS[1],id)
257 redis.call('hSet',KEYS[2],id,sha1)
258 redis.call('hSet',KEYS[3],sha1,id)
260 redis.call('hSet',KEYS[5],id,blob)
266 return $this->redisEval( $conn, $script,
269 $this->getQueueKey( 'l-unclaimed' ), # KEYS[1]
270 $this->getQueueKey( 'h-sha1ById' ), # KEYS[2]
271 $this->getQueueKey( 'h-idBySha1' ), # KEYS[3]
272 $this->getQueueKey( 'z-delayed' ), # KEYS[4]
273 $this->getQueueKey( 'h-data' ), # KEYS[5]
277 5 # number of first argument(s) that are keys
282 * @see JobQueue::doPop()
284 * @throws MWException
286 protected function doPop() {
289 // Push ready delayed jobs into the queue every 10 jobs to spread the load.
290 // This is also done as a periodic task, but we don't want too much done at once.
291 if ( $this->checkDelay
&& mt_rand( 0, 9 ) == 0 ) {
292 $this->releaseReadyDelayedJobs();
295 $conn = $this->getConnection();
298 if ( $this->claimTTL
> 0 ) {
299 // Keep the claimed job list down for high-traffic queues
300 if ( mt_rand( 0, 99 ) == 0 ) {
301 $this->recycleAndDeleteStaleJobs();
303 $blob = $this->popAndAcquireBlob( $conn );
305 $blob = $this->popAndDeleteBlob( $conn );
307 if ( $blob === false ) {
308 break; // no jobs; nothing to do
311 wfIncrStats( 'job-pop' );
312 $item = unserialize( $blob );
313 if ( $item === false ) {
314 wfDebugLog( 'JobQueueRedis', "Could not unserialize {$this->type} job." );
318 // If $item is invalid, recycleAndDeleteStaleJobs() will cleanup as needed
319 $job = $this->getJobFromFields( $item ); // may be false
320 } while ( !$job ); // job may be false if invalid
321 } catch ( RedisException
$e ) {
322 $this->throwRedisException( $this->server
, $conn, $e );
329 * @param RedisConnRef $conn
330 * @return array serialized string or false
331 * @throws RedisException
333 protected function popAndDeleteBlob( RedisConnRef
$conn ) {
336 -- Pop an item off the queue
337 local id = redis.call('rpop',KEYS[1])
338 if not id then return false end
339 -- Get the job data and remove it
340 local item = redis.call('hGet',KEYS[4],id)
341 redis.call('hDel',KEYS[4],id)
342 -- Allow new duplicates of this job
343 local sha1 = redis.call('hGet',KEYS[2],id)
344 if sha1 then redis.call('hDel',KEYS[3],sha1) end
345 redis.call('hDel',KEYS[2],id)
346 -- Return the job data
349 return $this->redisEval( $conn, $script,
351 $this->getQueueKey( 'l-unclaimed' ), # KEYS[1]
352 $this->getQueueKey( 'h-sha1ById' ), # KEYS[2]
353 $this->getQueueKey( 'h-idBySha1' ), # KEYS[3]
354 $this->getQueueKey( 'h-data' ), # KEYS[4]
356 4 # number of first argument(s) that are keys
361 * @param RedisConnRef $conn
362 * @return array serialized string or false
363 * @throws RedisException
365 protected function popAndAcquireBlob( RedisConnRef
$conn ) {
368 -- Pop an item off the queue
369 local id = redis.call('rPop',KEYS[1])
370 if not id then return false end
371 -- Allow new duplicates of this job
372 local sha1 = redis.call('hGet',KEYS[2],id)
373 if sha1 then redis.call('hDel',KEYS[3],sha1) end
374 redis.call('hDel',KEYS[2],id)
375 -- Mark the jobs as claimed and return it
376 redis.call('zAdd',KEYS[4],ARGV[1],id)
377 redis.call('hIncrBy',KEYS[5],id,1)
378 return redis.call('hGet',KEYS[6],id)
380 return $this->redisEval( $conn, $script,
382 $this->getQueueKey( 'l-unclaimed' ), # KEYS[1]
383 $this->getQueueKey( 'h-sha1ById' ), # KEYS[2]
384 $this->getQueueKey( 'h-idBySha1' ), # KEYS[3]
385 $this->getQueueKey( 'z-claimed' ), # KEYS[4]
386 $this->getQueueKey( 'h-attempts' ), # KEYS[5]
387 $this->getQueueKey( 'h-data' ), # KEYS[6]
388 time(), # ARGV[1] (injected to be replication-safe)
390 6 # number of first argument(s) that are keys
395 * @see JobQueue::doAck()
398 * @throws MWException
400 protected function doAck( Job
$job ) {
401 if ( $this->claimTTL
> 0 ) {
402 $conn = $this->getConnection();
404 // Get the exact field map this Job came from, regardless of whether
405 // the job was transformed into a DuplicateJob or anything of the sort.
406 $item = $job->metadata
['sourceFields'];
410 -- Unmark the job as claimed
411 redis.call('zRem',KEYS[1],ARGV[1])
412 redis.call('hDel',KEYS[2],ARGV[1])
413 -- Delete the job data itself
414 return redis.call('hDel',KEYS[3],ARGV[1])
416 $res = $this->redisEval( $conn, $script,
418 $this->getQueueKey( 'z-claimed' ), # KEYS[1]
419 $this->getQueueKey( 'h-attempts' ), # KEYS[2]
420 $this->getQueueKey( 'h-data' ), # KEYS[3]
421 $item['uuid'] # ARGV[1]
423 3 # number of first argument(s) that are keys
427 wfDebugLog( 'JobQueueRedis', "Could not acknowledge {$this->type} job." );
430 } catch ( RedisException
$e ) {
431 $this->throwRedisException( $this->server
, $conn, $e );
438 * @see JobQueue::doDeduplicateRootJob()
441 * @throws MWException
443 protected function doDeduplicateRootJob( Job
$job ) {
444 if ( !$job->hasRootJobParams() ) {
445 throw new MWException( "Cannot register root job; missing parameters." );
447 $params = $job->getRootJobParams();
449 $key = $this->getRootJobCacheKey( $params['rootJobSignature'] );
451 $conn = $this->getConnection();
453 $timestamp = $conn->get( $key ); // current last timestamp of this job
454 if ( $timestamp && $timestamp >= $params['rootJobTimestamp'] ) {
455 return true; // a newer version of this root job was enqueued
457 // Update the timestamp of the last root job started at the location...
458 return $conn->set( $key, $params['rootJobTimestamp'], self
::ROOTJOB_TTL
); // 2 weeks
459 } catch ( RedisException
$e ) {
460 $this->throwRedisException( $this->server
, $conn, $e );
465 * @see JobQueue::doIsRootJobOldDuplicate()
469 protected function doIsRootJobOldDuplicate( Job
$job ) {
470 if ( !$job->hasRootJobParams() ) {
471 return false; // job has no de-deplication info
473 $params = $job->getRootJobParams();
475 $conn = $this->getConnection();
477 // Get the last time this root job was enqueued
478 $timestamp = $conn->get( $this->getRootJobCacheKey( $params['rootJobSignature'] ) );
479 } catch ( RedisException
$e ) {
480 $this->throwRedisException( $this->server
, $conn, $e );
483 // Check if a new root job was started at the location after this one's...
484 return ( $timestamp && $timestamp > $params['rootJobTimestamp'] );
488 * @see JobQueue::getAllQueuedJobs()
491 public function getAllQueuedJobs() {
492 $conn = $this->getConnection();
495 return new MappedIterator(
496 $conn->lRange( $this->getQueueKey( 'l-unclaimed' ), 0, -1 ),
497 function( $uid ) use ( $that, $conn ) {
498 return $that->getJobFromUidInternal( $uid, $conn );
501 } catch ( RedisException
$e ) {
502 $this->throwRedisException( $this->server
, $conn, $e );
507 * @see JobQueue::getAllQueuedJobs()
510 public function getAllDelayedJobs() {
511 $conn = $this->getConnection();
514 return new MappedIterator( // delayed jobs
515 $conn->zRange( $this->getQueueKey( 'z-delayed' ), 0, -1 ),
516 function( $uid ) use ( $that, $conn ) {
517 return $that->getJobFromUidInternal( $uid, $conn );
520 } catch ( RedisException
$e ) {
521 $this->throwRedisException( $this->server
, $conn, $e );
526 * This function should not be called outside JobQueueRedis
529 * @param $conn RedisConnRef
531 * @throws MWException
533 public function getJobFromUidInternal( $uid, RedisConnRef
$conn ) {
535 $item = unserialize( $conn->hGet( $this->getQueueKey( 'h-data' ), $uid ) );
536 if ( !is_array( $item ) ) { // this shouldn't happen
537 throw new MWException( "Could not find job with ID '$uid'." );
539 $title = Title
::makeTitle( $item['namespace'], $item['title'] );
540 $job = Job
::factory( $item['type'], $title, $item['params'] );
541 $job->metadata
['sourceFields'] = $item;
543 } catch ( RedisException
$e ) {
544 $this->throwRedisException( $this->server
, $conn, $e );
549 * Release any ready delayed jobs into the queue
551 * @return integer Number of jobs released
552 * @throws MWException
554 public function releaseReadyDelayedJobs() {
557 $conn = $this->getConnection();
561 -- Get the list of ready delayed jobs, sorted by readiness
562 local ids = redis.call('zRangeByScore',KEYS[1],0,ARGV[1])
563 -- Migrate the jobs from the "delayed" set to the "unclaimed" list
564 for k,id in ipairs(ids) do
565 redis.call('lPush',KEYS[2],id)
566 redis.call('zRem',KEYS[1],id)
570 $count +
= (int)$this->redisEval( $conn, $script,
572 $this->getQueueKey( 'z-delayed' ), // KEYS[1]
573 $this->getQueueKey( 'l-unclaimed' ), // KEYS[2]
574 time() // ARGV[1]; max "delay until" UNIX timestamp
576 2 # first two arguments are keys
578 } catch ( RedisException
$e ) {
579 $this->throwRedisException( $this->server
, $conn, $e );
586 * Recycle or destroy any jobs that have been claimed for too long
588 * @return integer Number of jobs recycled/deleted
589 * @throws MWException
591 public function recycleAndDeleteStaleJobs() {
592 if ( $this->claimTTL
<= 0 ) { // sanity
593 throw new MWException( "Cannot recycle jobs since acknowledgements are disabled." );
596 // For each job item that can be retried, we need to add it back to the
597 // main queue and remove it from the list of currenty claimed job items.
598 // For those that cannot, they are marked as dead and kept around for
599 // investigation and manual job restoration but are eventually deleted.
600 $conn = $this->getConnection();
605 local released,abandoned,pruned = 0,0,0
606 -- Get all non-dead jobs that have an expired claim on them.
607 -- The score for each item is the last claim timestamp (UNIX).
608 local staleClaims = redis.call('zRangeByScore',KEYS[1],0,ARGV[1])
609 for k,id in ipairs(staleClaims) do
610 local timestamp = redis.call('zScore',KEYS[1],id)
611 local attempts = redis.call('hGet',KEYS[2],id)
612 if attempts < ARGV[3] then
613 -- Claim expired and retries left: re-enqueue the job
614 redis.call('lPush',KEYS[3],id)
615 redis.call('hIncrBy',KEYS[2],id,1)
616 released = released + 1
618 -- Claim expired and no retries left: mark the job as dead
619 redis.call('zAdd',KEYS[5],timestamp,id)
620 abandoned = abandoned + 1
622 redis.call('zRem',KEYS[1],id)
624 -- Get all of the dead jobs that have been marked as dead for too long.
625 -- The score for each item is the last claim timestamp (UNIX).
626 local deadClaims = redis.call('zRangeByScore',KEYS[5],0,ARGV[2])
627 for k,id in ipairs(deadClaims) do
628 -- Stale and out of retries: remove any traces of the job
629 redis.call('zRem',KEYS[5],id)
630 redis.call('hDel',KEYS[2],id)
631 redis.call('hDel',KEYS[4],id)
634 return {released,abandoned,pruned}
636 $res = $this->redisEval( $conn, $script,
638 $this->getQueueKey( 'z-claimed' ), # KEYS[1]
639 $this->getQueueKey( 'h-attempts' ), # KEYS[2]
640 $this->getQueueKey( 'l-unclaimed' ), # KEYS[3]
641 $this->getQueueKey( 'h-data' ), # KEYS[4]
642 $this->getQueueKey( 'z-abandoned' ), # KEYS[5]
643 $now - $this->claimTTL
, # ARGV[1]
644 $now - self
::MAX_AGE_PRUNE
, # ARGV[2]
645 $this->maxTries
# ARGV[3]
647 5 # number of first argument(s) that are keys
650 list( $released, $abandoned, $pruned ) = $res;
651 $count +
= $released +
$pruned;
652 wfIncrStats( 'job-recycle', count( $released ) );
654 } catch ( RedisException
$e ) {
655 $this->throwRedisException( $this->server
, $conn, $e );
664 protected function doGetPeriodicTasks() {
666 if ( $this->claimTTL
> 0 ) {
667 $tasks['recycleAndDeleteStaleJobs'] = array(
668 'callback' => array( $this, 'recycleAndDeleteStaleJobs' ),
669 'period' => ceil( $this->claimTTL
/ 2 )
672 if ( $this->checkDelay
) {
673 $tasks['releaseReadyDelayedJobs'] = array(
674 'callback' => array( $this, 'releaseReadyDelayedJobs' ),
675 'period' => 300 // 5 minutes
682 * @param RedisConnRef $conn
683 * @param string $script
684 * @param array $params
685 * @param integer $numKeys
688 protected function redisEval( RedisConnRef
$conn, $script, array $params, $numKeys ) {
689 $sha1 = sha1( $script ); // 40 char hex
691 // Try to run the server-side cached copy of the script
692 $conn->clearLastError();
693 $res = $conn->evalSha( $sha1, $params, $numKeys );
694 // If the script is not in cache, use eval() to retry and cache it
695 if ( $conn->getLastError() && $conn->script( 'exists', $sha1 ) === array( 0 ) ) {
696 $conn->clearLastError();
697 $res = $conn->eval( $script, $params, $numKeys );
698 wfDebugLog( 'JobQueueRedis', "Used eval() for Lua script $sha1." );
701 if ( $conn->getLastError() ) { // script bug?
702 wfDebugLog( 'JobQueueRedis', "Lua script error: " . $conn->getLastError() );
712 protected function getNewJobFields( Job
$job ) {
714 // Fields that describe the nature of the job
715 'type' => $job->getType(),
716 'namespace' => $job->getTitle()->getNamespace(),
717 'title' => $job->getTitle()->getDBkey(),
718 'params' => $job->getParams(),
719 // Some jobs cannot run until a "release timestamp"
720 'rtimestamp' => $job->getReleaseTimestamp() ?
: 0,
721 // Additional job metadata
722 'uuid' => UIDGenerator
::newRawUUIDv4( UIDGenerator
::QUICK_RAND
),
723 'sha1' => $job->ignoreDuplicates()
724 ?
wfBaseConvert( sha1( serialize( $job->getDeduplicationInfo() ) ), 16, 36, 31 )
726 'timestamp' => time() // UNIX timestamp
731 * @param $fields array
734 protected function getJobFromFields( array $fields ) {
735 $title = Title
::makeTitleSafe( $fields['namespace'], $fields['title'] );
737 $job = Job
::factory( $fields['type'], $title, $fields['params'] );
738 $job->metadata
['sourceFields'] = $fields;
745 * Get a connection to the server that handles all sub-queues for this queue
747 * @return Array (server name, Redis instance)
748 * @throws MWException
750 protected function getConnection() {
751 $conn = $this->redisPool
->getConnection( $this->server
);
753 throw new MWException( "Unable to connect to redis server." );
759 * @param $server string
760 * @param $conn RedisConnRef
761 * @param $e RedisException
762 * @throws MWException
764 protected function throwRedisException( $server, RedisConnRef
$conn, $e ) {
765 $this->redisPool
->handleException( $server, $conn, $e );
766 throw new MWException( "Redis server error: {$e->getMessage()}\n" );
770 * @param $prop string
773 private function getQueueKey( $prop ) {
774 list( $db, $prefix ) = wfSplitWikiID( $this->wiki
);
775 if ( strlen( $this->key
) ) { // namespaced queue (for testing)
776 return wfForeignMemcKey( $db, $prefix, 'jobqueue', $this->type
, $this->key
, $prop );
778 return wfForeignMemcKey( $db, $prefix, 'jobqueue', $this->type
, $prop );
786 public function setTestingPrefix( $key ) {