Skip to content

Database: Route locking reads to writable servers. - #244

Merged
JJJ merged 1 commit into
masterfrom
fix/hyperdb-locking-reads
Nov 20, 2026
Merged

JJJ merged 1 commit into
masterfrom
fix/hyperdb-locking-reads

Conversation

@JJJ

@JJJ JJJ commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Route FOR UPDATE, FOR SHARE, and LOCK IN SHARE MODE through writable connections.
  • Keep LudicrousDB’s conservative possible-write behavior, including fail-safe handling for ambiguous SQL comments.
  • Advance the HyperDB parity ledger through upstream commit 082a127.

Compatibility

This is a focused port of Automattic/HyperDB#192. It preserves the PHP 7.4 and WordPress 6.4 floors and does not change public APIs.

Validation

  • Full PHPUnit suite.
  • PHPStan.
  • Central Fleet PHPCS baseline.
  • Composer validation and locked dependency audit.
  • PHP syntax checks.
  • Read-only Claude review of the exact head found no actionable issues.

This remains a draft because a database drop-in routing change needs an explicit release decision.

Props rebeccahum, vnsavage.

Recognize FOR SHARE and LOCK IN SHARE MODE alongside FOR UPDATE using the existing conservative possible-write heuristic. Cover primary and replica selection and record HyperDB 082a127 in the parity ledger.

Props rebeccahum, vnsavage.

See Automattic/HyperDB#192.
@JJJ
JJJ marked this pull request as ready for review November 20, 2026 04:13
Copilot AI balanced review requested due to automatic review settings November 20, 2026 04:13
@JJJ
JJJ merged commit 9b51b31 into master Nov 20, 2026
13 checks passed
@JJJ
JJJ deleted the fix/hyperdb-locking-reads branch November 20, 2026 04:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Critical-risk database routing and persistent primary-affinity changes require an explicit human release decision because isolated tests do not establish live MySQL/MariaDB locking behavior.

No open issues 🎉

What changed in this PR

Ports HyperDB’s locking-read routing behavior into LudicrousDB’s connection selection while preserving conservative possible-write classification.

Changes:

  • Routes FOR UPDATE, FOR SHARE, and LOCK IN SHARE MODE to writable servers, with conservative handling of ambiguous comments.
  • Adds classification, writable-routing, primary-affinity, and scan-performance tests.
  • Advances the upstream parity ledger through commit 082a127.

No actionable findings.

File Description
UPSTREAM.md Records the upstream baseline and locking-read port.
tests/​LudicrousDBTest.php Adds routing, SQL edge-case, and performance coverage.
ludicrousdb/​includes/​class-ludicrousdb.php Detects locking reads and routes ambiguous comment cases conservatively.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants