Skip to content
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: serialization error when gossip working #6566

Merged

Conversation

kitsuyui
Copy link
Contributor

@kitsuyui kitsuyui commented Dec 28, 2020

Fix of #5075

Current problem

Currently, Gossip does not respect accept_content when generating a consumer.
If you have multiple Celery workers running and allow pickle with accept_content, you may get a Refusing to deserialize disabled content of type pickle (application/x-python-serialize) error.

This error does not occur when running a single worker, but it does occur when running multiple workers.

What this PR does

  • Make Gossip respect accept_content
    • To do this, Gossip needs to pass accept_content when generating a consumer
  • Add tests to verify that multiple workers are running and no errors containing Refusing to deserialize disabled content of type are occurring

Additional notes

  • Some of the existing unit tests use Mock() to replace Gossip processing. This is the case with t/unit/worker/test_consumer.py.

    • The Mock() needs to be configured with additional settings to work as intended with this change.
  • Some of the tests are unstable. I (@kitsuyui) have confirmed that these failures occur without my changes.

  1. The update to Codecov reports sometimes fails with a 500 error
  2. Integration tests sometimes fail due to timeouts

@@ -176,6 +176,7 @@ def get_consumers(self, channel):
channel,
queues=[ev.queue],
on_message=partial(self.on_message, ev.event_from_message),
accept=ev.accept,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, thanks for the PR, but this change needs some unit test to get accepted

@auvipy
Copy link
Member

auvipy commented Jan 4, 2021

Description

fix of #5075
Pass accept when Gossip getting consumers.

can you at least add a unit test for this fix?

@kitsuyui
Copy link
Contributor Author

kitsuyui commented Jan 5, 2021

@auvipy
Thanks. I'd tried to do that but it will take more time for me.
Or can you write instead of me?

@auvipy
Copy link
Member

auvipy commented Jan 6, 2021

@auvipy
Thanks. I'd tried to do that but it will take more time for me.
Or can you write instead of me?

you can take your time, I have other priorities todo in celery at the moment

@thedrow thedrow modified the milestones: 5.0.6, 5.1.0 Feb 24, 2021
@thedrow thedrow added this to Review in progress in Celery 5.1.0 Feb 24, 2021
@thedrow
Copy link
Member

thedrow commented Feb 24, 2021

@kitsuyui Is there a chance that you'll complete this PR soon?

@kitsuyui
Copy link
Contributor Author

@thedrow No.
I don't have any clue to solve soon. I've tried but the unit test has become too complicated.

@auvipy auvipy closed this Feb 24, 2021
Celery 5.1.0 automation moved this from Review in progress to Done Feb 24, 2021
@auvipy auvipy reopened this Feb 24, 2021
Celery 5.1.0 automation moved this from Done to In progress Feb 24, 2021
@auvipy auvipy moved this from In progress to Postponed in Celery 5.1.0 May 4, 2021
@auvipy auvipy modified the milestones: 5.1.0, 5.2 May 4, 2021
@auvipy auvipy modified the milestones: 5.2, 5.2.x Oct 31, 2021
@thedrow thedrow removed this from the 5.2.x milestone Dec 13, 2021
@auvipy auvipy added this to the 5.3.x milestone Jun 21, 2022
@auvipy auvipy closed this Feb 6, 2023
@auvipy auvipy reopened this Feb 6, 2023
@jbvsmo
Copy link

jbvsmo commented Oct 3, 2023

Any news on this? As the author said he can't finish is it possible some celery mantainer pick it up, please? cc @auvipy

This is affecting us greatly with no other fix or workaround

@auvipy
Copy link
Member

auvipy commented Oct 3, 2023

We need to verify this is working and not creating any regression. Thanks for the ping

@rfqu
Copy link

rfqu commented Oct 13, 2023

I encountered this issue too and solved by adding
accept_content = ['application/json', 'application/x-python-serialize','application/x-pickle2']

@auvipy
Copy link
Member

auvipy commented Oct 14, 2023

I encountered this issue too and solved by adding accept_content = ['application/json', 'application/x-python-serialize','application/x-pickle2']

hey! great to know that. is it possible for you to send a PR to improve the docs regarding the issue/solution you mentioned?

@wlach
Copy link
Contributor

wlach commented Oct 21, 2023

I encountered this issue too and solved by adding accept_content = ['application/json', 'application/x-python-serialize','application/x-pickle2']

