Magento2: Since 2.3.2, we can no longer switch maintenance modes with an empty database

Created on 5 Jul 2019  路  20Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento 2.3.2
  2. PHP 7.2.19

Steps to reproduce (*)

  1. Setup Magento 2.3.1 using composer
  2. Drop the database and create it again so it's empty (meaning: db has zero tables)
  3. Run bin/magento maintenance:enable or bin/magento maintenance:disable
  4. Notice that this works => good
  5. Setup Magento 2.3.2 using composer
  6. Drop the database and create it again so it's empty (meaning: db has zero tables)
  7. Run bin/magento maintenance:enable or bin/magento maintenance:disable
  8. Notice that this crashes => not good

Expected result (*)

  1. Maintenance mode switching should work on an empty database like it did in Magento 2.3.1

Actual result (*)

  1. We get this error (including stack trace):
$ bin/magento maintenance:enable -vvv

In Mysql.php line 110:

  [Zend_Db_Statement_Exception (42)]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento23-test.core_config_data' doesn't exist, query was: SELECT `main_table`.* FROM `core_config_data` AS `main_table`


Exception trace:
 () at vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110
 Magento\Framework\DB\Statement\Pdo\Mysql->tryExecute() at vendor/magento/framework/DB/Statement/Pdo/Mysql.php:92
 Magento\Framework\DB\Statement\Pdo\Mysql->_execute() at vendor/magento/zendframework1/library/Zend/Db/Statement.php:303
 Zend_Db_Statement->execute() at vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:480
 Zend_Db_Adapter_Abstract->query() at vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:238
 Zend_Db_Adapter_Pdo_Abstract->query() at vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:542
 Magento\Framework\DB\Adapter\Pdo\Mysql->_query() at vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:617
 Magento\Framework\DB\Adapter\Pdo\Mysql->query() at vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:737
 Zend_Db_Adapter_Abstract->fetchAll() at vendor/magento/framework/Data/Collection/Db/FetchStrategy/Query.php:21
 Magento\Framework\Data\Collection\Db\FetchStrategy\Query->fetchAll() at vendor/magento/framework/Data/Collection/AbstractDb.php:778
 Magento\Framework\Data\Collection\AbstractDb->_fetchAll() at vendor/magento/framework/Data/Collection/AbstractDb.php:673
 Magento\Framework\Data\Collection\AbstractDb->getData() at vendor/magento/framework/Data/Collection/AbstractDb.php:576
 Magento\Framework\Data\Collection\AbstractDb->loadWithFilter() at vendor/magento/framework/Data/Collection/AbstractDb.php:561
 Magento\Framework\Data\Collection\AbstractDb->load() at vendor/magento/framework/Data/Collection.php:838
 Magento\Framework\Data\Collection->getIterator() at vendor/magento/module-config/App/Config/Source/RuntimeConfigSource.php:82
 Magento\Config\App\Config\Source\RuntimeConfigSource->loadConfig() at vendor/magento/module-config/App/Config/Source/RuntimeConfigSource.php:62
 Magento\Config\App\Config\Source\RuntimeConfigSource->get() at vendor/magento/framework/App/Config/ConfigSourceAggregated.php:40
 Magento\Framework\App\Config\ConfigSourceAggregated->get() at vendor/magento/module-config/App/Config/Type/System/Reader.php:60
 Magento\Config\App\Config\Type\System\Reader->read() at generated/code/Magento/Config/App/Config/Type/System/Reader/Proxy.php:95
 Magento\Config\App\Config\Type\System\Reader\Proxy->read() at vendor/magento/module-config/App/Config/Type/System.php:371
 Magento\Config\App\Config\Type\System->readData() at vendor/magento/framework/Cache/LockGuardedCacheLoader.php:79
 Magento\Framework\Cache\LockGuardedCacheLoader->lockedLoadData() at vendor/magento/module-config/App/Config/Type/System.php:261
 Magento\Config\App\Config\Type\System->loadDefaultScopeData() at vendor/magento/module-config/App/Config/Type/System.php:195
 Magento\Config\App\Config\Type\System->getWithParts() at vendor/magento/module-config/App/Config/Type/System.php:169
 Magento\Config\App\Config\Type\System->get() at vendor/magento/framework/App/Config.php:131
 Magento\Framework\App\Config->get() at vendor/magento/framework/App/Config.php:80
 Magento\Framework\App\Config->getValue() at vendor/magento/module-page-cache/Model/Config.php:119
 Magento\PageCache\Model\Config->getType() at vendor/magento/module-cache-invalidate/Observer/FlushAllCacheObserver.php:45
 Magento\CacheInvalidate\Observer\FlushAllCacheObserver->execute() at vendor/magento/framework/Event/Invoker/InvokerDefault.php:88
 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() at vendor/magento/framework/Event/Invoker/InvokerDefault.php:74
 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() at vendor/magento/framework/Event/Manager.php:66
 Magento\Framework\Event\Manager->dispatch() at generated/code/Magento/Framework/Event/Manager/Proxy.php:95
 Magento\Framework\Event\Manager\Proxy->dispatch() at vendor/magento/module-page-cache/Model/Cache/Type.php:51
 Magento\PageCache\Model\Cache\Type->clean() at vendor/magento/framework/App/Cache/TypeList.php:194
 Magento\Framework\App\Cache\TypeList->cleanType() at vendor/magento/framework/App/Cache/Manager.php:91
 Magento\Framework\App\Cache\Manager->clean() at vendor/magento/module-page-cache/Observer/SwitchPageCacheOnMaintenance.php:72
 Magento\PageCache\Observer\SwitchPageCacheOnMaintenance->turnOffFullPageCache() at vendor/magento/module-page-cache/Observer/SwitchPageCacheOnMaintenance.php:55
 Magento\PageCache\Observer\SwitchPageCacheOnMaintenance->execute() at vendor/magento/framework/Event/Invoker/InvokerDefault.php:88
 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() at vendor/magento/framework/Event/Invoker/InvokerDefault.php:74
 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() at vendor/magento/framework/Event/Manager.php:66
 Magento\Framework\Event\Manager->dispatch() at vendor/magento/framework/App/MaintenanceMode.php:82
 Magento\Framework\App\MaintenanceMode->set() at setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php:90
 Magento\Setup\Console\Command\AbstractMaintenanceCommand->execute() at vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at vendor/symfony/console/Application.php:893
 Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/console/Application.php:262
 Symfony\Component\Console\Application->doRun() at vendor/magento/framework/Console/Cli.php:105
 Magento\Framework\Console\Cli->doRun() at vendor/symfony/console/Application.php:145
 Symfony\Component\Console\Application->run() at bin/magento:23

