humhub / humhub

HumHub is an Open Source Enterprise Social Network. Easy to install, intuitive to use and extendable with countless freely available modules.
https://www.humhub.com
Other
6.3k stars 1.66k forks source link

Maria DB Galera - Installer broken #6739

Closed jSML4ThWwBID69YC closed 2 months ago

jSML4ThWwBID69YC commented 9 months ago

What steps will reproduce the problem?

Run a basic installation of Humhub 1.15.0 or 1.15.1 using Galera as the backend SQL database.

What is the expected result?

Installation should proceed without errors.

What do you get instead?

At the admin creation step. Fill out the information and click next. The screen will return a SQL error. Note, the admin user is created, and a simple refresh of the page brings you to the next step.

Here is the error.

yii\base\ErrorException: Attempt to read property "id" on null in /apps/humhub/protected/humhub/modules/installer/controllers/ConfigController.php:496
Stack trace:
#0 /apps/humhub/protected/humhub/modules/installer/controllers/ConfigController.php(496): yii\base\ErrorHandler->handleError(2, 'Attempt to read...', '/apps/humhub/pr...', 496)
#1 [internal function]: humhub\modules\installer\controllers\ConfigController->actionAdmin()
#2 /apps/humhub/protected/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 /apps/humhub/protected/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#4 /apps/humhub/protected/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('admin', Array)
#5 /apps/humhub/protected/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('installer/confi...', Array)
#6 /apps/humhub/protected/vendor/yiisoft/yii2/base/Application.php(384): yii\web\Application->handleRequest(Object(humhub\components\Request))
#7 /apps/humhub/index.php(25): yii\base\Application->run()
#8 {main}

Additional info

Q A
HumHub version 1.15.0 and 1.15.1. Other versions not tested.
PHP version PHP 8.2 and PHP 8.3.
Operating system FreeBSD
Database MariaDB 10.6.16 with Galera 26.4.16.

Please let me know what else you need, or any other way I can help.

luke- commented 9 months ago

@jSML4ThWwBID69YC Does the problem only occur in relation to Galera?

Have you ever tried to migrate an existing database to Galera?

luke- commented 9 months ago

Related : https://github.com/humhub/humhub/issues/6740

jSML4ThWwBID69YC commented 9 months ago

Hello @luke-

Yes. I did the following.

  1. Did a fresh installation of HumHub into a single instance of MariaDB 10.6.16 without Galera. This works perfect.
  2. Export the database and import it into a Galera cluster. This also worked perfectly.
  3. Adjusted protected/config/dynamic.php to use the Galera cluster database and tested.

So far as I can tell HumHub is working correctly with the Galera service using an imported database from the standalone MariaDB instance. HumHub also seems to work correctly with Galera even when installed directly on it.

It's just the two steps in the installer that demonstrate errors.

luke- commented 9 months ago

Thanks for the info!

gevorgmansuryan commented 5 months ago

Hi @jSML4ThWwBID69YC! Can you please share contents of protected/config/dynamic.php and also how you configure Humhub to use Galera at database configuration step?

jSML4ThWwBID69YC commented 5 months ago

Hello,

I configure the database server the same regardless of whether Galera is present. It's just the standard database name, username, password, and server IP entered into the web based configuration screen.

Here's the dynamic.php.

<?php return array (
  'components' => 
  array (
    'db' => 
    array (
      'class' => 'yii\\db\\Connection',
      'dsn' => 'mysql:host=10.10.0.1;port=3306;dbname=censored',
      'username' => 'censored',
      'password' => 'censored',
    ),
    'user' => 
    array (
    ),
    'mailer' => 
    array (
      'transport' => 
      array (
        'dsn' => 'native://default',
      ),
    ),
    'cache' => 
    array (
      'class' => 'yii\\caching\\FileCache',
      'keyPrefix' => 'humhub',
    ),
  ),
  'params' => 
  array (
    'installer' => 
    array (
      'db' => 
      array (
        'installer_hostname' => '10.10.0.1',
        'installer_database' => 'censored',
      ),
    ),
    'config_created_at' => 1715036180,
    'horImageScrollOnMobile' => 1,
    'databaseInstalled' => true,
    'installed' => true,
  ),
  'name' => 'HumHub',
  'language' => 'en-US',
); ?>

