- Add admin dashboard with sync controls and data browser - Implement RMM, Auvik, and Addigy organization mappings - Add chunked ticket sync with progress tracking - Implement entity sync service with rate limiting - Add analytics engine and performance optimizer - Create data browser for all PSA entities - Add navigation components and UI improvements - Implement background processing and sync services - Add comprehensive documentation and migration scripts - Update configuration items with multi-system support - Enhance contact management and purchase history - Add issue type assignment and LLM analyzer - Improve error handling and logging utilities
2.7 KiB
RMM Cache Invalidation Fix
Issue
Company 29683395 (TK Plastics Company, Inc.) was showing 0 RMM devices on the configuration items page despite having 2 RMM site mappings configured in the database.
Root Cause
The /api/rmm-devices endpoint was using a cache key that didn't account for changes in RMM site mappings:
Old cache key format: rmm-devices:${companyId}:${activeFilter}
This meant that when RMM site mappings were added for a company, the cache would continue serving the old data (with 0 RMM devices) until the cache expired (2 minutes).
Database Verification
-- Company has 2 RMM site mappings
SELECT * FROM rmm_site_mappings WHERE company_id = 29683395;
-- Results:
-- 612f6b1f-9228-4e2a-8e63-f0ec5d0b6aaa | TK Plastics
-- aba39a7b-d9b3-4eff-88e4-4d0182d478cb | TK Plastics - Kaercher
Solution
1. Updated Cache Key to Include Mapping Count
Modified /app/api/rmm-devices/route.ts to include the number of site mappings in the cache key:
New cache key format: rmm-devices:${companyId}:${activeFilter}:mappings-${mappingCount}
This ensures that when mappings are added or removed, the cache is automatically invalidated because the key changes.
2. Added Force Refresh Capability
Added a skipCache query parameter to allow bypassing the cache entirely when needed:
- Added
forceRefreshstate to the configuration items page - Updated the refresh button to increment
forceRefreshcounter - When
forceRefresh > 0, adds&skipCache=trueto the API request - Made the refresh button show a spinner animation while loading
3. Improved Refresh Button UX
- Refresh button now shows spinning animation while loading
- Button is disabled during loading to prevent multiple simultaneous requests
- Button is disabled when no company is selected
Files Modified
/app/api/rmm-devices/route.ts- Updated cache key logic and added skipCache parameter/app/configuration-items/page.tsx- Added force refresh capability and improved refresh button
Testing
After deploying these changes:
- The cache key will automatically change from
rmm-devices:29683395:active:mappings-0tormm-devices:29683395:active:mappings-2 - This will force a fresh API call that will fetch devices from both mapped RMM sites
- Users can also click the refresh button to force bypass the cache
Expected Behavior
- Company 29683395 should now show RMM devices from both "TK Plastics" and "TK Plastics - Kaercher" sites
- Any future changes to RMM site mappings will automatically invalidate the cache
- Users can manually force a refresh by clicking the refresh button
Related Documentation
/docs/rmm-multi-site-integration.md- RMM multi-site support architecture- System-retrieved memory about RMM site mappings implementation