3 * Generator and manager of database load balancing objects
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
24 namespace Wikimedia\Rdbms
;
26 use Psr\Log\LoggerInterface
;
27 use Wikimedia\ScopedCallback
;
36 * An interface for generating database load balancers
39 abstract class LBFactory
implements ILBFactory
{
40 /** @var ChronologyProtector */
42 /** @var object|string Class name or object With profileIn/profileOut methods */
44 /** @var TransactionProfiler */
45 protected $trxProfiler;
46 /** @var LoggerInterface */
47 protected $replLogger;
48 /** @var LoggerInterface */
49 protected $connLogger;
50 /** @var LoggerInterface */
51 protected $queryLogger;
52 /** @var LoggerInterface */
53 protected $perfLogger;
54 /** @var callable Error logger */
55 protected $errorLogger;
56 /** @var callable Deprecation logger */
57 protected $deprecationLogger;
62 /** @var WANObjectCache */
65 /** @var DatabaseDomain Local domain */
66 protected $localDomain;
67 /** @var string Local hostname of the app server */
69 /** @var array Web request information about the client */
70 protected $requestInfo;
74 /** @var string|bool String if a requested DBO_TRX transaction round is active */
75 protected $trxRoundId = false;
76 /** @var string|bool Reason all LBs are read-only or false if not */
77 protected $readOnlyReason = false;
78 /** @var callable[] */
79 protected $replicationWaitCallbacks = [];
81 /** @var array[] $aliases Map of (table => (dbname, schema, prefix) map) */
82 protected $tableAliases = [];
83 /** @var string[] Map of (index alias => index) */
84 protected $indexAliases = [];
86 /** @var bool Whether this PHP instance is for a CLI script */
88 /** @var string Agent name for query profiling */
91 /** @var string One of the ROUND_* class constants */
92 private $trxRoundStage = self
::ROUND_CURSORY
;
94 /** @var string|null */
95 private $defaultGroup = null;
97 const ROUND_CURSORY
= 'cursory';
98 const ROUND_BEGINNING
= 'within-begin';
99 const ROUND_COMMITTING
= 'within-commit';
100 const ROUND_ROLLING_BACK
= 'within-rollback';
101 const ROUND_COMMIT_CALLBACKS
= 'within-commit-callbacks';
102 const ROUND_ROLLBACK_CALLBACKS
= 'within-rollback-callbacks';
104 private static $loggerFields =
105 [ 'replLogger', 'connLogger', 'queryLogger', 'perfLogger' ];
107 public function __construct( array $conf ) {
108 $this->localDomain
= isset( $conf['localDomain'] )
109 ? DatabaseDomain
::newFromId( $conf['localDomain'] )
110 : DatabaseDomain
::newUnspecified();
112 if ( isset( $conf['readOnlyReason'] ) && is_string( $conf['readOnlyReason'] ) ) {
113 $this->readOnlyReason
= $conf['readOnlyReason'];
116 $this->srvCache
= $conf['srvCache'] ??
new EmptyBagOStuff();
117 $this->memStash
= $conf['memStash'] ??
new EmptyBagOStuff();
118 $this->wanCache
= $conf['wanCache'] ?? WANObjectCache
::newEmpty();
120 foreach ( self
::$loggerFields as $key ) {
121 $this->$key = $conf[$key] ??
new \Psr\Log\
NullLogger();
123 $this->errorLogger
= $conf['errorLogger'] ??
function ( Exception
$e ) {
124 trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING
);
126 $this->deprecationLogger
= $conf['deprecationLogger'] ??
function ( $msg ) {
127 trigger_error( $msg, E_USER_DEPRECATED
);
130 $this->profiler
= $conf['profiler'] ??
null;
131 $this->trxProfiler
= $conf['trxProfiler'] ??
new TransactionProfiler();
133 $this->requestInfo
= [
134 'IPAddress' => $_SERVER[ 'REMOTE_ADDR' ] ??
'',
135 'UserAgent' => $_SERVER['HTTP_USER_AGENT'] ??
'',
136 // Headers application can inject via LBFactory::setRequestInfo()
137 'ChronologyClientId' => null, // prior $cpClientId value from LBFactory::shutdown()
138 'ChronologyPositionIndex' => null // prior $cpIndex value from LBFactory::shutdown()
141 $this->cliMode
= $conf['cliMode'] ??
( PHP_SAPI
=== 'cli' || PHP_SAPI
=== 'phpdbg' );
142 $this->hostname
= $conf['hostname'] ??
gethostname();
143 $this->agent
= $conf['agent'] ??
'';
144 $this->defaultGroup
= $conf['defaultGroup'] ??
null;
146 $this->ticket
= mt_rand();
149 public function destroy() {
150 $this->shutdown( self
::SHUTDOWN_NO_CHRONPROT
);
151 $this->forEachLBCallMethod( 'disable' );
154 public function shutdown(
155 $mode = self
::SHUTDOWN_CHRONPROT_SYNC
,
156 callable
$workCallback = null,
160 $chronProt = $this->getChronologyProtector();
161 if ( $mode === self
::SHUTDOWN_CHRONPROT_SYNC
) {
162 $this->shutdownChronologyProtector( $chronProt, $workCallback, 'sync', $cpIndex );
163 } elseif ( $mode === self
::SHUTDOWN_CHRONPROT_ASYNC
) {
164 $this->shutdownChronologyProtector( $chronProt, null, 'async', $cpIndex );
167 $cpClientId = $chronProt->getClientId();
169 $this->commitMasterChanges( __METHOD__
); // sanity
173 * @see ILBFactory::newMainLB()
174 * @param bool $domain
175 * @return ILoadBalancer
177 abstract public function newMainLB( $domain = false );
180 * @see ILBFactory::getMainLB()
181 * @param bool $domain
182 * @return ILoadBalancer
184 abstract public function getMainLB( $domain = false );
187 * @see ILBFactory::newExternalLB()
188 * @param string $cluster
189 * @return ILoadBalancer
191 abstract public function newExternalLB( $cluster );
194 * @see ILBFactory::getExternalLB()
195 * @param string $cluster
196 * @return ILoadBalancer
198 abstract public function getExternalLB( $cluster );
201 * Call a method of each tracked load balancer
203 * @param string $methodName
206 protected function forEachLBCallMethod( $methodName, array $args = [] ) {
208 function ( ILoadBalancer
$loadBalancer, $methodName, array $args ) {
209 $loadBalancer->$methodName( ...$args );
211 [ $methodName, $args ]
215 public function flushReplicaSnapshots( $fname = __METHOD__
) {
216 $this->forEachLBCallMethod( 'flushReplicaSnapshots', [ $fname ] );
219 final public function commitAll( $fname = __METHOD__
, array $options = [] ) {
220 $this->commitMasterChanges( $fname, $options );
221 $this->forEachLBCallMethod( 'flushMasterSnapshots', [ $fname ] );
222 $this->forEachLBCallMethod( 'flushReplicaSnapshots', [ $fname ] );
225 final public function beginMasterChanges( $fname = __METHOD__
) {
226 $this->assertTransactionRoundStage( self
::ROUND_CURSORY
);
227 $this->trxRoundStage
= self
::ROUND_BEGINNING
;
228 if ( $this->trxRoundId
!== false ) {
229 throw new DBTransactionError(
231 "$fname: transaction round '{$this->trxRoundId}' already started."
234 $this->trxRoundId
= $fname;
235 // Set DBO_TRX flags on all appropriate DBs
236 $this->forEachLBCallMethod( 'beginMasterChanges', [ $fname ] );
237 $this->trxRoundStage
= self
::ROUND_CURSORY
;
240 final public function commitMasterChanges( $fname = __METHOD__
, array $options = [] ) {
241 $this->assertTransactionRoundStage( self
::ROUND_CURSORY
);
242 $this->trxRoundStage
= self
::ROUND_COMMITTING
;
243 if ( $this->trxRoundId
!== false && $this->trxRoundId
!== $fname ) {
244 throw new DBTransactionError(
246 "$fname: transaction round '{$this->trxRoundId}' still running."
249 /** @noinspection PhpUnusedLocalVariableInspection */
250 $scope = $this->getScopedPHPBehaviorForCommit(); // try to ignore client aborts
251 // Run pre-commit callbacks and suppress post-commit callbacks, aborting on failure
253 $count = 0; // number of callbacks executed this iteration
254 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( &$count ) {
255 $count +
= $lb->finalizeMasterChanges();
257 } while ( $count > 0 );
258 $this->trxRoundId
= false;
259 // Perform pre-commit checks, aborting on failure
260 $this->forEachLBCallMethod( 'approveMasterChanges', [ $options ] );
261 // Log the DBs and methods involved in multi-DB transactions
262 $this->logIfMultiDbTransaction();
263 // Actually perform the commit on all master DB connections and revert DBO_TRX
264 $this->forEachLBCallMethod( 'commitMasterChanges', [ $fname ] );
265 // Run all post-commit callbacks in a separate step
266 $this->trxRoundStage
= self
::ROUND_COMMIT_CALLBACKS
;
267 $e = $this->executePostTransactionCallbacks();
268 $this->trxRoundStage
= self
::ROUND_CURSORY
;
269 // Throw any last post-commit callback error
270 if ( $e instanceof Exception
) {
275 final public function rollbackMasterChanges( $fname = __METHOD__
) {
276 $this->trxRoundStage
= self
::ROUND_ROLLING_BACK
;
277 $this->trxRoundId
= false;
278 // Actually perform the rollback on all master DB connections and revert DBO_TRX
279 $this->forEachLBCallMethod( 'rollbackMasterChanges', [ $fname ] );
280 // Run all post-commit callbacks in a separate step
281 $this->trxRoundStage
= self
::ROUND_ROLLBACK_CALLBACKS
;
282 $this->executePostTransactionCallbacks();
283 $this->trxRoundStage
= self
::ROUND_CURSORY
;
287 * @return Exception|null
289 private function executePostTransactionCallbacks() {
290 // Run all post-commit callbacks until new ones stop getting added
291 $e = null; // first callback exception
293 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( &$e ) {
294 $ex = $lb->runMasterTransactionIdleCallbacks();
297 } while ( $this->hasMasterChanges() );
298 // Run all listener callbacks once
299 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( &$e ) {
300 $ex = $lb->runMasterTransactionListenerCallbacks();
307 public function hasTransactionRound() {
308 return ( $this->trxRoundId
!== false );
311 public function isReadyForRoundOperations() {
312 return ( $this->trxRoundStage
=== self
::ROUND_CURSORY
);
316 * Log query info if multi DB transactions are going to be committed now
318 private function logIfMultiDbTransaction() {
320 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( &$callersByDB ) {
321 $masterName = $lb->getServerName( $lb->getWriterIndex() );
322 $callers = $lb->pendingMasterChangeCallers();
324 $callersByDB[$masterName] = $callers;
328 if ( count( $callersByDB ) >= 2 ) {
329 $dbs = implode( ', ', array_keys( $callersByDB ) );
330 $msg = "Multi-DB transaction [{$dbs}]:\n";
331 foreach ( $callersByDB as $db => $callers ) {
332 $msg .= "$db: " . implode( '; ', $callers ) . "\n";
334 $this->queryLogger
->info( $msg );
338 public function hasMasterChanges() {
340 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( &$ret ) {
341 $ret = $ret ||
$lb->hasMasterChanges();
347 public function laggedReplicaUsed() {
349 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( &$ret ) {
350 $ret = $ret ||
$lb->laggedReplicaUsed();
356 public function hasOrMadeRecentMasterChanges( $age = null ) {
358 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( $age, &$ret ) {
359 $ret = $ret ||
$lb->hasOrMadeRecentMasterChanges( $age );
364 public function waitForReplication( array $opts = [] ) {
368 'timeout' => $this->cliMode ?
60 : 10,
369 'ifWritesSince' => null
372 if ( $opts['domain'] === false && isset( $opts['wiki'] ) ) {
373 $opts['domain'] = $opts['wiki']; // b/c
376 // Figure out which clusters need to be checked
377 /** @var ILoadBalancer[] $lbs */
379 if ( $opts['cluster'] !== false ) {
380 $lbs[] = $this->getExternalLB( $opts['cluster'] );
381 } elseif ( $opts['domain'] !== false ) {
382 $lbs[] = $this->getMainLB( $opts['domain'] );
384 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( &$lbs ) {
388 return; // nothing actually used
392 // Get all the master positions of applicable DBs right now.
393 // This can be faster since waiting on one cluster reduces the
394 // time needed to wait on the next clusters.
395 $masterPositions = array_fill( 0, count( $lbs ), false );
396 foreach ( $lbs as $i => $lb ) {
397 if ( $lb->getServerCount() <= 1 ) {
398 // T29975 - Don't try to wait for replica DBs if there are none
399 // Prevents permission error when getting master position
401 } elseif ( $opts['ifWritesSince']
402 && $lb->lastMasterChangeTimestamp() < $opts['ifWritesSince']
404 continue; // no writes since the last wait
406 $masterPositions[$i] = $lb->getMasterPos();
409 // Run any listener callbacks *after* getting the DB positions. The more
410 // time spent in the callbacks, the less time is spent in waitForAll().
411 foreach ( $this->replicationWaitCallbacks
as $callback ) {
416 foreach ( $lbs as $i => $lb ) {
417 if ( $masterPositions[$i] ) {
418 // The RDBMS may not support getMasterPos()
419 if ( !$lb->waitForAll( $masterPositions[$i], $opts['timeout'] ) ) {
420 $failed[] = $lb->getServerName( $lb->getWriterIndex() );
426 throw new DBReplicationWaitError(
428 "Could not wait for replica DBs to catch up to " .
429 implode( ', ', $failed )
434 public function setWaitForReplicationListener( $name, callable
$callback = null ) {
436 $this->replicationWaitCallbacks
[$name] = $callback;
438 unset( $this->replicationWaitCallbacks
[$name] );
442 public function getEmptyTransactionTicket( $fname ) {
443 if ( $this->hasMasterChanges() ) {
444 $this->queryLogger
->error( __METHOD__
. ": $fname does not have outer scope.\n" .
445 ( new RuntimeException() )->getTraceAsString() );
450 return $this->ticket
;
453 final public function commitAndWaitForReplication( $fname, $ticket, array $opts = [] ) {
454 if ( $ticket !== $this->ticket
) {
455 $this->perfLogger
->error( __METHOD__
. ": $fname does not have outer scope.\n" .
456 ( new RuntimeException() )->getTraceAsString() );
461 // The transaction owner and any caller with the empty transaction ticket can commit
462 // so that getEmptyTransactionTicket() callers don't risk seeing DBTransactionError.
463 if ( $this->trxRoundId
!== false && $fname !== $this->trxRoundId
) {
464 $this->queryLogger
->info( "$fname: committing on behalf of {$this->trxRoundId}." );
465 $fnameEffective = $this->trxRoundId
;
467 $fnameEffective = $fname;
470 $this->commitMasterChanges( $fnameEffective );
471 $this->waitForReplication( $opts );
472 // If a nested caller committed on behalf of $fname, start another empty $fname
473 // transaction, leaving the caller with the same empty transaction state as before.
474 if ( $fnameEffective !== $fname ) {
475 $this->beginMasterChanges( $fnameEffective );
479 public function getChronologyProtectorTouched( $dbName ) {
480 return $this->getChronologyProtector()->getTouched( $dbName );
483 public function disableChronologyProtection() {
484 $this->getChronologyProtector()->setEnabled( false );
488 * @return ChronologyProtector
490 protected function getChronologyProtector() {
491 if ( $this->chronProt
) {
492 return $this->chronProt
;
495 $this->chronProt
= new ChronologyProtector(
498 'ip' => $this->requestInfo
['IPAddress'],
499 'agent' => $this->requestInfo
['UserAgent'],
500 'clientId' => $this->requestInfo
['ChronologyClientId']
502 $this->requestInfo
['ChronologyPositionIndex']
504 $this->chronProt
->setLogger( $this->replLogger
);
506 if ( $this->cliMode
) {
507 $this->chronProt
->setEnabled( false );
508 } elseif ( $this->requestInfo
['ChronologyProtection'] === 'false' ) {
509 // Request opted out of using position wait logic. This is useful for requests
510 // done by the job queue or background ETL that do not have a meaningful session.
511 $this->chronProt
->setWaitEnabled( false );
512 } elseif ( $this->memStash
instanceof EmptyBagOStuff
) {
513 // No where to store any DB positions and wait for them to appear
514 $this->chronProt
->setEnabled( false );
515 $this->replLogger
->info( 'Cannot use ChronologyProtector with EmptyBagOStuff.' );
518 $this->replLogger
->debug( __METHOD__
. ': using request info ' .
519 json_encode( $this->requestInfo
, JSON_PRETTY_PRINT
) );
521 return $this->chronProt
;
525 * Get and record all of the staged DB positions into persistent memory storage
527 * @param ChronologyProtector $cp
528 * @param callable|null $workCallback Work to do instead of waiting on syncing positions
529 * @param string $mode One of (sync, async); whether to wait on remote datacenters
530 * @param int|null &$cpIndex DB position key write counter; incremented on update
532 protected function shutdownChronologyProtector(
533 ChronologyProtector
$cp, $workCallback, $mode, &$cpIndex = null
535 // Record all the master positions needed
536 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( $cp ) {
537 $cp->shutdownLB( $lb );
539 // Write them to the persistent stash. Try to do something useful by running $work
540 // while ChronologyProtector waits for the stash write to replicate to all DCs.
541 $unsavedPositions = $cp->shutdown( $workCallback, $mode, $cpIndex );
542 if ( $unsavedPositions && $workCallback ) {
543 // Invoke callback in case it did not cache the result yet
544 $workCallback(); // work now to block for less time in waitForAll()
546 // If the positions failed to write to the stash, at least wait on local datacenter
547 // replica DBs to catch up before responding. Even if there are several DCs, this increases
548 // the chance that the user will see their own changes immediately afterwards. As long
549 // as the sticky DC cookie applies (same domain), this is not even an issue.
550 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( $unsavedPositions ) {
551 $masterName = $lb->getServerName( $lb->getWriterIndex() );
552 if ( isset( $unsavedPositions[$masterName] ) ) {
553 $lb->waitForAll( $unsavedPositions[$masterName] );
559 * Base parameters to ILoadBalancer::__construct()
562 final protected function baseLoadBalancerParams() {
563 if ( $this->trxRoundStage
=== self
::ROUND_COMMIT_CALLBACKS
) {
564 $initStage = ILoadBalancer
::STAGE_POSTCOMMIT_CALLBACKS
;
565 } elseif ( $this->trxRoundStage
=== self
::ROUND_ROLLBACK_CALLBACKS
) {
566 $initStage = ILoadBalancer
::STAGE_POSTROLLBACK_CALLBACKS
;
572 'localDomain' => $this->localDomain
,
573 'readOnlyReason' => $this->readOnlyReason
,
574 'srvCache' => $this->srvCache
,
575 'wanCache' => $this->wanCache
,
576 'profiler' => $this->profiler
,
577 'trxProfiler' => $this->trxProfiler
,
578 'queryLogger' => $this->queryLogger
,
579 'connLogger' => $this->connLogger
,
580 'replLogger' => $this->replLogger
,
581 'errorLogger' => $this->errorLogger
,
582 'deprecationLogger' => $this->deprecationLogger
,
583 'hostname' => $this->hostname
,
584 'cliMode' => $this->cliMode
,
585 'agent' => $this->agent
,
586 'defaultGroup' => $this->defaultGroup
,
587 'chronologyCallback' => function ( ILoadBalancer
$lb ) {
588 // Defer ChronologyProtector construction in case setRequestInfo() ends up
589 // being called later (but before the first connection attempt) (T192611)
590 $this->getChronologyProtector()->initLB( $lb );
592 'roundStage' => $initStage
597 * @param ILoadBalancer $lb
599 protected function initLoadBalancer( ILoadBalancer
$lb ) {
600 if ( $this->trxRoundId
!== false ) {
601 $lb->beginMasterChanges( $this->trxRoundId
); // set DBO_TRX
604 $lb->setTableAliases( $this->tableAliases
);
605 $lb->setIndexAliases( $this->indexAliases
);
608 public function setTableAliases( array $aliases ) {
609 $this->tableAliases
= $aliases;
612 public function setIndexAliases( array $aliases ) {
613 $this->indexAliases
= $aliases;
616 public function setDomainPrefix( $prefix ) {
617 $this->localDomain
= new DatabaseDomain(
618 $this->localDomain
->getDatabase(),
623 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( $prefix ) {
624 $lb->setDomainPrefix( $prefix );
628 public function closeAll() {
629 $this->forEachLBCallMethod( 'closeAll', [] );
632 public function setAgentName( $agent ) {
633 $this->agent
= $agent;
636 public function appendShutdownCPIndexAsQuery( $url, $index ) {
638 $this->forEachLB( function ( ILoadBalancer
$lb ) use ( &$usedCluster ) {
639 $usedCluster |
= ( $lb->getServerCount() > 1 );
642 if ( !$usedCluster ) {
643 return $url; // no master/replica clusters touched
646 return strpos( $url, '?' ) === false ?
"$url?cpPosIndex=$index" : "$url&cpPosIndex=$index";
650 * @param int $index Write index
651 * @param int $time UNIX timestamp; can be used to detect stale cookies (T190082)
652 * @param string $clientId Agent ID hash from ILBFactory::shutdown()
653 * @return string Timestamp-qualified write index of the form "<index>@<timestamp>#<hash>"
656 public static function makeCookieValueFromCPIndex( $index, $time, $clientId ) {
657 return "$index@$time#$clientId";
661 * @param string $value Possible result of LBFactory::makeCookieValueFromCPIndex()
662 * @param int $minTimestamp Lowest UNIX timestamp that a non-expired value can have
663 * @return array (index: int or null, clientId: string or null)
666 public static function getCPInfoFromCookieValue( $value, $minTimestamp ) {
667 static $placeholder = [ 'index' => null, 'clientId' => null ];
669 if ( !preg_match( '/^(\d+)@(\d+)#([0-9a-f]{32})$/', $value, $m ) ) {
670 return $placeholder; // invalid
675 return $placeholder; // invalid
676 } elseif ( isset( $m[2] ) && $m[2] !== '' && (int)$m[2] < $minTimestamp ) {
677 return $placeholder; // expired
680 $clientId = ( isset( $m[3] ) && $m[3] !== '' ) ?
$m[3] : null;
682 return [ 'index' => $index, 'clientId' => $clientId ];
685 public function setRequestInfo( array $info ) {
686 if ( $this->chronProt
) {
687 throw new LogicException( 'ChronologyProtector already initialized.' );
690 $this->requestInfo
= $info +
$this->requestInfo
;
694 * @param string $stage
696 private function assertTransactionRoundStage( $stage ) {
697 if ( $this->trxRoundStage
!== $stage ) {
698 throw new DBTransactionError(
700 "Transaction round stage must be '$stage' (not '{$this->trxRoundStage}')"
706 * Make PHP ignore user aborts/disconnects until the returned
707 * value leaves scope. This returns null and does nothing in CLI mode.
709 * @return ScopedCallback|null
711 final protected function getScopedPHPBehaviorForCommit() {
712 if ( PHP_SAPI
!= 'cli' ) { // https://bugs.php.net/bug.php?id=47540
713 $old = ignore_user_abort( true ); // avoid half-finished operations
714 return new ScopedCallback( function () use ( $old ) {
715 ignore_user_abort( $old );
722 function __destruct() {
728 * @deprecated since 1.29
730 class_alias( LBFactory
::class, 'LBFactory' );