This was tested today with a clean installation of HumHub 1.15.3.

jSML4ThWwBID69YC commented 4 months ago

The issue exists on 1.15.5 too.

gevorgmansuryan commented 4 months ago

@jSML4ThWwBID69YC still can not reproduce it, it works fine on my side. Maybe it's env related, some server/galera configurations? Can you please reproduce the same in other env?

jSML4ThWwBID69YC commented 4 months ago

I've been able to reproduce it on Mariadb 10.6 and 10.11 with Galera 26 enabled. It's consistent 100%.

Is there some kind of HumHub debugging I can turn on to provide better information?

ArchBlood commented 4 months ago

Sounds to me that it's related to synchronous multi-master replication, could you configure Galera with the following?

[mysqld]
innodb_autoinc_lock_mode=2
wsrep_sync_wait=0

Also something that could probably be the issue would be the actionAdmin() which returns a null value before switching to creating the welcome space, so maybe add a check for this beforehand?

public function actionAdmin()
{
    // Start a database transaction
    $transaction = Yii::$app->db->beginTransaction();

    try {
        // Lock the user table to prevent race conditions
        Yii::$app->db->createCommand('LOCK TABLES user WRITE')->execute();

        // Check if the admin user already exists
        $adminUser = User::find()->where(['username' => 'admin'])->one();

        if ($adminUser) {
            // Admin account already created
            // Unlock the table and commit the transaction
            Yii::$app->db->createCommand('UNLOCK TABLES')->execute();
            $transaction->commit();
            return $this->redirect(Yii::$app->getModule('installer')->getNextConfigStepUrl());
        }

        $userModel = new User();
        $userModel->scenario = User::SCENARIO_EDIT_ADMIN;
        $userPasswordModel = new Password();
        $userPasswordModel->scenario = 'registration';
        $profileModel = $userModel->profile;
        $profileModel->scenario = 'registration';

        // Build Form Definition
        $definition = [];
        $definition['elements'] = [];

        // Add User Form
        $definition['elements']['User'] = [
            'type' => 'form',
            'elements' => [
                'username' => [
                    'type' => 'text',
                    'class' => 'form-control',
                    'maxlength' => 25,
                ],
                'email' => [
                    'type' => 'text',
                    'class' => 'form-control',
                    'maxlength' => 100,
                ]
            ],
        ];

        // Add User Password Form
        $definition['elements']['Password'] = [
            'type' => 'form',
            'elements' => [
                'newPassword' => [
                    'type' => 'password',
                    'class' => 'form-control',
                    'maxlength' => 255,
                ],
                'newPasswordConfirm' => [
                    'type' => 'password',
                    'class' => 'form-control',
                    'maxlength' => 255,
                ],
            ],
        ];

        // Add Profile Form
        $definition['elements']['Profile'] = array_merge(['type' => 'form'], $profileModel->getFormDefinition());

        // Get Form Definition
        $definition['buttons'] = [
            'save' => [
                'type' => 'submit',
                'class' => 'btn btn-primary',
                'label' => Yii::t('InstallerModule.base', 'Create Admin Account'),
            ],
        ];

        $form = new \humhub\compat\HForm($definition);
        $form->models['User'] = $userModel;
        $form->models['Password'] = $userPasswordModel;
        $form->models['Profile'] = $profileModel;

        if ($form->submitted('save') && $form->validate()) {
            $form->models['User']->status = User::STATUS_ENABLED;
            $form->models['User']->language = '';
            $form->models['User']->tagsField = ['Administration', 'Support', 'HumHub'];
            $form->models['User']->save();

            $form->models['Profile']->user_id = $form->models['User']->id;
            $form->models['Profile']->title = "System Administration";
            $form->models['Profile']->save();

            // Save User Password
            $form->models['Password']->user_id = $form->models['User']->id;
            $form->models['Password']->setPassword($form->models['Password']->newPassword);
            $form->models['Password']->save();

            Group::getAdminGroup()->addUser($form->models['User']);

            // Reload User
            $adminUser = User::findOne(['id' => $form->models['User']->id]);

            // Switch Identity
            Yii::$app->user->switchIdentity($adminUser);

            // Create Welcome Space
            $space = new Space();
            $space->name = Yii::t("InstallerModule.base", "Welcome Space");
            $space->description = Yii::t("InstallerModule.base", "Your first sample space to discover the platform.");
            $space->join_policy = Space::JOIN_POLICY_FREE;
            $space->visibility = Space::VISIBILITY_ALL;
            $space->created_by = $adminUser->id;
            $space->auto_add_new_members = 1;
            $space->color = '#6fdbe8';
            $space->save();
            $space->refresh();

            // Activate all available modules for this space
            foreach ($space->moduleManager->getAvailable() as $module) {
                $space->moduleManager->enable($module->id);
            }

            // Add Some Post to the Space
            $post = new Post();
            $post->message = Yii::t("InstallerModule.base", "Yay! I've just installed HumHub :sunglasses:");
            $post->content->container = $space;
            $post->content->visibility = \humhub\modules\content\models\Content::VISIBILITY_PUBLIC;
            $post->save();

            // Unlock the table and commit the transaction
            Yii::$app->db->createCommand('UNLOCK TABLES')->execute();
            $transaction->commit();

            return $this->redirect(Yii::$app->getModule('installer')->getNextConfigStepUrl());
        }

        // Unlock the table in case of validation failure
        Yii::$app->db->createCommand('UNLOCK TABLES')->execute();
        $transaction->commit();
    } catch (\Exception $e) {
        // Rollback the transaction in case of error
        $transaction->rollBack();
        throw $e;
    }

    return $this->render('admin', ['hForm' => $form]);
}

