Files
momentry_core/migrations/20261011_pipeline_queue.sql
T
Accusys 63fbbe1225 release: v1.3.1 - Pipeline Queue Integration, OCR Fix, Worker Compatibility
Major Changes:
- Pipeline Queue integration completed (internal.file + pipeline.commands)
- Fixed old job_worker database compatibility with new command_queue table
- Compiled Swift OCR binary (was missing, causing empty OCR results)
- Added deep scan functionality through re-scan API

Fixes:
- Changed CommandJob.id from i32 to i64 for database compatibility
- Added UUID generation in create_command (message_id field)
- Fixed claim_pending_commands to query queue_name = 'internal.file'
- Fixed field mappings: command_id → message_id, job_type → command_type
- Added support for 'processing' status in CommandJobStatus

Queue System:
- internal.file queue: for register/unregister/re-scan commands (job_worker)
- pipeline.commands queue: for vectorize/store_asrx/etc commands (pipeline_worker)

Documentation:
- Added comprehensive queue system documentation
- Created M4 workspace status reports
- Updated AGENTS.md with queue system details
2026-10-12 10:00:51 +08:00

73 lines
3.0 KiB
SQL

-- ============================================
-- Pipeline Queue 集成
-- ============================================
-- Version: 1.0
-- Date: 2026-10-11
-- Description: Pipeline 命令队列路由配置
-- ============================================
-- ============================================
-- 1. 插入 Pipeline 命令路由
-- ============================================
INSERT INTO queue_routes (command_type, command_category, queue_name, handler, priority, billing_required) VALUES
-- Pipeline 操作
('internal', 'pipeline_store_asrx', 'pipeline.commands', 'pipeline_worker', 1, false),
('internal', 'pipeline_execute_rule1', 'pipeline.commands', 'pipeline_worker', 2, false),
('internal', 'pipeline_vectorize', 'pipeline.commands', 'pipeline_worker', 3, false),
('internal', 'pipeline_phase1_pack', 'pipeline.commands', 'pipeline_worker', 2, false),
('internal', 'pipeline_mark_complete', 'pipeline.commands', 'pipeline_worker', 1, false),
('internal', 'pipeline_execute_rule3', 'pipeline.commands', 'pipeline_worker', 2, false),
('internal', 'pipeline_reindex_embeddings', 'pipeline.commands', 'pipeline_worker', 3, false)
ON CONFLICT (command_type, command_category) DO NOTHING;
-- ============================================
-- 2. 创建 Pipeline 进度追踪表
-- ============================================
CREATE TABLE IF NOT EXISTS pipeline_progress (
id SERIAL PRIMARY KEY,
command_id VARCHAR(36) NOT NULL UNIQUE,
file_uuid VARCHAR(32) NOT NULL,
command_type VARCHAR(50) NOT NULL,
-- 进度
progress INTEGER DEFAULT 0, -- 0-100
message TEXT,
processed_count BIGINT DEFAULT 0,
total_count BIGINT DEFAULT 0,
-- 状态
status VARCHAR(20) DEFAULT 'processing',
error_message TEXT,
-- 时间戳
started_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
completed_at TIMESTAMP WITH TIME ZONE,
-- 索引
FOREIGN KEY (command_id) REFERENCES command_queue(message_id) ON DELETE CASCADE
);
CREATE INDEX idx_pipeline_progress_file ON pipeline_progress(file_uuid, started_at);
CREATE INDEX idx_pipeline_progress_status ON pipeline_progress(status, started_at);
-- ============================================
-- 3. 创建 Pipeline 执行日志视图
-- ============================================
CREATE OR REPLACE VIEW pipeline_execution_stats AS
SELECT
command_category,
COUNT(*) as total_executions,
COUNT(*) FILTER (WHERE status = 'completed') as successful,
COUNT(*) FILTER (WHERE status = 'failed') as failed,
AVG(EXTRACT(EPOCH FROM (processing_completed_at - processing_started_at)) * 1000) FILTER (WHERE status = 'completed') as avg_duration_ms,
MIN(processing_started_at) as first_execution,
MAX(processing_started_at) as last_execution
FROM command_queue
WHERE command_type = 'internal'
AND command_category LIKE 'pipeline_%'
GROUP BY command_category
ORDER BY command_category;
-- ============================================
-- Schema 扩展完成
-- ============================================