4

On a dockerized CI environment (Ubuntu 20.04) we are getting the following error:

cd dev/tests/integration; ../../../vendor/bin/phpunit -v --testsuite 'Our Tests'

...

Disabling Maintenance Mode:

In ResourceConnection.php line 148:

[DomainException]
Connection "default" is not defined

This seems during the automated sandbox installation.

When we run the command again, it works.

But after we deleted the sandboxes using

rm dev/tests/integration/tmp/sandbox-* -r

it does not work again on the first try.

We found https://github.com/magento/magento2/issues/22198 which says this could be related to the opcache.enable_cli option, but this one is already switched to Off.

Does anybody know how to fix this?

It did not happen for Magento 2.4.2 and surfaced after the upgrade to Magento 2.4.3.

EDIT: Exception trace:

Exception trace:
  at /var/www/vendor/magento/framework/App/ResourceConnection.php:148
 Magento\Framework\App\ResourceConnection->getConnectionByName() at /var/www/vendor/magento/framework/App/ResourceConnection.php:97
 Magento\Framework\App\ResourceConnection->getConnection() at /var/www/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:333
 Magento\Framework\Model\ResourceModel\Db\AbstractDb->getConnection() at /var/www/vendor/magento/module-message-queue/Model/ResourceModel/Lock.php:103
 Magento\MessageQueue\Model\ResourceModel\Lock->releaseOutdatedLocks() at /var/www/vendor/magento/module-message-queue/Model/Plugin/ResourceModel/Lock.php:39
 Magento\MessageQueue\Model\Plugin\ResourceModel\Lock->afterSet() at /var/www/vendor/magento/framework/Interception/Interceptor.php:146
 Magento\Framework\App\MaintenanceMode\Interceptor->Magento\Framework\Interception\{closure}() at /var/www/vendor/magento/framework/Interception/Interceptor.php:153
 Magento\Framework\App\MaintenanceMode\Interceptor->___callPlugins() at /var/www/generated/code/Magento/Framework/App/MaintenanceMode/Interceptor.php:23
 Magento\Framework\App\MaintenanceMode\Interceptor->set() at /var/www/setup/src/Magento/Setup/Model/Installer.php:1442
 Magento\Setup\Model\Installer->setMaintenanceMode() at n/a:n/a
 call_user_func_array() at /var/www/setup/src/Magento/Setup/Model/Installer.php:389
 Magento\Setup\Model\Installer->install() at /var/www/setup/src/Magento/Setup/Console/Command/InstallCommand.php:231
 Magento\Setup\Console\Command\InstallCommand->execute() at /var/www/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /var/www/vendor/symfony/console/Application.php:1009
 Symfony\Component\Console\Application->doRunCommand() at /var/www/vendor/symfony/console/Application.php:273
 Symfony\Component\Console\Application->doRun() at /var/www/vendor/magento/framework/Console/Cli.php:115
 Magento\Framework\Console\Cli->doRun() at /var/www/vendor/symfony/console/Application.php:149
 Symfony\Component\Console\Application->run() at /var/www/bin/magento:23

4 Answers 4

8
+50

This is issue #33802. A pull request linked there is reported to fix the issue.

1
1

Quick workaround: open your app/etc/env.php and duplicate the db.connection.default into a db.connection.db

Something like this:

<?php

return [
    # [..]
    'db' => [
        # [..]
        'connection' => [
            'default' => [
                'host' => 'db',
                'dbname' => 'magento',
                'username' => 'magento',
                'password' => 'magento',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1',
                'driver_options' => [
                    1014 => false
                ]
            ],
            'db' => [
                'host' => 'db',
                'dbname' => 'magento',
                'username' => 'magento',
                'password' => 'magento',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1',
                'driver_options' => [
                    1014 => false
                ]
            ]
        ]
    ],
    # [..]
];
1

This issue is appearing again in 2.4.6-p2 and is tracked in issue #37805. At the time of wrinting this answer adobe is already working on this issue but no PR has been linked yet.

I have created a patch to get the integration tests running again until it is fixed properly:

@package magento/framework
@level 4

Index: vendor/magento/framework/App/DeploymentConfig.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/magento/framework/App/DeploymentConfig.php b/vendor/magento/framework/App/DeploymentConfig.php
--- a/vendor/magento/framework/App/DeploymentConfig.php
+++ b/vendor/magento/framework/App/DeploymentConfig.php (date 1692798116511)
@@ -94,9 +94,7 @@
         }
         $result = $this->getByKey($key);
         if ($result === null) {
-            if (empty($this->flatData) || count($this->getAllEnvOverrides())) {
-                $this->reloadData();
-            }
+            $this->reloadData();
             $result = $this->getByKey($key);
         }
         return $result ?? $defaultValue;
@@ -184,9 +182,7 @@
      */
     private function reloadInitialData(): void
     {
-        if (empty($this->readerLoad) || empty($this->data) || empty($this->flatData)) {
-            $this->readerLoad = $this->reader->load();
-        }
+        $this->readerLoad = $this->reader->load();
         $this->data = array_replace(
             $this->readerLoad,
             $this->overrideData ?? [],

-3

Replace hhvm with php7 and everything worked fine. The installer check needs to warn if hhvm is not supported

1
  • We are not using hhvm, but PHP7.4
    – Alex
    Dec 10, 2021 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.