I'd like to note that I have not tested the above snippet personally using Galera currently, this should just be taken as a mitigation method and should be looked into more when time is had.

gevorgmansuryan commented 3 months ago

@jSML4ThWwBID69YC any updates? I've tried install fresh humhub installation using docker with https://hub.docker.com/r/bitnami/mariadb-galera image, and it worked fine. I can not reproduce it in any way. I believe it's something config related. please check @ArchBlood 's comment.

jSML4ThWwBID69YC commented 3 months ago

@ArchBlood

Thank you for the hints. I think you were right.

_innodb_autoinc_lockmode=2 has been set from the start of the cluster. The wsrep_sync_wait=0 was not set. Instead the legacy option wsrep_causal_reads=1 was set. I believe this is equivalent to wsrep_sync_wait=1.

@gevorgmansuryan I've run the installation twice with wsrep_sync_wait=0 set. It worked both times. That said, it would good if it would work with wsrep_sync_wait=1 too, as other applications need safe reads to function properly at scale. Nextcloud comes to mind

The wsrep_sync_wait value can be set per session. Could the installation script set it as part of the installation process? So far as I can tell HumHub works fine with wsrep_sync_wait=1 after the installation.

ArchBlood commented 3 months ago

@luke- or @gevorgmansuryan maybe documentation is needed in these cases?

ArchBlood commented 3 months ago

@ArchBlood

Thank you for the hints. I think you were right.

_innodb_autoinc_lockmode=2 has been set from the start of the cluster. The _wsrep_syncwait=0 was not set. Instead the legacy option _wsrep_causalreads=1 was set. I believe this is equivalent to _wsrep_syncwait=1.

@gevorgmansuryan I've run the installation twice with _wsrep_syncwait=0 set. It worked both times. That said, it would good if it would work with _wsrep_syncwait=1 too, as other applications need safe reads to function properly at scale. Nextcloud comes to mind

The _wsrep_syncwait value can be set per session. Could the installation script set it as part of the installation process? So far as I can tell HumHub works fine with _wsrep_syncwait=1 after the installation.

A quick answer to the original question why both wsrep_causal_reads=1 and wsrep_sync_wait=1 may not work is because they introduce additional latency for read operations. HumHub, being a social network platform, often relies on quick read/write cycles to provide a responsive user experience. The added latency can lead to timeouts and perceived sluggishness in an instance. So I'm not sure it is something that should be supported in HumHub. Overall I don't even believe Yii2 is specifically optimized for the added latency of causal reads or synchronized waits, they both will work but at the cost of performance.

