SamWheating opened a new pull request #19999:
URL: https://github.com/apache/airflow/pull/19999


   Closes: https://github.com/apache/airflow/issues/19988
   
   Splitting this `CREATE TABLE AS SELECT` query into two queries (`CREATE 
TABLE LIKE ..` followed by `INSERT INTO`) because the former doesn't play 
nicely with MySQL.
   
   This PR is inherently difficult to test/validate, but I ran the proposed 
queries against the metadata database in our development environment (where we 
first ran into this issue) and was able to replicate the issue and verify the 
fix:
   
   ```
   // replicating the issue:
   
   MySQL [airflow] > create table _airflow_moved__2_2__task_instance as select 
source.* from task_instance as source;
   ERROR 1786 (HY000): Statement violates GTID consistency: CREATE TABLE ... 
SELECT.
   
   // Validating that splitting the query fixes the issue
   
   MySQL [airflow] > create table _airflow_moved__2_2__task_instance like 
task_instance;
   Query OK, 0 rows affected (0.063 sec)
   
   MySQL [airflow] > INSERT INTO _airflow_moved__2_2__task_instance select 
source.* from task_instance as source left join dag_run as dr on (source.dag_id 
= dr.dag_id and source.execution_date = dr.execution_date) where dr.id is null;
   Query OK, 22900 rows affected (2.110 sec)
   ```
   
   Tomorrow I can create a patched image with these changes and validate the 
fix in our development environment.
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code change, Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in 
[UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to