Support for query splitting to Replica in core

Created on 29 May 2019, over 5 years ago
Updated 3 September 2024, 5 days ago

I understand how to configure the $database['default']['replica'][] settings so that I can point to 1..N replica servers.

I do not understand how to get anything but my custom-written queries to leverage the Replica servers.

This seems to me like a core feature to supporting multiple databases in core, but I see no clear path to handling this logic, nor do I see a clear place to override this

I've even tried

 if (!isset($options['target']) && stripos($query, 'SELECT') === 0) {
        $options['target'] = 'replica';
      }
      return parent::query($query, $args, $options);

in
Drupal\Core\Database\Driver\mysql\Connection function query(
but whatever other processes are involved with loading any page in Drupal appear to mark the replica as invalid, so I never actually have any queries that execute against the replica in this scenario.

This seems to me like a core scaling issue for Drupal, so I'm not clear on if I'm just misunderstanding how this is supposed to work, or if the only recommendation is to use an external process such as proxySQL or other mechanism to split read/write queries across master/slave (primary/replica)

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
MySQL driverΒ  β†’

Last updated 5 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States craigmc

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024