luke- commented 3 months ago

Yes, documentation would be nice.

Perhaps we can also check beforehand where the wsrep_sync_wait triggers the problem. Maybe we can avoid it and support this mode.

ArchBlood commented 3 months ago

Yes, documentation would be nice.

Perhaps we can also check beforehand where the wsrep_sync_wait triggers the problem. Maybe we can avoid it and support this mode.

From my understanding it happens when switching to the user after system admin is created and before when the Welcome Space is started for creation. At least that is as far as I made it, I didn't test beyond that point.

jSML4ThWwBID69YC commented 3 months ago

I agree that this should be documented. Just a note that Galera needs wsrep_sync_wait=0 set for HumHub to function properly.

A quick answer to the original question why both wsrep_causal_reads=1 and wsrep_sync_wait=1 may not work is because they introduce additional latency for read operations. HumHub, being a social network platform, often relies on quick read/write cycles to provide a responsive user experience. The added latency can lead to timeouts and perceived sluggishness in an instance. So I'm not sure it is something that should be supported in HumHub. Overall I don't even believe Yii2 is specifically optimized for the added latency of causal reads or synchronized waits, they both will work but at the cost of performance.

I have noticed that HumHub is sluggish in response time. Adding Redis to the mix helps a lot, but performance could be improved for Galera based systems. Does HumHub support using read-only sql replicas? If so, that may be a solution to the sluggish issue when using Glaera as the write server.

I'd be happy to test anything that might improve performance on Galera. Thank you for all the help.

ArchBlood commented 3 months ago

I agree that this should be documented. Just a note that Galera needs _wsrep_syncwait=0 set for HumHub to function properly.

A quick answer to the original question why both wsrep_causal_reads=1 and wsrep_sync_wait=1 may not work is because they introduce additional latency for read operations. HumHub, being a social network platform, often relies on quick read/write cycles to provide a responsive user experience. The added latency can lead to timeouts and perceived sluggishness in an instance. So I'm not sure it is something that should be supported in HumHub. Overall I don't even believe Yii2 is specifically optimized for the added latency of causal reads or synchronized waits, they both will work but at the cost of performance.

I have noticed that HumHub is sluggish in response time. Adding Redis to the mix helps a lot, but performance could be improved for Galera based systems. Does HumHub support using read-only sql replicas? If so, that may be a solution to the sluggish issue when using Glaera as the write server.

I'd be happy to test anything that might improve performance on Galera. Thank you for all the help.

Currently I don't believe HumHub natively supports read-only SQL replicas within configurations, this would require custom configurations and adjustments to be made in your common.php and database, maybe something like the following;

return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=LOAD_BALANCER_HOST;dbname=YOUR_DATABASE_NAME',
            'username' => 'DB_USERNAME',
            'password' => 'DB_PASSWORD',
            'charset' => 'utf8',
            'enableSchemaCache' => true,
            'schemaCacheDuration' => 3600,
            'schemaCache' => 'cache',
        ],
        // Additional components...
    ],
    // Additional configuration...
];

Load Balancer ProxySQL

-- Add the master node (for writes)
INSERT INTO mysql_servers (hostname, port, hostgroup_id) VALUES ('master_node_host', 3306, 10);

-- Add the read replicas (for reads)
INSERT INTO mysql_servers (hostname, port, hostgroup_id) VALUES ('replica1_host', 3306, 20);
INSERT INTO mysql_servers (hostname, port, hostgroup_id) VALUES ('replica2_host', 3306, 20);

-- Configure the user for ProxySQL
INSERT INTO mysql_users (username, password, default_hostgroup, transaction_persistent) VALUES ('humhub_user', 'password', 10, 0);

-- Route SELECT queries to the replicas
INSERT INTO mysql_query_rules (rule_id, active, match_pattern, destination_hostgroup, apply) VALUES (1, 1, '^SELECT.*', 20, 1);

