| 35547 |
amit |
1 |
-- ============================================================
|
|
|
2 |
-- Solr Update Failures Table
|
|
|
3 |
-- Purpose: Track failed Solr updates for visibility and retry
|
|
|
4 |
-- Created: 2026-01-14
|
|
|
5 |
-- ============================================================
|
|
|
6 |
|
|
|
7 |
-- Create table for tracking Solr update failures
|
|
|
8 |
CREATE TABLE IF NOT EXISTS solr_update_failures (
|
|
|
9 |
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
|
10 |
catalog_id INT NOT NULL COMMENT 'Catalog ID that failed to update in Solr',
|
|
|
11 |
item_id INT COMMENT 'Item ID (optional, for reference)',
|
|
|
12 |
change_type VARCHAR(50) COMMENT 'Type of change: PRICE_UPDATED, STATUS_CHANGED, CREATED, DELETED',
|
|
|
13 |
error_message TEXT COMMENT 'Error message from failed Solr update',
|
|
|
14 |
retry_count INT DEFAULT 0 COMMENT 'Number of retry attempts',
|
|
|
15 |
status VARCHAR(20) DEFAULT 'PENDING' COMMENT 'PENDING, RETRYING, FAILED, RESOLVED',
|
|
|
16 |
created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'When the failure occurred',
|
|
|
17 |
last_retry_at DATETIME COMMENT 'Last retry attempt timestamp',
|
|
|
18 |
|
|
|
19 |
INDEX idx_status (status),
|
|
|
20 |
INDEX idx_catalog_id (catalog_id),
|
|
|
21 |
INDEX idx_created_at (created_at)
|
|
|
22 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Tracks failed Solr update attempts for monitoring and retry';
|
|
|
23 |
|
|
|
24 |
-- ============================================================
|
|
|
25 |
-- Sample Queries for Dashboard
|
|
|
26 |
-- ============================================================
|
|
|
27 |
|
|
|
28 |
-- Get count of pending failures
|
|
|
29 |
-- SELECT COUNT(*) as pending_count FROM solr_update_failures WHERE status = 'PENDING';
|
|
|
30 |
|
|
|
31 |
-- Get all pending failures
|
|
|
32 |
-- SELECT * FROM solr_update_failures WHERE status = 'PENDING' ORDER BY created_at ASC;
|
|
|
33 |
|
|
|
34 |
-- Get failures that exceeded max retries (need manual intervention)
|
|
|
35 |
-- SELECT * FROM solr_update_failures WHERE status = 'FAILED' ORDER BY created_at DESC;
|
|
|
36 |
|
|
|
37 |
-- Clean up old resolved entries (optional maintenance)
|
|
|
38 |
-- DELETE FROM solr_update_failures WHERE status = 'RESOLVED' AND created_at < DATE_SUB(NOW(), INTERVAL 7 DAY);
|