Skip to content

[2.4.6-p2] Regression, can trigger error 'Connection "default" is not defined' again #37805

@hostep

Description

@hostep

Preconditions and environment

  • Magento version 2.4.6-p2 (pre-release which isn't available on github here yet) but can also be reproduced on 2.4-develop

Steps to reproduce

  1. Setup a clean Magento
  2. Ensure there is a file app/etc/config.php
  3. Remove the file app/etc/env.php
  4. Make sure you empty the current database, it should hold no data or structure (this might be optional, I haven't checked with an existing database) (Update: confirmed that database doesn't need to be emptied)
  5. Run:
# replace the db parameters with the ones from your own database

./bin/magento setup:install \
    --admin-firstname=Firstname \
    --admin-lastname=Lastname \
    --admin-email=email@example.com \
    --admin-user=admin \
    --admin-password=admin124 \
    --base-url=https://url.example/ \
    --base-url-secure=https://url.example/ \
    --backend-frontname=admin \
    --db-host={dbhost} \  # your db host
    --db-name={dbname} \  # your db name
    --db-user={dbuser} \  # your db user
    --db-password={dbpass} \  # your db user's password
    --language=en_US \
    --currency=EUR \
    --timezone=Europe/Brussels \
    --use-rewrites=1 \
    --use-secure=1 \
    --use-secure-admin=1 \
    --admin-use-security-key=1 \
    --session-save=files \
    --cleanup-database \
    -vvv

Expected result

Works without issues

Actual result

Getting

...
[Progress: 861 / 864]
Disabling Maintenance Mode:

In ResourceConnection.php line 162:

  [DomainException]
  Connection "default" is not defined


Exception trace:
  at lib/internal/Magento/Framework/App/ResourceConnection.php:162
 Magento\Framework\App\ResourceConnection->getConnectionByName() at generated/code/Magento/Framework/App/ResourceConnection/Interceptor.php:41
 Magento\Framework\App\ResourceConnection\Interceptor->getConnectionByName() at lib/internal/Magento/Framework/App/ResourceConnection.php:111
 Magento\Framework\App\ResourceConnection->getConnection() at generated/code/Magento/Framework/App/ResourceConnection/Interceptor.php:23
 Magento\Framework\App\ResourceConnection\Interceptor->getConnection() at lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php:312
 Magento\Framework\Model\ResourceModel\Db\AbstractDb->getConnection() at app/code/Magento/MessageQueue/Model/ResourceModel/Lock.php:103
 Magento\MessageQueue\Model\ResourceModel\Lock->releaseOutdatedLocks() at app/code/Magento/MessageQueue/Model/Plugin/ResourceModel/Lock.php:39
 Magento\MessageQueue\Model\Plugin\ResourceModel\Lock->afterSet() at lib/internal/Magento/Framework/Interception/Interceptor.php:146
 Magento\Framework\App\MaintenanceMode\Interceptor->Magento\Framework\Interception\{closure}() at lib/internal/Magento/Framework/Interception/Interceptor.php:153
 Magento\Framework\App\MaintenanceMode\Interceptor->___callPlugins() at generated/code/Magento/Framework/App/MaintenanceMode/Interceptor.php:32
 Magento\Framework\App\MaintenanceMode\Interceptor->set() at setup/src/Magento/Setup/Model/Installer.php:1503
 Magento\Setup\Model\Installer->setMaintenanceMode() at n/a:n/a
 call_user_func_array() at setup/src/Magento/Setup/Model/Installer.php:388
 Magento\Setup\Model\Installer->install() at setup/src/Magento/Setup/Console/Command/InstallCommand.php:238
 Magento\Setup\Console\Command\InstallCommand->execute() at vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at lib/internal/Magento/Framework/Console/Cli.php:116
 Magento\Framework\Console\Cli->doRun() at vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at bin/magento:23

Additional information

This problem does not occur with Magento 2.4.6-p1, so this is a regression bug.
Issue is most likely to happen in CI pipelines, to run integration tests, or whatever else needs a database.

This can be solved

  • by removing the app/etc/config.php before running bin/magento setup:install (but that can lead to other problems)
  • by running bin/magento setup:install twice (where you account for the first one to fail, the first execution will generate a env.php file, so the second run can load this config in memory)

This bug has something to do with these changes that were added in Magento 2.4.6-p2: ACP2E-1958: avoid reloading configs for each requested key (cc @bubasuma & @o-iegorov)

It has something to do with trying to fetch the configuration for key db which it doesn't find, because it has only loaded the config from config.php file and not from the env.php file. So most likely once the db configuration is written to env.php file, it's not being refreshed in memory and leads to this problem.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrameworkIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P1Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions