magento2: Product EAV index throws error with GTID consistency
Attempting to reindex the Product EAV when binary logging or replication is enabled on MySQL 5.7throws a SQL error. This same type of error is thrown when attempting to create a new category.
Preconditions
- Environment is NGINX 1.10.3 on Ubuntu 16.04.3 LTS running PHP7.0-fpm on a Google Cloud instance.
- MySQL version is 5.7 running on Google Cloud Platform SQL
Steps to reproduce
- Make sure that your Google SQL db has binary logging enabled AND/OR you have replication enabled.
- go to your magento installation and run
php bin/magento indexer:reindex
Expected result
All indexes run correctly and display that they have rebuilt successfully
Actual result
SQLSTATE[HY000]: General error: 1787 Statement violates GTID consistency: CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE can only be executed outside transactional context. These statements are also not allowed in a function or trigger because functions and triggers are also considered to be multi-statement transactions., query was: CREATE TEMPORARY TABLE IF NOT EXISTS catalog_product_index_eav_temp LIKE catalog_product_index_eav_tmp
This error indicates that there is a transaction that violates GTID consistency somewhere in the Product EAV indexing SQL. One suggestion that was made to avoid this problem would be a CREATE VIEW instead of CREATE TEMPORARY TABLE in the indexer module.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 16
- Comments: 32 (4 by maintainers)
Still broken on 2.2 and 2.3 over a year after being reported š¦ Magento should be able to run on a MySQL installation with binary logging enabled.
FOR GOOGLE CLOUD SQL USERS
Iām trying to migrate a 2.3 CE database to Google Cloud SQL on a 2nd gen server. Upon reindexing I get the āviolates GTID consistencyā error for the Product EAV index.
Thereās little info on the forums so far, so thought Iād contribute my findings.
Forget about the module (https://github.com/bangerkuwranger/Magento-2-GTID-Safe-URL-Rewrite-Tables), the guy made it for a project on 2.1 and has no plans to maintain it. Wonāt install on M2.3
Downgrading to a legacy SQL server on Google presented other issues with VM connectivity (ipv4 only, so latency issues / also being discontinued in around a years time)
SOLUTION:
Iām on M2.3 CE and not using db replication, so I just tried to disable āBinary Loggingā on the SQL Server. Go to instance > click Edit > go to Enable auto-backups > Uncheck āEnable binary logging (required for replication and earlier position point-in-time recovery)ā.
Test
bin/magento indexer:reindex
My reindexation of Magento completed without the previous error āviolates GTID consistencyā.I understand the limitations to this approach, but until Magento gets their act together (donāt hold your breath, issue ongoing since 2017), this is the only way I can find to run M2.3 on Google SQL 2nd Gen Servers.
Any update for this?
@scrivvles, thank you for your report. Weāve created internal ticket(s) MAGETWO-82828 to track progress on the issue.
For anyone coming by or reading from various GitHub issues that all that needs to be done to host Magento 2 on Google Cloud SQL is to simply disable binary logging and having no luck, here is the bit of information that is required to get it working:
You need to be using MySQL version
5.7
. You cannot host on Google Cloudās SQL service using its5.6
version.https://dev.mysql.com/doc/refman/5.7/en/replication-options-gtids.html#option_mysqld_enforce-gtid-consistency
Here is the important paragraph that is not mentioned in the
5.6
documentation:In other words, in
5.6
, even withgtid_mode=off
, and binary logging off, theenforce-gtid-consistency
option will still throw an error. In5.7
it will not be āchecked or enforcedā under these same conditions.@gvigner Thanks for the tip! It seems like this is one of those things that belongs in core.
Received this June 26:
Itās worth noting thereās no documentation on this at the moment on the Cloud SQL second gen docs, however this change does more or less mean the HA mechanism for MySQL instances will match the current model for PostgreSQL.
@dharake Yeah I figured out how to get it working in GCP. It was a very subtle difference in the documentation that clued me into the possibility that
5.7
would behave differently.@danemacmillan I am indeed. Iāve hosted 2.3.0-2.3.2 without issues.
Kindly find my settings in the attached screenshots, I hope that can help you.
Linking to https://github.com/magento/magento2/issues/11055
The Module https://github.com/bangerkuwranger/Magento-2-GTID-Safe-URL-Rewrite-Tables only solves part of the problem with the queries