-- Load the new configurations into runtime and persist them
LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;
LOAD MYSQL USERS TO RUNTIME;
SAVE MYSQL USERS TO DISK;
LOAD MYSQL QUERY RULES TO RUNTIME;
SAVE MYSQL QUERY RULES TO DISK;
jSML4ThWwBID69YC commented 3 months ago

Hello,

I was trying the configuration from https://yii2-framework.readthedocs.io/en/latest/guide/db-dao/ I add this to common.php under my Redis configuration following the same file format.


// Override DB class
        'db' => [
        'class' => 'yii\db\Connection',

    // Primary configuration
            'dsn' => 'mysql:host=galera.example.com;dbname=VALUE',
            'username' => 'VALUE',
            'password' => 'VALUE',

    // Replica configuration
    'slaveConfig' => [
        'username' => 'VALUE',
        'password' => 'VALUE',
        'attributes' => [
            // use a smaller connection timeout
            PDO::ATTR_TIMEOUT => 10,
        ],
    ],

    // Replica
    'slaves' => [
            'dsn' => 'mysql:host=galera-replica.example.com;dbname=VALUE',
    ],
],

It seems like it should work, but I think I'm missing something HumHub specific. Here's the error.

TypeError: array_merge(): Argument #2 must be of type array, string given in /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php:1202
Stack trace:
#0 /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php(1202): array_merge(Array, 'mysql:host=gale...')
#1 /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php(1163): yii\db\Connection->openFromPoolSequentially(Array, Array)
#2 /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php(1085): yii\db\Connection->openFromPool(Array, Array)
#3 /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php(1052): yii\db\Connection->getSlave(false)
#4 /path/humhub/protected/vendor/yiisoft/yii2/db/Command.php(261): yii\db\Connection->getSlavePdo(true)
#5 /path/humhub/protected/vendor/yiisoft/yii2/db/Command.php(1181): yii\db\Command->prepare(true)
#6 /path/humhub/protected/vendor/yiisoft/yii2/db/Command.php(460): yii\db\Command->queryInternal('fetchAll', 7)
#7 /path/humhub/protected/vendor/yiisoft/yii2/db/mysql/Schema.php(122): yii\db\Command->queryColumn()
#8 /path/humhub/protected/vendor/yiisoft/yii2/db/Schema.php(235): yii\db\mysql\Schema->findTableNames('')
#9 /path/humhub/protected/humhub/libs/BaseSettingsManager.php(312): yii\db\Schema->getTableNames()
#10 /path/humhub/protected/humhub/libs/BaseSettingsManager.php(59): humhub\libs\BaseSettingsManager::isDatabaseInstalled()
#11 /path/humhub/protected/vendor/yiisoft/yii2/base/BaseObject.php(109): humhub\libs\BaseSettingsManager->init()
#12 [internal function]: yii\base\BaseObject->__construct(Array)
#13 /path/humhub/protected/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#14 /path/humhub/protected/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('humhub\\componen...', Array, Array)
#15 /path/humhub/protected/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('humhub\\componen...', Array, Array)
#16 /path/humhub/protected/vendor/yiisoft/yii2/di/ServiceLocator.php(137): yii\BaseYii::createObject(Array)
#17 /path/humhub/protected/vendor/yiisoft/yii2/base/Module.php(766): yii\di\ServiceLocator->get('settings', true)
#18 /path/humhub/protected/vendor/yiisoft/yii2/di/ServiceLocator.php(74): yii\base\Module->get('settings')
#19 /path/humhub/protected/humhub/components/Request.php(41): yii\di\ServiceLocator->__get('settings')
#20 /path/humhub/protected/vendor/yiisoft/yii2/base/BaseObject.php(109): humhub\components\Request->init()
#21 [internal function]: yii\base\BaseObject->__construct(Array)
#22 /path/humhub/protected/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#23 /path/humhub/protected/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('humhub\\componen...', Array, Array)
#24 /path/humhub/protected/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('humhub\\componen...', Array, Array)
#25 /path/humhub/protected/vendor/yiisoft/yii2/di/ServiceLocator.php(137): yii\BaseYii::createObject(Array)
#26 /path/humhub/protected/vendor/yiisoft/yii2/base/Module.php(766): yii\di\ServiceLocator->get('request', true)
#27 /path/humhub/protected/vendor/yiisoft/yii2/web/Application.php(160): yii\base\Module->get('request')
#28 /path/humhub/protected/humhub/components/Application.php(51): yii\web\Application->getRequest()
#29 /path/humhub/protected/vendor/yiisoft/yii2/base/Application.php(271): humhub\components\Application->bootstrap()
#30 /path/humhub/protected/humhub/components/Application.php(42): yii\base\Application->init()
#31 /path/humhub/protected/vendor/yiisoft/yii2/base/BaseObject.php(109): humhub\components\Application->init()
#32 /path/humhub/protected/vendor/yiisoft/yii2/base/Application.php(204): yii\base\BaseObject->__construct(Array)
#33 /path/humhub/protected/humhub/components/ApplicationTrait.php(38): yii\base\Application->__construct(Array)
#34 /path/humhub/index.php(25): humhub\components\Application->__construct(Array)
#35 {main}

