Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running cron jobs fails if database name is too long #22240

Closed
amenk opened this issue Apr 9, 2019 · 10 comments
Closed

Running cron jobs fails if database name is too long #22240

amenk opened this issue Apr 9, 2019 · 10 comments
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@amenk
Copy link
Contributor

amenk commented Apr 9, 2019

Preconditions (*)

Database is called
shop_test_com_testing_foo_de

You have crontab.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
    <group id="update_virtual_attributes">

Steps to reproduce (*)

  1. bin/magento cron:run -v

Expected result (*)

works

Actual result (*)

doesn't

  [Magento\Framework\Exception\InputException]                                             
  Lock name too long: shop_test_com_testing_foo_de|CRON_GROUP_update_virtual_attribute...  
	                                                                                   

Exception trace:
 () at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/framework/Lock/Backend/Database.php:156
 Magento\Framework\Lock\Backend\Database->addPrefix() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/framework/Lock/Backend/Database.php:66
 Magento\Framework\Lock\Backend\Database->lock() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php:259
 Magento\Cron\Observer\ProcessCronQueueObserver->lockGroup() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php:241
 Magento\Cron\Observer\ProcessCronQueueObserver->execute() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/framework/Event/Invoker/InvokerDefault.php:72
 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/framework/Event/Invoker/InvokerDefault.php:60
 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/framework/Event/Manager.php:66
 Magento\Framework\Event\Manager->dispatch() at /var/www/html/shop.test.com.testing.foo.de/web/generated/code/Magento/Framework/Event/Manager/Proxy.php:95
 Magento\Framework\Event\Manager\Proxy->dispatch() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/framework/App/Cron.php:86
 Magento\Framework\App\Cron->launch() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/module-cron/Console/Command/CronCommand.php:117
 Magento\Cron\Console\Command\CronCommand->execute() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/magento/framework/Console/Cli.php:102
 Magento\Framework\Console\Cli->doRun() at /var/www/html/shop.test.com.testing.foo.de/web/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at /var/www/html/shop.test.com.testing.foo.de/web/bin/magento:23
@m2-assistant
Copy link

m2-assistant bot commented Apr 9, 2019

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

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • 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-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

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

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

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Apr 9, 2019
@ghost ghost self-assigned this Apr 9, 2019
@m2-assistant
Copy link

m2-assistant bot commented Apr 9, 2019

Hi @engcom-backlog-nazar. 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: 👇

  • 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-engcom-team 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-engcom-team 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.

@ghost
Copy link

ghost commented Apr 9, 2019

Hi @amenk thank you for you report, this is expected behavior, please refer to -> https://dev.mysql.com/doc/refman/5.7/en/locking-functions.html

@ghost ghost closed this as completed Apr 9, 2019
@ghost
Copy link

ghost commented Apr 9, 2019

@amenk MySQL 5.7 and later enforces a maximum length on lock names of 64 characters. Previously, no limit was enforced.

@amenk
Copy link
Contributor Author

amenk commented Apr 9, 2019

Thanks for the info --- but can't we then just create the lock name in another way? For example by hashing it ? What is the maximum table name length? then we should enforce a shorter cron group name or so ...

@PascalBrouwers
Copy link
Contributor

This is not expected behaviour. With constraints Magento creates a shorter name when they are too long. It should do the same here.

@PivitParkour94
Copy link

PivitParkour94 commented Oct 29, 2019

I am able to replicate this, but it is manifesting in a confusing admin panel with no menu items loading. The error was being thrown in the log and changing to developer mode threw the error and it would seem it is because my database schema name is 40 characters long, so when the Database lock is loaded, when the prefix is added, the length is greater than 64 and the error is being thrown.
see \Magento\Framework\Lock\Backend\Database::addPrefix

image

Is there a way we can trim the lock name to keep it under 64 to avoid hours of confusion in the future? That would be great.

@PascalBrouwers
Copy link
Contributor

@engcom-backlog-nazar can you reopen this issue?
This is not expected behaviour. With constraints Magento creates a shorter name when they are too long. It should do the same here.

@PascalBrouwers
Copy link
Contributor

Also... see this example of a lock
BLOCK_4d0fde89c53949f89f741386ae575b1d704f9a24-old-price-225261-widget-product-grid-final_price-EUR-20191104-1-0-
Even a db name the size of 1 character would cause the lock to fail

vpashovski added a commit to vpashovski/magento2 that referenced this issue Nov 4, 2019
Create short name for Database Lock name
@VladimirZaets
Copy link
Contributor

Hi @amenk. Thank you for your report.
The issue has been fixed in #25472 by @vpashovski in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.5 release.

@VladimirZaets VladimirZaets added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Nov 24, 2019
magento-engcom-team added a commit that referenced this issue Nov 24, 2019
…me is too long #25472

 - Merge Pull Request #25472 from vpashovski/magento2:issue-22240
 - Merged commits:
   1. 08972b4
   2. 4dce93e
   3. 34f870e
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

5 participants