You are here

function db_ignore_replica in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/includes/database.inc \db_ignore_replica()

Sets a session variable specifying the lag time for ignoring a replica server (A replica server is traditionally referred to as a "slave" in database server documentation).

See also

https://www.drupal.org/node/2275877

4 calls to db_ignore_replica()
IgnoreReplicaSubscriberTest::testSystemInitIgnoresSecondaries in core/modules/system/src/Tests/System/IgnoreReplicaSubscriberTest.php
Tests \Drupal\Core\EventSubscriber\ReplicaDatabaseIgnoreSubscriber::checkReplicaServer().
MenuRouterRebuildSubscriber::menuLinksRebuild in core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php
Perform menu-specific rebuilding.
SqlContentEntityStorage::delete in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
Deletes permanently saved entities.
SqlContentEntityStorage::save in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
Saves the entity permanently.

File

core/includes/database.inc, line 1029
Core systems for the database layer.

Code

function db_ignore_replica() {
  $connection_info = Database::getConnectionInfo();

  // Only set ignore_replica_server if there are replica servers being used,
  // which is assumed if there are more than one.
  if (count($connection_info) > 1) {

    // Five minutes is long enough to allow the replica to break and resume
    // interrupted replication without causing problems on the Drupal site from
    // the old data.
    $duration = Settings::get('maximum_replication_lag', 300);

    // Set session variable with amount of time to delay before using replica.
    $_SESSION['ignore_replica_server'] = REQUEST_TIME + $duration;
  }
}