[PR #30323] fix(api): remove tool provider list cache to fix cache inconsistency #32774

Closed
opened 2026-02-21 20:52:03 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/30323

State: closed
Merged: Yes


Summary

Remove the Redis caching mechanism for tool provider list API that was introduced in #29101.

Problems with the current caching approach

  1. Cache inconsistency: After CRUD operations on tool providers, cached data may not be properly invalidated, causing stale data to be returned to users.

  2. Race conditions: Cache invalidation timing issues - invalidating cache inside Redis locks caused timeouts (#30150), but moving it outside can cause race conditions.

  3. Hard to maintain: Manual cache invalidation is scattered across multiple service files (api_tools_manage_service.py, workflow_tools_manage_service.py, builtin_tools_manage_service.py, tool_providers.py), making it error-prone and difficult to maintain. Missing any invalidation call leads to inconsistency.

  4. User-facing symptoms:

    • Newly created tools not appearing in the list
    • Deleted tools still showing up
    • Updated tool configurations not reflecting immediately
    • MCP provider auth state not updating correctly

Changes

  • Remove ToolProviderListCache class and its test file
  • Remove cache invalidation calls from all service files
  • Remove related test mocks
  • Keep the valuable code optimizations from #29101 (session management, batch processing in tool_manager.py)

Test plan

  • make lint passes
  • make type-check passes
  • Unit tests pass
  • Manual testing: verify tool CRUD operations reflect immediately without stale data

Fixes #30322

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/langgenius/dify/pull/30323 **State:** closed **Merged:** Yes --- ## Summary Remove the Redis caching mechanism for tool provider list API that was introduced in #29101. ### Problems with the current caching approach 1. **Cache inconsistency**: After CRUD operations on tool providers, cached data may not be properly invalidated, causing stale data to be returned to users. 2. **Race conditions**: Cache invalidation timing issues - invalidating cache inside Redis locks caused timeouts (#30150), but moving it outside can cause race conditions. 3. **Hard to maintain**: Manual cache invalidation is scattered across multiple service files (`api_tools_manage_service.py`, `workflow_tools_manage_service.py`, `builtin_tools_manage_service.py`, `tool_providers.py`), making it error-prone and difficult to maintain. Missing any invalidation call leads to inconsistency. 4. **User-facing symptoms**: - Newly created tools not appearing in the list - Deleted tools still showing up - Updated tool configurations not reflecting immediately - MCP provider auth state not updating correctly ### Changes - Remove `ToolProviderListCache` class and its test file - Remove cache invalidation calls from all service files - Remove related test mocks - **Keep** the valuable code optimizations from #29101 (session management, batch processing in `tool_manager.py`) ## Test plan - [x] `make lint` passes - [x] `make type-check` passes - [ ] Unit tests pass - [ ] Manual testing: verify tool CRUD operations reflect immediately without stale data Fixes #30322 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-21 20:52:03 -05:00
yindo closed this issue 2026-02-21 20:52:03 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32774