Skip to content

Master/Slave configuration and use of slave connection #33267

Open
@gianstraf

Description

@gianstraf

Preconditions (*)

  1. Magento Commerce Edition ver. 2.4.2
  2. PHP 7.4.6
  3. Master/slave configuration

Steps to reproduce (*)

  1. Add a slave connection with bin/magento setup:db-schema:add-slave
'db' => [
        'connection' => [
            'indexer' => [
                'host' => 'localhost',
                'dbname' => 'local_db2',
                'username' => 'local_user2',
                'password' => 'local_pass',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1',
                'persistent' => null
            ],
            'default' => [
                'host' => 'localhost',
                'dbname' => 'local_db2',
                'username' => 'local_user2',
                'password' => 'local_pass',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1',
                'driver_options' => [
                    1014 => false
                ]
            ]
        ],
        'table_prefix' => '',
        'slave_connection' => [
            'default' => [
                'host' => 'localhost',
                'dbname' => 'local_db2',
                'username' => 'local_user2_slave',
                'password' => 'local_pass',
                'maxAllowedLag' => '',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1'
            ]
        ]
    ],
  1. Navigate on FE or BE or run a cli command: three different scenariuos

Expected result (*)

  1. In case of CLI command, we expect that an export of products (for example), can work whole on slave database (all read operations). The master/slave configuration, is ignored (never used) in the CLI Context.
  2. In case of BE operations (i.e. products list, sales order list), read queries should be ran on slave connection, lightening the master database.

Actual result (*)

  1. Any command runned via CLI, "ignores" slave connection.
  2. In case of BE operations (i.e. products list, sales order list) only a few queries are ran on slave database, the most are ran on master database. In the sales orders lists, in example, when framework save data on the "theme" table, all following queries go on the master connection, without return back to slave connection (a ratio of ~10% on the total, with the most of select statements on master database).

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Ready for Grooming

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions