JCoder01 commented on issue #13099:
URL: https://github.com/apache/airflow/issues/13099#issuecomment-748263101


   @ashb I think I narrowed this down to being an issue with one of my plugins 
(a FAB view) that relies on an Airflow Variable. I think this is the same one I 
pinged you about on Slack a week or two ago and we thought it was likely due to 
me running the scheduler a debugger, but maybe that wasn't (entirely) the 
problem. I found that if I commented out the lines that did the call to 
`Variables` the pk violations stopped happening. If I put them back in, stopped 
the scheduler long enough for a dag to need to be triggered right away (with 
one scheduled to run every minute, that was one minute) and then started the 
scheduler again, it would trigger the pk violation.
   
   In trying to recreate a minimal example, I added the following to a file in 
plugins/
   
   ```
   from airflow.models.variable import Variable
   v = Variable().get("VAR")
   ```
   and upon starting the it triggered this Error:
   `RuntimeError: UNEXPECTED COMMIT - THIS WILL BREAK HA LOCKS!`
   which was the same error I pinged you about.
   This made be go back and look at the code in the plugin and I had:
   ```
   try:
       models = Variables().get("MODELS")
   except:
       models = []
   ```
   If I took out the generic except, then rather than kicking out a pk 
violation, it raised the UNEXPECTED COMMIT error. So the pk violation was 
happening because of the overly broad except in the plugin code.
   
   So this brings up the question about how does one use Variables in Plugins 
without breaking the HA code?
   
   


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

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


Reply via email to