View Issue Details

IDProjectCategoryView StatusLast Update
0006927OXID eShop (all versions)4.01. Database handlingpublic2024-07-17 15:52
Reportermichael_keiluweit Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version6.1.1 
Fixed in Version6.1.2 
Summary0006927: Master Slave Database balancing improvement
DescriptionBy executing the method \OxidEsales\EshopCommunity\Core\SystemEventHandler::validateOnline a transaction is started. This validation will be executed on every request, nearly at the beginning. Because of this and that a transaction is used, the database connection will force switch to the master database. The consequence is that the master ~ slave balancing is disrupted.
Steps To Reproduce1. Open vendor/oxid-esales/oxideshop-ee/Core/Database/Adapter/Doctrine/Database.php
2. Add this method:
public function getConnection()
{
    $debug = 'No Master/Slave connection used' . PHP_EOL;

    if ($this->isMasterSlaveConnection($this->connection)) {
        /** @var $connection MasterSlaveConnection */
        $connection = $this->connection;
        $debugBacktrace = debug_backtrace();
        $count = count($debugBacktrace) - 1; //skip require_once

        $debug = 'Used Connection: ';
        $debug .= $connection->isConnectedToMaster() ? 'master' : 'slave';
        $debug .= PHP_EOL;

         // 0 is always this method.
         for ($i = 1; $i < $count; $i++) {
             $debug .= $debugBacktrace[$i]['class'] . ' :: ' . $debugBacktrace[$i]['function'] . PHP_EOL;
         }
    }

    $logger = getLogger();
    $logger->error($debug);

    return parent::getConnection();
}
(Note: Don't use the administration area while this code is used. You will run into a nested loop. It will only work at the frontend.)
3. Check the oxideshop.log

Additional InformationThe numbers are a bit out of sync as I tested it on the second or third page refresh, but you will get the idea.
The value of DAO means: 1 = true, it was active; 0 = false, I removed the call of $appServerService->updateAppServerInformationInFrontend();
+----------+-----+--------+-------+
|   Page   | DAO | Master | Slave |
+----------+-----+--------+-------+
| Start    |   1 |    626 |    18 |
| Start    |   0 |      0 |   641 |
| Category |   1 |    404 |    21 |
| Category |   0 |      0 |   421 |
| Detail   |   1 |    874 |    21 |
| Detail   |   0 |      0 |   887 |
+----------+-----+--------+-------+
TagsDatabase, EE, Master-Slave
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined

Relationships

related to 0007192 acknowledgedbenjamin.joerger Master Slave Database balancing - category listing (alist) - using the Master DB in model classes 

Activities

HR

2019-10-16 10:04

administrator   ~0013022

This issue had been fixed in CE [6.3.2] - 2019-01-22, compilation v6.1.2.