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:start Celery with a Redis cluster not in the same slot (#4472) #4478

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vicwang3
Copy link

@vicwang3 vicwang3 commented May 17, 2024

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #4472

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • TODO

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
  • optional I have made corresponding changes to the documentation
  • optional I have added tests that prove my fix is effective or that my feature works
  • optional New and existing unit tests pass locally with my changes

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working labels May 17, 2024
@crazywoola crazywoola requested a review from takatost May 18, 2024 02:26
@bowenliang123
Copy link
Contributor

Some questions for further investigation:

  1. how the global_keyprefix config of celery helps to fix the slot problem in Redis cluster concepts.
  2. What's {celery_global_prefix} in the config example? Any reference explanation for the usage ? Is that template holder in some way?

@binarx2
Copy link

binarx2 commented May 20, 2024

The configuration option should be result_backend_transport_options ?

https://docs.celeryq.dev/en/stable/getting-started/backends-and-brokers/redis.html#global-keyprefix

@vicwang3
Copy link
Author

Some questions for further investigation:

  1. how the global_keyprefix config of celery helps to fix the slot problem in Redis cluster concepts.
  2. What's {celery_global_prefix} in the config example? Any reference explanation for the usage ? Is that template holder in some way?

The root of the issue is that in Redis cluster mode, keys are distributed across different nodes, and the cluster requires that all keys involved in a specific operation must be located within the same slot since such operations are designed to be executed atomically on a single node.
Solution
Utilizing Redis’s hash tag feature when defining keys for the message queue can ensure that related keys are assigned to the same slot. Users can customize the hash tag CELERY_GLOBAL_PREFIX={celery_global_prefix} in the .env configuration. When operating on REDIS, CELERY_GLOBAL_PREFIX will automatically be used as a prefix. Redis will then assign keys with the same hash tag to the same SLOT.

@crazywoola
Copy link
Member

This one can be reviewed as well.
#4520

* origin/main: (93 commits)
  chore: node help link (langgenius#4795)
  Add SearchApi tools (langgenius#4648)
  chore: improve node user experience (langgenius#4792)
  fix: in tool and http node of iteration can not show item var correctly (langgenius#4791)
  feat: Add logging warning when MAIL_TYPE is not set (langgenius#4771)
  fix organize agent's history messages without recalculating tokens (langgenius#4324)
  feat: support define tags in tool yaml (langgenius#4763)
  feat: update ernie model (langgenius#4756)
  fix: incorrect workflow max call depth (langgenius#4759)
  feat: support baichuan3 turbo, baichuan3 turbo 128k, and baichuan4 (langgenius#4762)
  fix: confusing chart description (langgenius#4760)
  style: fix annotation panel display misalignment (langgenius#4750)
  Add WORKFLOW_CALL_MAX_DEPTH env var. (langgenius#4713)
  Fix/4742 ollama num gpu option not consistent with allowed values (langgenius#4751)
  style: the 'all' of add tool panel should contain workflow tools (langgenius#4755)
  fix: Corrected schema link in model_runtime's README.md (langgenius#4757)
  fix: optimize sticky header styles z-index in tools - ProviderList component (langgenius#4746)
  fix: workflow run sequence number slow sql (langgenius#4737)
  Show tool i18n name on chat pannel (langgenius#4724)
  fix: Correct context size for banchuan2-53b and banchuan2-turbo (langgenius#4721)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
4 participants