View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006927 | OXID eShop (all versions) | 4.01. Database handling | public | 2018-12-04 10:14 | 2024-07-17 15:52 |
Reporter | michael_keiluweit | Assigned To | |||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 6.1.1 | ||||
Fixed in Version | 6.1.2 | ||||
Summary | 0006927: Master Slave Database balancing improvement | ||||
Description | By 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 Reproduce | 1. 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 Information | The 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 | +----------+-----+--------+-------+ | ||||
Tags | Database, EE, Master-Slave | ||||
Theme | Not defined | ||||
Browser | Not defined | ||||
PHP Version | Not defined | ||||
Database Version | Not defined | ||||
related to | 0007192 | acknowledged | benjamin.joerger | Master Slave Database balancing - category listing (alist) - using the Master DB in model classes |