feat(spider-execution-manager): Update Runtime implementation to track the consumed task assignment records.#350
Conversation
WalkthroughIntroduces ChangesTask Assignment Lifecycle and Scheduler Heartbeat
Sequence Diagram(s)sequenceDiagram
participant Runtime
participant SchedulerHeartbeatTask
participant SchedulerClient
participant StorageClient
note over Runtime: create()
Runtime->>SchedulerHeartbeatTask: spawn periodic heartbeat loop
note over Runtime: run() main loop
Runtime->>SchedulerClient: next_task(em_id, prev_assignments.pop_front())
SchedulerClient-->>Runtime: SchedulerResponse(task_assignment, scheduler_id, session_id)
Runtime->>StorageClient: register_task_instance(response)
alt registration ok
StorageClient-->>Runtime: Ok(Some(instance))
Runtime->>Runtime: mark_consume(assignment)
else CacheStale or StaleSession
StorageClient-->>Runtime: Err(CacheStale | StaleSession)
Runtime->>Runtime: refresh liveness, mark_consume, return Ok(None)
else other storage error
StorageClient-->>Runtime: Err(other)
Runtime-->>Runtime: RuntimeError::StorageResponse
end
note over Runtime: shutdown
Runtime->>SchedulerHeartbeatTask: cancel token
Runtime->>SchedulerClient: shutdown(em_id, prev_assignments.into())
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| result = self.scheduler_client.next_task(self.em_id) => { | ||
| result = self.scheduler_client.next_task( | ||
| self.em_id, | ||
| self.prev_assignments.pop_front() |
There was a problem hiding this comment.
Why not report all received assignments?
There was a problem hiding this comment.
I'm not sure yet what the multi-executor implementation would look like, so I made the next_task only send one processed task assignment, assuming the task assignment is from its own previous execution. I think it should be fair for now since we only have one assignment per EM. We could promote this param to a vector in the future, though, if we found it makes more sense for a multi-executor case.
Description
This PR updates the implementation of
Runtimeto reflect the latest changes in our em-to-scheduler protocol: the runtime now keeps track of a queue of previously consumed task assignments. These records are reported back to the scheduler on every task dispatch or on exit. The runtime also sets up a background task to send heartbeats to the scheduler periodically.Checklist
breaking change.
Validation performed
Summary by CodeRabbit
Release Notes
New Features
Improvements
Tests