craftcms / craftcms/cms

Segmentation Fault when implementing read/write query splitting

Open
#5,625 4 comments 0 reactions 1 assignee View on GitHub

@jasonmccallister is already working on this.

Since Feb 10, 2020.

Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Description

When trying to implement read/write query splitting using a custom database component like the one detailed in the docs (https://docs.craftcms.com/v3/config/app.html#cache-component), I keep hitting a seg fault on my server (Apache).

I'm running craft in a docker container in kubernetes and can provide my docker file if necessary.

Code
'components' => [
    'db' => function() {
        $config = craft\helpers\App::dbConfig();
        $config['slaveConfig'] = [
            'username' => 'root',
            'password' => getEnv('DB_PASSWORD'),
            'tablePrefix' => 'craft_',
            'attributes' => [
                PDO::ATTR_TIMEOUT => 10,
            ],
        ];

        $config['slaves'] = [
            ['dsn' => getEnv('SLAVE_DSN_1')], 
            ['dsn' => getEnv('SLAVE_DSN_2')],
        ];
        return Craft::createObject($config);
    },
],

After a little debugging it appears that the slave dsn declaration array is what's triggering the error but I'm unclear as to why a simple array declaration would be triggering the error. Any help would be appreciated, thanks!

Additional info
  • Craft version: 3.4.4
  • PHP version: 7.2
  • Database driver & version: mysql

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.