I'm not using ProxySQl here. Should I open this as different issue, or a feature request?

ArchBlood commented 3 months ago

Hello,

I was trying the configuration from https://yii2-framework.readthedocs.io/en/latest/guide/db-dao/ I add this to common.php under my Redis configuration following the same file format.


// Override DB class
        'db' => [
        'class' => 'yii\db\Connection',

    // Primary configuration
            'dsn' => 'mysql:host=galera.example.com;dbname=VALUE',
            'username' => 'VALUE',
            'password' => 'VALUE',

    // Replica configuration
    'slaveConfig' => [
        'username' => 'VALUE',
        'password' => 'VALUE',
        'attributes' => [
            // use a smaller connection timeout
            PDO::ATTR_TIMEOUT => 10,
        ],
    ],

    // Replica
    'slaves' => [
            'dsn' => 'mysql:host=galera-replica.example.com;dbname=VALUE',
    ],
],

It seems like it should work, but I think I'm missing something HumHub specific. Here's the error.

TypeError: array_merge(): Argument #2 must be of type array, string given in /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php:1202
Stack trace:
#0 /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php(1202): array_merge(Array, 'mysql:host=gale...')
#1 /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php(1163): yii\db\Connection->openFromPoolSequentially(Array, Array)
#2 /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php(1085): yii\db\Connection->openFromPool(Array, Array)
#3 /path/humhub/protected/vendor/yiisoft/yii2/db/Connection.php(1052): yii\db\Connection->getSlave(false)
#4 /path/humhub/protected/vendor/yiisoft/yii2/db/Command.php(261): yii\db\Connection->getSlavePdo(true)
#5 /path/humhub/protected/vendor/yiisoft/yii2/db/Command.php(1181): yii\db\Command->prepare(true)
#6 /path/humhub/protected/vendor/yiisoft/yii2/db/Command.php(460): yii\db\Command->queryInternal('fetchAll', 7)
#7 /path/humhub/protected/vendor/yiisoft/yii2/db/mysql/Schema.php(122): yii\db\Command->queryColumn()
#8 /path/humhub/protected/vendor/yiisoft/yii2/db/Schema.php(235): yii\db\mysql\Schema->findTableNames('')
#9 /path/humhub/protected/humhub/libs/BaseSettingsManager.php(312): yii\db\Schema->getTableNames()
#10 /path/humhub/protected/humhub/libs/BaseSettingsManager.php(59): humhub\libs\BaseSettingsManager::isDatabaseInstalled()
#11 /path/humhub/protected/vendor/yiisoft/yii2/base/BaseObject.php(109): humhub\libs\BaseSettingsManager->init()
#12 [internal function]: yii\base\BaseObject->__construct(Array)
#13 /path/humhub/protected/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#14 /path/humhub/protected/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('humhub\\componen...', Array, Array)
#15 /path/humhub/protected/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('humhub\\componen...', Array, Array)
#16 /path/humhub/protected/vendor/yiisoft/yii2/di/ServiceLocator.php(137): yii\BaseYii::createObject(Array)
#17 /path/humhub/protected/vendor/yiisoft/yii2/base/Module.php(766): yii\di\ServiceLocator->get('settings', true)
#18 /path/humhub/protected/vendor/yiisoft/yii2/di/ServiceLocator.php(74): yii\base\Module->get('settings')
#19 /path/humhub/protected/humhub/components/Request.php(41): yii\di\ServiceLocator->__get('settings')
#20 /path/humhub/protected/vendor/yiisoft/yii2/base/BaseObject.php(109): humhub\components\Request->init()
#21 [internal function]: yii\base\BaseObject->__construct(Array)
#22 /path/humhub/protected/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#23 /path/humhub/protected/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('humhub\\componen...', Array, Array)
#24 /path/humhub/protected/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('humhub\\componen...', Array, Array)
#25 /path/humhub/protected/vendor/yiisoft/yii2/di/ServiceLocator.php(137): yii\BaseYii::createObject(Array)
#26 /path/humhub/protected/vendor/yiisoft/yii2/base/Module.php(766): yii\di\ServiceLocator->get('request', true)
#27 /path/humhub/protected/vendor/yiisoft/yii2/web/Application.php(160): yii\base\Module->get('request')
#28 /path/humhub/protected/humhub/components/Application.php(51): yii\web\Application->getRequest()
#29 /path/humhub/protected/vendor/yiisoft/yii2/base/Application.php(271): humhub\components\Application->bootstrap()
#30 /path/humhub/protected/humhub/components/Application.php(42): yii\base\Application->init()
#31 /path/humhub/protected/vendor/yiisoft/yii2/base/BaseObject.php(109): humhub\components\Application->init()
#32 /path/humhub/protected/vendor/yiisoft/yii2/base/Application.php(204): yii\base\BaseObject->__construct(Array)
#33 /path/humhub/protected/humhub/components/ApplicationTrait.php(38): yii\base\Application->__construct(Array)
#34 /path/humhub/index.php(25): humhub\components\Application->__construct(Array)
#35 {main}

