kingwind94 commented on issue #45366:
URL: https://github.com/apache/airflow/issues/45366#issuecomment-4210504537

     In MySQL, SET clause columns in an UPDATE statement are evaluated 
left-to-right. The original code set state =
     'scheduled' before evaluating the CASE expression for try_number, so by 
the time the CASE reads state, it's already
     'scheduled' — not 'up_for_reschedule'. This makes the condition always 
True, causing try_number to increment on every
     sensor poke.
   
     This does not affect PostgreSQL/SQLite, which evaluate all SET expressions 
using the original row values.
   
     Fix
   
     Swap the column order so try_number is evaluated before state is 
overwritten:
   
     -- Before (buggy): state updated first, CASE reads 'scheduled'
     SET state = 'scheduled', try_number = CASE WHEN state != 
'up_for_reschedule' THEN try_number + 1 ...
   
     -- After (fixed): try_number evaluated first, CASE reads original 
'up_for_reschedule'
     SET try_number = CASE WHEN state != 'up_for_reschedule' THEN try_number + 
1 ..., state = 'scheduled'


-- 
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