-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Fix reload gunicorn workers #32102
Fix reload gunicorn workers #32102
Conversation
9edbb17
to
13f12b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there was a good reason we added --preload
, https://github.com/apache/airflow/pull/27297/files and it was to remove lots of integrity warnings generated by parallel gunicorns trying to update the database in parallell and generating race conditions.
This cahnge means that when "reload_on_plugin_change" is turned on, we will start getting those warnings, unless the root cause of the problem has been fixed (I think it hasn't been fixed).
So I think this change only makes sense to be implemented if we find another way to prevent the integrity errors. For example adding some locking strategy for the DB operations that generated integrity warnings - without it, it will be a regression.
cc: @ephraimbuddy ^^ would love your comment on that one |
Exactly my thoughts. Without fixing the source of the IntegrityErrors, this change will be a regression. @AVMusorin How about adding a new configuration that when set to True(default), enables this preloading instead of using the plugin's config? That way it won't be a breaking change. |
Agree, no problem for me. |
OK. Ping us when added. Fine for me too. |
After much debugging on this, I found that once Line 162 in 9d68492
I'd suggest using the reload_on_plugin_change to toggle the --preload. What do you think @potiuk |
13f12b0
to
3287fab
Compare
Sure, if you think it's fine - but it will bring the previous behaviour if If you think It's fine for me - so I won't block it for 2.7.0 - reloading on plugin change is useful, and maybe having Integrity check errors is the price to pay. Maybe it would be a good idea to add a comment for that option that when it is enabled it will (or may? not sure if it happened always) produce those kind of errors and this is expected... |
Removing my "require changes" after Ephraim's comments.
3287fab
to
1418f49
Compare
There was a good description in comments, I moved it to warning message. |
Since gunicorn can't reload a new code if starts with ``--preload`` setting, we need to check ``reload_on_plugin_change`` before set it up. Gunicorn can't reload a new code because the code is preloaded into the master process and worker are launched with ``fork``, they will still have the old code.
c5080af
to
c37f687
Compare
Would like to hear what @jedcunningham @dstandish and @ashb think about this. I will request the changes back until we have agreed on this. In production, it doesn't make sense to reload plugin, so this gives me concern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent accidental merge
The whole point of preload is quite literally to pre-load all the code so that the workers start up quicker. The downside to that is they code changes anywhere won't be reflected. If you want plugins to reload don't use preload. The pr message as it stands looks good to me |
Co-authored-by: Jed Cunningham <[email protected]>
Co-authored-by: Jed Cunningham <[email protected]>
Co-authored-by: Jed Cunningham <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a couple of commits to refine the message. The warning messag especially has some wording issues.
* Toggle gunicorn --preload with reload_on_plugin_change Since gunicorn can't reload a new code if starts with ``--preload`` setting, we need to check ``reload_on_plugin_change`` before set it up. Gunicorn can't reload a new code because the code is preloaded into the master process and worker are launched with ``fork``, they will still have the old code. * added warning message * Improve warning message Co-authored-by: Jed Cunningham <[email protected]> * Improve warning message Co-authored-by: Jed Cunningham <[email protected]> * Improve warning message Co-authored-by: Jed Cunningham <[email protected]> * Minor tweak of warning message * Mention prod issue in config description --------- Co-authored-by: Jed Cunningham <[email protected]> Co-authored-by: Tzu-ping Chung <[email protected]> (cherry picked from commit f78a836)
I think we should allow users to set auto-reload-when-plugins-change for |
Feel free to open PRs for that Or create a feature proposal. Commenting on closed issue is a straight way to your comment being completely ignored. |
Since gunicorn can't reload a new code if starts with
--preload
setting, we need to checkreload_on_plugin_change
before set it up.Gunicorn can't reload a new code because the code is preloaded into the master process and worker are launched with
fork
, they will still have the old code.