I'm not using ProxySQl here. Should I open this as different issue, or a feature request?

Should look like the following in this case;

return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',

            // Primary configuration
            'dsn' => 'mysql:host=galera.example.com;dbname=VALUE',
            'username' => 'VALUE',
            'password' => 'VALUE',
            'charset' => 'utf8',

            // Replica configuration
            'slaveConfig' => [
                'username' => 'VALUE',
                'password' => 'VALUE',
                'attributes' => [
                    // use a smaller connection timeout
                    PDO::ATTR_TIMEOUT => 10,
                ],
            ],

            // Replicas
            'slaves' => [
                ['dsn' => 'mysql:host=galera-replica.example.com;dbname=VALUE'],
                // Add more replicas if needed
                // ['dsn' => 'mysql:host=another-replica.example.com;dbname=VALUE'],
            ],
        ],

        // Other components like Redis configuration...
    ],

    // Other configuration...
];
jSML4ThWwBID69YC commented 3 months ago

Perfect! That works.

luke- commented 3 months ago

Looks intersting!

The best place to document this would probably be here: https://community.humhub.com/s/installation-and-setup/wiki/overview/list-categories

@gevorgmansuryan Can you perhaps summarise some notes about this in a Gallera Wiki page?

jSML4ThWwBID69YC commented 3 months ago

@luke-

It may be better to put it in the public documentation. Perhaps under https://docs.humhub.org/docs/admin/advanced-configuration/

I can open a pull request if need be.

luke- commented 3 months ago

Please add it to the wiki first, as we cannot yet offer official support for it.

We could possibly make a link to the wiki page here later. https://docs.humhub.org/docs/admin/performance

ArchBlood commented 3 months ago

@luke- maybe add the Require:Documentation and Topic:Performance tags and remove the Kind:BUG tag? Otherwise once the Wiki is created the issue could be closed.

ArchBlood commented 2 months ago

@luke- @gevorgmansuryan edit as needed.

https://community.humhub.com/s/installation-and-setup/wiki/256/MariaDB+Galera+Configuration+for+HumHub

luke- commented 2 months ago

@ArchBlood Thanks!