Repository navigation
[PLTFRM-1887] HyperDB: Route locking reads to the primary database - #7592
Conversation
Bumps drop-ins/hyperdb from 6fd480d to 082a127 (Automattic/HyperDB#192). SELECT ... FOR UPDATE, FOR SHARE and LOCK IN SHARE MODE are now treated as writes, so they no longer fail on read-only replicas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7592 +/- ##
==========================================
Coverage 41.10% 41.10%
Complexity 5687 5687
==========================================
Files 305 305
Lines 22504 22504
==========================================
Hits 9251 9251
Misses 13253 13253 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the update routing locking reads to the primary database.
No open issues 🎉
What changed in this PR
This PR updates HyperDB so locking reads use the primary database rather than failing on read-only replicas in WordPress VIP’s database layer.
Changes:
- Bumps
drop-ins/hyperdbfrom6fd480dto082a127, incorporating Automattic/HyperDB#192. - Classifies
FOR UPDATE,FOR SHARE, andLOCK IN SHARE MODEreads as writes for routing, also directing subsequent queries on the same table to the primary.
| File | Description |
|---|
Review effort: Balanced
sjinks
left a comment
There was a problem hiding this comment.
No actionable correctness findings in the HyperDB pointer update. The upstream range changes only is_write_query(); writable routing and subsequent same-table primary reads follow the existing routing path. Twelve native classification probes passed against the exact new method, including the comment tradeoffs explicitly documented upstream. PHP syntax passed. No live primary/replica integration test was run.



Description
HyperDB sent
SELECT ... FOR UPDATE(andFOR SHARE/LOCK IN SHARE MODE) queries to read replicas, where they fail with "running with the --read-only option". This bumpsdrop-ins/hyperdbfrom6fd480dto082a127(Automattic/HyperDB#192), which treats locking reads as writes. Side effect: as with any write, later queries on the same table in that request also go to the primary.Changelog Description
Fixed
SELECT ... FOR UPDATE,FOR SHARE,LOCK IN SHARE MODE) failing with a read-only error by sending them to the primary database.Pre-review checklist
Pre-deploy checklist
Steps to Test
drop-ins/hyperdbpoints to082a12756d8699059f95b8152e4d63f68caa1b22.WC_Discounts::is_coupon_valid()for a coupon with a per-user limit: theFOR UPDATEqueries now hit the primary with no read-only error, and plainSELECTs still go to the replica. (Verified locally on MariaDB 10.11, WP 7.1.4, WooCommerce 11.3.0.)🤖 Generated with Claude Code