We've noticed that loading the site editor with a fairly simple one-template theme on a newly created site on a large WordPress installation that uses the HyperDB plugin for replication takes a long time (10-15s).
Our preliminary findings indicate that this is due to queries being sent to the master database (which is in a different data center), as the same doesn't happen in a sandbox that's hosted in the same DC as the master DB.
The reason for queries being sent to master is that SRTM (Send Reads To Master) behavior is triggered, which usually happens when a write operation hits the DB right before a read (or another write) operation. SRTM then sends that subsequent request to master (rather than the replica) in order to avoid reading stale data.
We suspect that this issue is caused by the template resolution algorithm -- specifically by template part auto-draft creation.
cc/ @vindl @Addison-Stavlo @jeyip @noahtallen @epiqueras
Thanks @josephscott for advising
Why would SRTM send a read that follows a write to the master database for the same request? If the write happened locally, it already has fresh data.
IIUC, it might not be the exact same request but a different one, to the same table.
We _think_ that this issue has been fixed by #22893. I'll report back once we've verified on our HyperDB install.
Yep, looks like #22893 fixed this.
Most helpful comment
We _think_ that this issue has been fixed by #22893. I'll report back once we've verified on our HyperDB install.