Page MenuHomeIn-Portal Phabricator

INP-1771 - Change slave lag detection code to use "SHOW SLAVE STATUS" query
ClosedPublic

Authored by alex on Jun 24 2019, 8:32 AM.

Details

Test Plan
IMPORTANT: Without real master/slave setup we can only test, that in our fake master/slave setup slave is chosen for SELECT queries.
Code fragment
$application->Conn->Query('SELECT * FROM inp_SlaveOnly');
  • in Database Manager:
    1. create new database as copy/paste from database used in In-Portal
    2. in copied database create inp_SlaveOnly database table
    3. remember created database name
  • in IDE:
    1. open /index.php file for editing (front-end)
    2. after $application->Init(); line add code shown above test plan
    3. save changes
    4. change /system/config.php file to:
      • enable support for load balancing (see example in http://community.in-portal.org/x/Npkk and you can use same server as both slave & master) with DBMaxLag key in slave config set to 15 (any positive non-zero number really)
      • for slave connection add DBName key (even though it's not listed in Confluence) with above copied database name
      • basically what we need is inp_SlaveOnly table to be present on slave (copied) database only, but not on master database
    5. in core/kernel/db/db_load_balancer.php file change \kDBLoadBalancer::reallyOpenConnection method change $this->servers[0]['DBName'] to $server['DBName'] (allows to use different DB name for slave, that was added in config.php file)
  • in IDE
    1. enable Debug Mode
  • in Web Browser
    1. open Front-End
    2. confirm, that no SQL error happened
  • in IDE
    1. disable Debug Mode
  • in Web Browser
    1. open Front-End
    2. confirm, that no SQL error happened

Diff Detail

Repository
rINP In-Portal
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

alex created this revision.Jun 24 2019, 8:32 AM
alex requested review of this revision.Jun 24 2019, 8:32 AM
alex edited the test plan for this revision. (Show Details)Jun 24 2019, 8:56 AM
alex added a project: Restricted Project.
alex edited the test plan for this revision. (Show Details)
alex edited the test plan for this revision. (Show Details)Jun 25 2019, 5:19 AM
erik accepted this revision.Jun 25 2019, 5:40 AM
This revision is now accepted and ready to land.Jun 25 2019, 5:40 AM
alex updated this revision to Diff 914.Jun 25 2019, 7:41 AM

Handle cases, when slave is too busy catching up with a master.

This revision was landed with ongoing or failed builds.Jan 4 2021, 2:36 AM
This revision was automatically updated to reflect the committed changes.