In Mysql.php line 91:

  [PDOException (42S02)]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento23-test.core_config_data' doesn't exist


Exception trace:
 () at vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91
 PDOStatement->execute() at vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91
 Magento\Framework\DB\Statement\Pdo\Mysql->Magento\Framework\DB\Statement\Pdo\{closure}() at vendor/magento/framework/DB/Statement/Pdo/Mysql.php:107
 Magento\Framework\DB\Statement\Pdo\Mysql->tryExecute() at vendor/magento/framework/DB/Statement/Pdo/Mysql.php:92
 Magento\Framework\DB\Statement\Pdo\Mysql->_execute() at vendor/magento/zendframework1/library/Zend/Db/Statement.php:303
 Zend_Db_Statement->execute() at vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:480
 Zend_Db_Adapter_Abstract->query() at vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:238
 Zend_Db_Adapter_Pdo_Abstract->query() at vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:542
 Magento\Framework\DB\Adapter\Pdo\Mysql->_query() at vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:617
 Magento\Framework\DB\Adapter\Pdo\Mysql->query() at vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:737
 Zend_Db_Adapter_Abstract->fetchAll() at vendor/magento/framework/Data/Collection/Db/FetchStrategy/Query.php:21
 Magento\Framework\Data\Collection\Db\FetchStrategy\Query->fetchAll() at vendor/magento/framework/Data/Collection/AbstractDb.php:778
 Magento\Framework\Data\Collection\AbstractDb->_fetchAll() at vendor/magento/framework/Data/Collection/AbstractDb.php:673
 Magento\Framework\Data\Collection\AbstractDb->getData() at vendor/magento/framework/Data/Collection/AbstractDb.php:576
 Magento\Framework\Data\Collection\AbstractDb->loadWithFilter() at vendor/magento/framework/Data/Collection/AbstractDb.php:561
 Magento\Framework\Data\Collection\AbstractDb->load() at vendor/magento/framework/Data/Collection.php:838
 Magento\Framework\Data\Collection->getIterator() at vendor/magento/module-config/App/Config/Source/RuntimeConfigSource.php:82
 Magento\Config\App\Config\Source\RuntimeConfigSource->loadConfig() at vendor/magento/module-config/App/Config/Source/RuntimeConfigSource.php:62
 Magento\Config\App\Config\Source\RuntimeConfigSource->get() at vendor/magento/framework/App/Config/ConfigSourceAggregated.php:40
 Magento\Framework\App\Config\ConfigSourceAggregated->get() at vendor/magento/module-config/App/Config/Type/System/Reader.php:60
 Magento\Config\App\Config\Type\System\Reader->read() at generated/code/Magento/Config/App/Config/Type/System/Reader/Proxy.php:95
 Magento\Config\App\Config\Type\System\Reader\Proxy->read() at vendor/magento/module-config/App/Config/Type/System.php:371
 Magento\Config\App\Config\Type\System->readData() at vendor/magento/framework/Cache/LockGuardedCacheLoader.php:79
 Magento\Framework\Cache\LockGuardedCacheLoader->lockedLoadData() at vendor/magento/module-config/App/Config/Type/System.php:261
 Magento\Config\App\Config\Type\System->loadDefaultScopeData() at vendor/magento/module-config/App/Config/Type/System.php:195
 Magento\Config\App\Config\Type\System->getWithParts() at vendor/magento/module-config/App/Config/Type/System.php:169
 Magento\Config\App\Config\Type\System->get() at vendor/magento/framework/App/Config.php:131
 Magento\Framework\App\Config->get() at vendor/magento/framework/App/Config.php:80
 Magento\Framework\App\Config->getValue() at vendor/magento/module-page-cache/Model/Config.php:119
 Magento\PageCache\Model\Config->getType() at vendor/magento/module-cache-invalidate/Observer/FlushAllCacheObserver.php:45
 Magento\CacheInvalidate\Observer\FlushAllCacheObserver->execute() at vendor/magento/framework/Event/Invoker/InvokerDefault.php:88
 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() at vendor/magento/framework/Event/Invoker/InvokerDefault.php:74
 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() at vendor/magento/framework/Event/Manager.php:66
 Magento\Framework\Event\Manager->dispatch() at generated/code/Magento/Framework/Event/Manager/Proxy.php:95
 Magento\Framework\Event\Manager\Proxy->dispatch() at vendor/magento/module-page-cache/Model/Cache/Type.php:51
 Magento\PageCache\Model\Cache\Type->clean() at vendor/magento/framework/App/Cache/TypeList.php:194
 Magento\Framework\App\Cache\TypeList->cleanType() at vendor/magento/framework/App/Cache/Manager.php:91
 Magento\Framework\App\Cache\Manager->clean() at vendor/magento/module-page-cache/Observer/SwitchPageCacheOnMaintenance.php:72
 Magento\PageCache\Observer\SwitchPageCacheOnMaintenance->turnOffFullPageCache() at vendor/magento/module-page-cache/Observer/SwitchPageCacheOnMaintenance.php:55
 Magento\PageCache\Observer\SwitchPageCacheOnMaintenance->execute() at vendor/magento/framework/Event/Invoker/InvokerDefault.php:88
 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() at vendor/magento/framework/Event/Invoker/InvokerDefault.php:74
 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() at vendor/magento/framework/Event/Manager.php:66
 Magento\Framework\Event\Manager->dispatch() at vendor/magento/framework/App/MaintenanceMode.php:82
 Magento\Framework\App\MaintenanceMode->set() at setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php:90
 Magento\Setup\Console\Command\AbstractMaintenanceCommand->execute() at vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at vendor/symfony/console/Application.php:893
 Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/console/Application.php:262
 Symfony\Component\Console\Application->doRun() at vendor/magento/framework/Console/Cli.php:105
 Magento\Framework\Console\Cli->doRun() at vendor/symfony/console/Application.php:145
 Symfony\Component\Console\Application->run() at bin/magento:23

