Skip to content

feat: Add caching mechanism for plugin model schemas#14898

Merged
Yeuoly merged 2 commits intomainfrom
fix/duplicate-get-model-schema
Mar 4, 2025
Merged

feat: Add caching mechanism for plugin model schemas#14898
Yeuoly merged 2 commits intomainfrom
fix/duplicate-get-model-schema

Conversation

@Yeuoly
Copy link
Contributor

@Yeuoly Yeuoly commented Mar 4, 2025

Summary

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.

Tip

Close issue syntax: Fixes #<issue number> or Resolves #<issue number>, see documentation for more details.

Screenshots

Before After
... ...

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. ⚙️ feat:model-runtime 💪 enhancement New feature or request labels Mar 4, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 4, 2025
@Yeuoly Yeuoly merged commit 4668c49 into main Mar 4, 2025
10 checks passed
@Yeuoly Yeuoly deleted the fix/duplicate-get-model-schema branch March 4, 2025 10:02
jackzhuo pushed a commit to jackzhuo/dify that referenced this pull request Mar 14, 2025
parambharat pushed a commit to parambharat/dify that referenced this pull request Mar 31, 2025
@keakon
Copy link

keakon commented Jun 24, 2025

@Yeuoly @laipz8200

I have some concerns about this change. The locking granularity is too coarse, which causes a single slow request to block all subsequent calls to get_model_schema(), even if the data is already in the cache.
While checking the logs, I found get_model_schema() requests that timed out after 10 minutes. During this period, the entire system was rendered almost unusable. However, once the slow request timed out, subsequent requests started processing normally again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants