Skip to content

[PLTFRM-1887] HyperDB: Route locking reads to the primary database - #7592

Merged
rebeccahum merged 1 commit into
developfrom
update/hyperdb-locking-reads
Nov 16, 2026
Merged

rebeccahum merged 1 commit into
developfrom
update/hyperdb-locking-reads

Conversation

@rebeccahum

Copy link
Copy Markdown
Contributor

Description

HyperDB sent SELECT ... FOR UPDATE (and FOR SHARE / LOCK IN SHARE MODE) queries to read replicas, where they fail with "running with the --read-only option". This bumps drop-ins/hyperdb from 6fd480d to 082a127 (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

  • HyperDB: Fixed locking reads (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

  • This change works and has been tested locally or in Codespaces (or has an appropriate fallback).
  • This change works and has been tested on a sandbox.
  • This change has relevant unit tests (not applicable; submodule pointer update).
  • This change uses a rollout method to ease with deployment (not applicable).
  • This change has relevant documentation additions / updates (not applicable).
  • I've created a changelog description that aligns with the provided examples.

Pre-deploy checklist

  • VIP staff: Ensure any alerts added/updated conform to internal standards (not applicable).

Steps to Test

  1. Confirm drop-ins/hyperdb points to 082a12756d8699059f95b8152e4d63f68caa1b22.
  2. With a read-only replica configured, run WooCommerce WC_Discounts::is_coupon_valid() for a coupon with a per-user limit: the FOR UPDATE queries now hit the primary with no read-only error, and plain SELECTs still go to the replica. (Verified locally on MariaDB 10.11, WP 7.1.4, WooCommerce 11.3.0.)

🤖 Generated with Claude Code

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>
@rebeccahum
rebeccahum requested a review from a team as a code owner November 13, 2026 18:12
Copilot AI balanced review requested due to automatic review settings November 13, 2026 18:12
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.10%. Comparing base (4e65ee7) to head (dec5a27).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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/hyperdb from 6fd480d to 082a127, incorporating Automattic/HyperDB#192.
  • Classifies FOR UPDATE, FOR SHARE, and LOCK IN SHARE MODE reads as writes for routing, also directing subsequent queries on the same table to the primary.
File Description

Review effort: Balanced

@sjinks sjinks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rebeccahum
rebeccahum merged commit 9c4abdf into develop Nov 16, 2026
50 checks passed
@rebeccahum
rebeccahum deleted the update/hyperdb-locking-reads branch November 16, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants