Skip to content

Commit 49165b2

Browse files
author
Marvin Zhang
committed
refactor(node): reorganize task reconciliation, prioritize worker cache, add periodic cleanup
- Move and document reconciliation constants and add sectioned organization/comments. - Split large monolithic logic into smaller functions: - reconcileDisconnectedTasks / reconcileDisconnectedTask - reconcileAbandonedAssignedTasks - reconcileStalePendingTasks / handleStalePendingTask - getActualTaskStatus / getStatusFromWorkerCache / triggerWorkerStatusSync - queryProcessStatus / requestProcessStatusFromWorker / mapProcessStatusToTaskStatus - findTasksByStatus / markTaskDisconnected / findAvailableNodeForTask - updateTaskStatus / saveTask / shouldMarkTaskAbnormal / markTaskAbnormal - Add periodic background workers: - StartPeriodicReconciliation -> runPeriodicReconciliation to reconcile running/disconnected tasks - runPeriodicAssignedTaskCleanup -> cleanupStuckAssignedTasks to detect and recover stuck assigned tasks - Prioritize worker-side cached status and attempt sync from task runner before querying worker processes. - Introduce a placeholder createWorkerClient for future gRPC worker discovery/invocation. - Replace ad-hoc DB updates with saveTask using retry/backoff and centralize status update logic. - Improve logging and error messages, and tighten conditions for marking tasks abnormal. This refactor clarifies responsibilities, improves reliability of status updates, and prepares the codebase for future worker gRPC integration.
1 parent 883c954 commit 49165b2

1 file changed

Lines changed: 416 additions & 362 deletions

File tree

0 commit comments

Comments
 (0)