-
Notifications
You must be signed in to change notification settings - Fork 196
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
Handle thread safety wrt the messaging API in callbacks #3145
Handle thread safety wrt the messaging API in callbacks #3145
Conversation
1b75939
to
f69d9b0
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.
One suggestion/question and one requested change so far.
requirements.txt
Outdated
@@ -6,7 +6,7 @@ colander | |||
cornice>=3.1.0 | |||
dogpile.cache | |||
pyasn1-modules # Due to an unfortunate dash in its name, installs break if pyasn1 is installed first | |||
fedora_messaging | |||
fedora_messaging>=1.6.0 | |||
feedgen | |||
jinja2 | |||
kitchen |
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.
Since we directly use twisted now, we should also add twisted to this list.
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.
Right, I've added it.
bodhi/server/consumers/composer.py
Outdated
# safety. | ||
blockingCallFromThread( | ||
reactor, notifications.publish, | ||
topic="composer.start", msg=dict(agent=agent), force=True) |
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.
Would it be cleaner if we made notifications.publish()
do this when passed a new option (perhaps a boolean like run_in_reactor
or some better name)? I don't mind this, but it might be easier to remember to do it if it were done in one place and had an easy parameter to select the behaviour.
What do you think? I'm fine with this style if you prefer it.
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 tried that at first, but I think it's better that way, because if we do it in notifications.publish()
we'll have to handle the case where notifications are delayed after the DB transaction, so that one more layer down where we'll have to pass that flag. And since it's an issue that only affects message callbacks and is pretty specific to the way message callbacks are run, I thought it's more logical to handle these particularities there.
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.
Cool.
793391d
to
f63c0bb
Compare
a6f7dec
to
2cbe13f
Compare
Rebased. |
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.
We should add a release note that twisted is now required - I'll do this for you, push and approve. Thanks!
|
2cbe13f
to
5a456d8
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.
Thanks!
Strange, the f29 build failed with rpmdb corruption issues:
|
This failure happened in #3158 as well. |
I've filed https://bugzilla.redhat.com/show_bug.cgi?id=1705265 about the rpmdb corruption issue. |
I've opened #3207 to work around https://bugzilla.redhat.com/show_bug.cgi?id=1705265 |
The message callbacks are run in a thread by Twisted, and must therefore call the messaging API with the proper Twisted wrapper to ensure thread safety. See: https://fedora-messaging.readthedocs.io/en/stable/consuming.html#synchronous-and-asynchronous-calls Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
a705384
to
e07fc25
Compare
This patch is planned for inclusion in the upcoming 4.0.0 release: #3221 |
Bodhi 4.0.0 beta is built and deployed to staging: https://copr.fedorainfracloud.org/coprs/bowlofeggs/bodhi-pre-release |
The message callbacks are run in a thread by Twisted, and must therefore call the messaging API with the proper Twisted wrapper to ensure thread safety.
See: https://fedora-messaging.readthedocs.io/en/stable/consuming.html#synchronous-and-asynchronous-calls