Based on what I've seen, I don't see how this could fix the problem since the problem is that gossip doesn't respect these settings. I'm pretty sure this PR is the correct solution based on a frustrating encounter with this issue today.

Is there any chance we could merge this as-is and file a follow-up for a unit test? This is a pretty bad bug: it will affect anyone still using pickle serialization with gossip.

@auvipy
Copy link
Member

auvipy commented Oct 22, 2023

problem is the patch is making the CI red. which means it will create regression

@kitsuyui
Copy link
Contributor Author

Hi, sorry for being vague. Sorry for the long delay.

I have quitted the company that required this patch. However, I now have time to develop it. If there is anything I can do to help, I would like to do so.

I have already found a way to reproduce the problem at #5075 (comment), so I could try again.

The problem was that I was not able to write the necessary tests well, and I was unable to eliminate concerns about regression. I may still need someone's help in this.

@kitsuyui kitsuyui force-pushed the gossip-get-consumer-prefer-event-receiver-accept branch from 1a18671 to c8f286b Compare October 22, 2023 14:23
@kitsuyui kitsuyui mentioned this pull request Oct 22, 2023
@auvipy
Copy link
Member

auvipy commented Oct 23, 2023

thanks for coming back! as you shared in your repo kitsuyui#5 (comment) some changes on these tests would be needed. I currently have a big backlog in celery to clear. so in the mean time if you can try to figure out some sort of test, it would be great

@auvipy auvipy removed their assignment Oct 23, 2023
@kitsuyui kitsuyui force-pushed the gossip-get-consumer-prefer-event-receiver-accept branch from c8f286b to 55574dc Compare October 26, 2023 08:38
@kitsuyui
Copy link
Contributor Author

kitsuyui commented Oct 26, 2023

@auvipy Hi. I have updated the commits and description of the pull request.
I have added tests. I have also confirmed that the tests fail if I do not make this change.
I have confirmed that the tests pass on my local environment and on the CI of my fork. (kitsuyui#5)
But I am not confident that these tests meet your standards.
Could you please review this?

@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3723009) 87.33% compared to head (53ea3f3) 87.33%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6566   +/-   ##
=======================================
  Coverage   87.33%   87.33%           
=======================================
  Files         148      148           
  Lines       18515    18515           
  Branches     3163     3163           
=======================================
  Hits        16170    16170           
  Misses       2060     2060           
  Partials      285      285           
Flag Coverage Δ
unittests 87.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
celery/worker/consumer/gossip.py 96.96% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@auvipy
Copy link
Member

auvipy commented Oct 27, 2023

thanks for the tests! the failures seems to be github network related. so going to re start the CI

@auvipy auvipy closed this Oct 27, 2023
@auvipy auvipy reopened this Oct 27, 2023
@kitsuyui
Copy link
Contributor Author

@auvipy Hi, I can't rerun CI because I don't have permissions on the project. Please retry. ☕

@Nusnus
Copy link
Member

Nusnus commented Nov 6, 2023

@kitsuyui

@auvipy Hi, I can't rerun CI because I don't have permissions on the project. Please retry. ☕

Please rebase on main.
CI fixes were pushed.

I will make sure the CI will run if it won't automatically.

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please pull from main branch again

Pass accept when Gossip getting consumers.
If event_serializer, result_serializer, accept_content are set correctly, it works normally.
Otherwise, an error is output to the log. Test that.
@kitsuyui kitsuyui force-pushed the gossip-get-consumer-prefer-event-receiver-accept branch from 55574dc to 53ea3f3 Compare November 8, 2023 08:38
@kitsuyui
Copy link
Contributor Author

kitsuyui commented Nov 8, 2023

@Nusnus @auvipy Hi, I rebased the branch and pushed it again.

@Nusnus
Copy link
Member

Nusnus commented Nov 8, 2023

@Nusnus @auvipy Hi, I rebased the branch and pushed it again.

Thank you!
I'll review it later today

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@auvipy auvipy merged commit 4e88881 into celery:main Nov 8, 2023
32 checks passed
@kitsuyui
Copy link
Contributor Author

kitsuyui commented Nov 8, 2023

@auvipy @Nusnus Thank you!

@kitsuyui kitsuyui deleted the gossip-get-consumer-prefer-event-receiver-accept branch November 8, 2023 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Celery 5.1.0
  
Postponed
Development

Successfully merging this pull request may close these issues.

None yet

7 participants