maintenance:enable [--ip IP] [--magento-init-params MAGENTO-INIT-PARAMS]

Discussion

I understand this is a weird case, but we have some script in our workflow which runs against this problem and I was a bit surprised to see this happening now in 2.3.2

Backend Setup Fixed in 2.3.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.3.x

All 20 comments

Hi @hostep. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [x] Summary of the issue
  • [x] Information on your environment
  • [x] Steps to reproduce
  • [x] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@hostep do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [x] yes
  • [ ] no

Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 6. Add label Issue: Confirmed once verification is complete.

  • [ ] 7. Make sure that automatic system confirms that report has been added to the backlog.

@magento give me 2.3-develop instance

Hi @engcom-Charlie. Thank you for your request. I'm working on Magento 2.3-develop instance for you

Hi @engcom-Charlie, here is your Magento instance.
Admin access: https://i-23577-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

Hi @hostep thank you for your report, I'm not able to reproduce issue by steps you described on clean 2.3.2-develop.
If you'd like to update issue, please reopen it.
6

@engcom-Charlie, has Magento 2.3.2 code already been merged in 2.3-develop? Because a couple of days ago that wasn't the case yet...
This first needs to happen before you can start testing properly on the 2.3-develop branch I think.

Update: confirmed, Magento 2.3.2 code hasn't been merged yet. So you should stop testing all new reported issues on 2.3-develop, until that happens. This is slightly annoying that it takes this long for that merge to happen...

