From 8c6502de2f8ec2bd8382cd6945c327d7be400e14 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 28 Jan 2026 05:34:41 +0000
Subject: [PATCH] =Queue cleanup - seems to be working enough to get legacy before and after going!
---
inc/registry/CheckCustomTables.php | 91 ++++++++++++++++++++++++++-------------------
1 files changed, 53 insertions(+), 38 deletions(-)
diff --git a/inc/registry/CheckCustomTables.php b/inc/registry/CheckCustomTables.php
index e587f0d..16962fc 100644
--- a/inc/registry/CheckCustomTables.php
+++ b/inc/registry/CheckCustomTables.php
@@ -444,51 +444,66 @@
`id` VARCHAR(64) NOT NULL,
`type` varchar(50) NOT NULL,
`user_id` {$this->userIDType} NOT NULL,
- `request_data` JSON NOT NULL,
- `count` int(11) NOT NULL DEFAULT 1,
- `progress_count` int(11) DEFAULT 0,
+
+ `request_data` JSON NOT NULL CHECK (JSON_VALID(request_data)),
+
+ `total_items` int(11) NOT NULL DEFAULT 1,
+ `processed_items` int(11) DEFAULT 0,
`failed_items` JSON,
- `priority` enum('low', 'normal', 'high') DEFAULT 'normal',
- `status` enum('pending', 'scheduled', 'processing','failed', 'failed_permanent', 'completed', 'completed_with_errors') DEFAULT 'pending',
- `metadata` JSON DEFAULT NULL,
- `merge` enum('merge', 'append', 'replace') DEFAULT 'merge',
- `scheduled_at` datetime DEFAULT CURRENT_TIMESTAMP,
- `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
- `updated_at` datetime DEFAULT CURRENT_TIMESTAMP,
- `started_at` datetime DEFAULT NULL,
+
+ `priority` ENUM('high', 'normal', 'low') DEFAULT 'normal',
+ `state` enum('pending', 'scheduled', 'processing', 'completed') DEFAULT 'pending',
+ `outcome` enum('pending', 'success', 'partial', 'failed','failed_permanent') DEFAULT 'pending',
+
+ `retries` int(11) DEFAULT 0,
+ `last_error_hash` CHAR(32) DEFAULT NULL,
+ `error_message` text,
+
+ `scheduled_at` datetime DEFAULT NULL,
+ `started_at` datetime DEFAULT CURRENT_TIMESTAMP,
`completed_at` datetime DEFAULT NULL,
- `retries` int(11) DEFAULT 0,
+
+ `metadata` JSON DEFAULT NULL,
`result` JSON,
`dependencies` JSON,
- `error_message` text,
+
`user_dismissed` tinyint(1) DEFAULT 0,
- PRIMARY KEY (`id`),
- KEY `idx_status_priority` (`status`, `priority`),
- KEY `idx_user_type` (`user_id`, `type`),
- KEY `idx_created_at` (`created_at`),
- KEY `idx_completed_at` (`completed_at`),
- KEY `idx_user_status` (`user_id`, `status`),
- KEY `idx_retries_status` (`retries`, `status`),
- KEY `idx_user_status_created` (`user_id`, `status`, `created_at`),
- KEY `idx_scheduled_processing` (`scheduled_at`, `status`)
+ `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
+ `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ KEY `idx_run_queue` (state, priority, scheduled_at),
+ KEY `idx_user_ops` (user_id, state),
+ KEY `idx_user_type_pending` (user_id, type, state),
+ KEY `idx_completed_at` (completed_at),
+ KEY `idx_processing_stuck` (`state`, `started_at`)
)",
+
'stats__operation_queue' => "(
- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
- `date` date NOT NULL,
- `type` varchar(50) NOT NULL,
- `total_operations` int NOT NULL DEFAULT 0,
- `successful_operations` int NOT NULL DEFAULT 0,
- `failed_operations` int NOT NULL DEFAULT 0,
- `average_duration` float DEFAULT NULL,
- `total_items_processed` int NOT NULL DEFAULT 0,
- `peak_queue_size` int NOT NULL DEFAULT 0,
- `peak_memory_usage` int DEFAULT NULL,
- `peak_cpu_usage` float DEFAULT NULL,
- `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`id`),
- UNIQUE KEY (`date`, `type`),
- KEY `date_idx` (`date`),
- KEY `type_idx` (`type`)
+ `id` bigint unsigned AUTO_INCREMENT,
+ `date` date NOT NULL,
+ `type` varchar(50) NOT NULL,
+
+ `total_operations` int NOT NULL DEFAULT 0,
+ `successful_operations` int NOT NULL DEFAULT 0,
+ `partial_operations` int NOT NULL DEFAULT 0,
+ `failed_operations` int NOT NULL DEFAULT 0,
+ `failed_permanent_operations` int NOT NULL DEFAULT 0,
+
+ `total_items_processed` int NOT NULL DEFAULT 0,
+
+ `average_duration` float DEFAULT NULL,
+ `max_duration` int DEFAULT NULL,
+
+ `peak_queue_size` int NOT NULL DEFAULT 0,
+
+ `peak_memory_usage` int DEFAULT NULL,
+ `peak_cpu_usage` float DEFAULT NULL,
+
+ `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY (date, type),
+ KEY `date_idx` (date),
+ KEY `type_idx` (type)
)"
];
}
--
Gitblit v1.10.0