Design an asynchronous long-running query service with durable jobs, worker leases, safe retries, cancellation, status tracking, and large-result retrieval.
Design a service that accepts long-running queries without keeping a client request open for the entire execution. Explain submission, execution, progress/status, result retrieval, and failure recovery.
### Constraints & Assumptions
The source supplies the long-running-query design topic but no query language, execution engine, duration, or workload figures. Establish those requirements before choosing capacity or isolation policies.
### Clarifying Questions to Ask
- Can queries be retried safely, or can they have side effects?
- Must clients receive partial results, progress updates, cancellation, or only final results?
- What retention and access rules apply to completed results?
```hint Separate acceptance from completion
A durable query identifier lets a client disconnect while execution continues elsewhere.
```
### What a Strong Answer Covers
- Durable query state and an asynchronous execution queue.
- Idempotent submission, worker ownership, retries, and terminal-state handling.
- Authorized status/result access and an explicit cancellation protocol.
- Resource limits and result delivery that does not overload the coordinator.
### Follow-up Questions
- What happens when a worker completes after its lease has expired and another worker has retried the query?
- How would you deliver very large results to a reconnecting client?
Overview: Design an asynchronous long-running query service with durable jobs, worker leases, safe retries, cancellation, status tracking, and large-result retrieval.
Design a service that accepts long-running queries without keeping a client request open for the entire execution. Explain submission, execution, progress/status, result retrieval, and failure recovery.
Constraints & Assumptions
The source supplies the long-running-query design topic but no query language, execution engine, duration, or workload figures. Establish those requirements before choosing capacity or isolation policies.
Clarifying Questions to Ask Guidance
Can queries be retried safely, or can they have side effects?
Must clients receive partial results, progress updates, cancellation, or only final results?
What retention and access rules apply to completed results?
What a Strong Answer Covers Guidance
Durable query state and an asynchronous execution queue.
Idempotent submission, worker ownership, retries, and terminal-state handling.
Authorized status/result access and an explicit cancellation protocol.
Resource limits and result delivery that does not overload the coordinator.
Follow-up Questions Guidance
What happens when a worker completes after its lease has expired and another worker has retried the query?
How would you deliver very large results to a reconnecting client?