Hello @hostep. Magento 2.3.2 will not merge into 2.3-develop. No plan for it.

Say what? Can you explain please, this makes no sense?

If you mean that the tag 2.3.2 isn't going to be merged in 2.3-develop, but all the feature branches which were merged in 2.3.2 are going to be merged in 2.3-develop, then that's fine as well, but it needs to happen pretty soon if possible!

Like how are we supposed to send in bugfixes for code which is part of 2.3.2 but not yet part of 2.3-develop? And how can you guys try to verify issue reports from Magento 2.3.2 if the code of 2.3.2 isn't merged in 2.3-develop?

Hi @hostep can you please clarify what code from 2.3.2 is missing in 2.3-develop branch?

@sivaschenko: sure, I think it might be everything related to the security fixes from 2.3.2

Here are some random examples:

Let's continue with the issue itself.

I just tested on 2.3-develop (using c3f29ce8efa1e59c7e1f01b6eab2f09504442924) and was able to reproduce myself, looks like @engcom-Charlie didn't test properly.

Did some git bisecting between 2.3.1 and 2.3.2, and found this commit to have caused this regression: https://github.com/magento/magento2/commit/0e373538ded9abe3051d8e9e7a04ca1b6e1d173f

Currently I have no more personal interest in seeing this fixed as we now have a workaround in our workflow scripts for this issue.

Leaving it open for now, but if Magento maintainers consider this not a regression, feel free to close.

Hello @hostep ! Thank you for your contribution !
I just tested this case on 2.3-develop (using that commit) and wasnt able to reproduce this issue . Maybe im missing some steps or details ? I`m closing it for now but feel free to reopen in case you can provide some extra steps/details so i will reproduce it .
Thanks in advance !

Screenshot from 2019-07-18 10-46-18

Screenshot from 2019-07-18 10-46-53

I can still reproduce on latest 2.3-develop (I've used commit 2e7f0396e37)

Steps to reproduce:

  1. Clone 2.3-develop branch
  2. Run composer install
  3. Run bin/magento setup:install ...
  4. Run following queries in mysql: DROP DATABASE {database-name-which-was-used-in-step3}; CREATE DATABASE {database-name-which-was-used-in-step3};
  5. Run bin/magento maintenance:enable

Some observation I made, is that when I remove the app/etc/env.php file, the command works again. This now reminds me of https://github.com/magento/magento2/issues/15864, it's not exactly the same, but feels very similar.

@hostep now i reproduced it . Thank you for your collaboration !

image_2019_07_18T11_16_40_151Z

:white_check_mark: Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-18260 were created

Issue Available: @engcom-Charlie, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

@hostep : Same issue for me whe n trying to deploy an new Magento Server with existing code.

Before 2.3.2 : env.php is present. Install fails if [install] section is present in env.php. Succeed if env.php is present but no [install] section inside.

With 2.3.2 : Install fails if env.php is present. Install succeed if env.php is absent.

Hi @ivan-koliadynskyy. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • [ ] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [ ] 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


Hi @hostep. Thank you for your report.
The issue has been fixed in magento/magento2#24959 by @ivan-koliadynskyy in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.4 release.

@magento-engcom-team @ivan-koliadynskyy
Can anyone check this comment ?
https://github.com/magento/magento2/issues/26692#issuecomment-589086483

if the check result is not cached and it can affect performance and increase DB load ?

Was this page helpful?
0 / 5 - 0 ratings