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
This commit is contained in:
+93
-15
@@ -26,6 +26,8 @@ struct FileStatsResponse {
|
||||
processors: Vec<ProcessorStatus>,
|
||||
// PostgreSQL counts
|
||||
postgres: PostgresStats,
|
||||
// ASRX stats
|
||||
asrx: AsrxStats,
|
||||
// Qdrant collection counts
|
||||
qdrant: QdrantStats,
|
||||
// TKG stats
|
||||
@@ -56,6 +58,13 @@ struct PostgresStats {
|
||||
file_identities: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Default)]
|
||||
struct AsrxStats {
|
||||
status: Option<String>,
|
||||
segment_count: i32,
|
||||
language: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct QdrantStats {
|
||||
faces: i64,
|
||||
@@ -241,14 +250,13 @@ async fn scan_files(
|
||||
State(state): State<AppState>,
|
||||
Query(params): Query<ScanFilesQuery>,
|
||||
) -> Result<Json<ScanFilesResponse>, StatusCode> {
|
||||
let demo_dir_str = std::env::var("MOMENTRY_SFTP_ROOT")
|
||||
.unwrap_or_else(|_| {
|
||||
std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|p| p.parent().map(|d| d.join("var/sftpgo/data/demo")))
|
||||
.map(|p| p.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "var/sftpgo/data/demo".to_string())
|
||||
});
|
||||
let demo_dir_str = std::env::var("MOMENTRY_SFTP_ROOT").unwrap_or_else(|_| {
|
||||
std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|p| p.parent().map(|d| d.join("var/sftpgo/data/demo")))
|
||||
.map(|p| p.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "var/sftpgo/data/demo".to_string())
|
||||
});
|
||||
let demo_dir = std::path::Path::new(&demo_dir_str);
|
||||
|
||||
let allowed_extensions = vec![
|
||||
@@ -431,8 +439,8 @@ struct RegisteredVideo {
|
||||
async fn get_sftpgo_status(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<SftpgoStatusResponse>, StatusCode> {
|
||||
let demo_dir = std::env::var("MOMENTRY_SFTP_ROOT")
|
||||
.unwrap_or_else(|_| "var/sftpgo/data/demo".to_string());
|
||||
let demo_dir =
|
||||
std::env::var("MOMENTRY_SFTP_ROOT").unwrap_or_else(|_| "var/sftpgo/data/demo".to_string());
|
||||
|
||||
let files_count: i64 = std::fs::read_dir(&demo_dir)
|
||||
.map(|entries| entries.count() as i64)
|
||||
@@ -816,6 +824,29 @@ async fn get_ingestion_status(
|
||||
async fn get_file_stats(
|
||||
State(state): State<AppState>,
|
||||
Path(file_uuid): Path<String>,
|
||||
) -> Result<Json<FileStatsResponse>, StatusCode> {
|
||||
// Wrap entire handler in a 60-second timeout to prevent indefinite
|
||||
// hangs from multiple scroll_all_points calls or slow DB queries.
|
||||
// This is the last line of defense: each individual HTTP call has a
|
||||
// 30s timeout (via new_http_client), but multiple calls + DB queries
|
||||
// could still exceed reasonable response time.
|
||||
match tokio::time::timeout(
|
||||
std::time::Duration::from_secs(60),
|
||||
get_file_stats_inner(state, file_uuid),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(result) => result,
|
||||
Err(_) => {
|
||||
tracing::error!("get_file_stats timed out after 60s");
|
||||
Err(StatusCode::REQUEST_TIMEOUT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_file_stats_inner(
|
||||
state: AppState,
|
||||
file_uuid: String,
|
||||
) -> Result<Json<FileStatsResponse>, StatusCode> {
|
||||
let pool = state.db.pool();
|
||||
|
||||
@@ -959,7 +990,48 @@ async fn get_file_stats(
|
||||
.unwrap_or(0),
|
||||
};
|
||||
|
||||
// 4. Get Qdrant stats
|
||||
// 4. Get ASRX stats from processor_results
|
||||
let pr_table = schema::table_name("processor_results");
|
||||
let mj_table = schema::table_name("monitor_jobs");
|
||||
|
||||
#[derive(sqlx::FromRow)]
|
||||
struct AsrxRow {
|
||||
status: Option<String>,
|
||||
segment_count: i32,
|
||||
language: Option<String>,
|
||||
}
|
||||
|
||||
let asrx_data_result = sqlx::query_as::<_, AsrxRow>(&format!(
|
||||
"SELECT pr.asr_status AS status, COALESCE(pr.segment_count, 0) AS segment_count, pr.output_data->>'language' AS language \
|
||||
FROM {pr_table} pr \
|
||||
JOIN {mj_table} mj ON pr.job_id = mj.id \
|
||||
WHERE mj.uuid = $1 AND pr.processor = 'asrx' \
|
||||
LIMIT 1"
|
||||
))
|
||||
.bind(&file_uuid)
|
||||
.fetch_optional(pool)
|
||||
.await;
|
||||
|
||||
let asrx = match asrx_data_result {
|
||||
Ok(Some(row)) => {
|
||||
eprintln!("[ASRX-DEBUG] Found data: status={:?}, segment_count={}, language={:?}", row.status, row.segment_count, row.language);
|
||||
AsrxStats {
|
||||
status: row.status,
|
||||
segment_count: row.segment_count,
|
||||
language: row.language,
|
||||
}
|
||||
}
|
||||
Ok(None) => {
|
||||
eprintln!("[ASRX-DEBUG] No ASRX data found for uuid={}", file_uuid);
|
||||
AsrxStats::default()
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("[ASRX-DEBUG] Query failed for uuid={}: {}", file_uuid, e);
|
||||
AsrxStats::default()
|
||||
}
|
||||
};
|
||||
|
||||
// 5. Get Qdrant stats
|
||||
use crate::core::db::qdrant_db::QdrantDb;
|
||||
use serde_json::json;
|
||||
|
||||
@@ -1202,6 +1274,7 @@ async fn get_file_stats(
|
||||
processing_completed_at,
|
||||
processors,
|
||||
postgres,
|
||||
asrx,
|
||||
qdrant: qdrant_stats,
|
||||
tkg,
|
||||
face_dedup,
|
||||
@@ -1390,7 +1463,12 @@ async fn get_pipeline_progress_handler(
|
||||
pp.update_stage("face_dedup", 1.0, "completed", Some("no faces".to_string()));
|
||||
} else if tkg_edge_count == 0 {
|
||||
// Faces detected but no relationships
|
||||
pp.update_stage("face_dedup", 1.0, "completed", Some("no relationships".to_string()));
|
||||
pp.update_stage(
|
||||
"face_dedup",
|
||||
1.0,
|
||||
"completed",
|
||||
Some("no relationships".to_string()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1419,15 +1497,15 @@ async fn get_pipeline_progress_handler(
|
||||
} else {
|
||||
"running"
|
||||
};
|
||||
|
||||
|
||||
let vlm_progress = if vlm_total == 0 {
|
||||
1.0 // Completed with 0 results
|
||||
1.0 // Completed with 0 results
|
||||
} else if vlm_done > 0 {
|
||||
vlm_done as f64 / vlm_total as f64
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
|
||||
pp.update_stage(
|
||||
"vlm_summary",
|
||||
vlm_progress,
|
||||
|
||||
Reference in New Issue
Block a user