Skip to content

feat: child run starts that wait for capacity on the account, as apify-orchestrator does - #32

Merged
metalwarrior665 merged 2 commits into
masterfrom
feat/wait-for-capacity
Nov 10, 2026
Merged

metalwarrior665 merged 2 commits into
masterfrom
feat/wait-for-capacity

Conversation

@metalwarrior665

Copy link
Copy Markdown
Member

Actor::call and Actor::start already cover most of what Actors use apify-orchestrator for: named runs (run_name) that are reused across retries, migrations and resurrections, the tracked runs persisted, and runs aborted with the parent. One part was missing: waiting for capacity. The platform refuses a start when the account lacks memory (actor-memory-limit-exceeded) or Actor jobs (concurrent-runs-limit-exceeded), and the orchestrator queues such starts instead of failing.

CallOptions::wait_for_capacity does the same:

  • Starts with the option go one at a time.
  • A refused start is tried again every second once a 10-second cooldown has passed. No other start goes during the cooldown.
  • Once this run is aborting, migrating or exiting, waiting starts fail instead of going out.

A task called without run_name but with the option goes through the start path, so its start can wait.

This lets instagram-rs delete src/utils/initialize_orchestrator.rs (about 550 lines), and the standalone export Actor delete its copy (orchestrator.rs). They would call Actor::call(actor, input, CallOptions { token, run_name, wait_for_capacity: true, abort_with_parent: true, .. }) instead. One difference: the orchestrator keeps its runs AES-encrypted under ORCHESTRATOR-CLIENT-RUNS, and the SDK keeps them under __ACTOR_CHILD_RUNS. A run that migrates across the switch would not find the runs it tracked before.

Tested with unit tests on paused time (child_runs::tests). The two red tests/storage.rs tests are the ones from #28 that also fail on master (see #29).


Generated by Claude Code

…y-orchestrator does

`CallOptions::wait_for_capacity`: the platform refuses a start when the account lacks memory or
Actor jobs. With the option, such starts go one at a time, a refused one is tried again every
second once a 10-second cooldown has passed (during which none goes), and once this run is
aborting, migrating or exiting they fail instead of starting. With `run_name`, the run is tracked
and reused as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S
- The in-process re-open of a deleted alias went through `Services`, which hands back the instance it
  already opened (as `StorageInstanceManager` does in JS), so the backend never resolved it again. Ask
  the backend.
- The replaced declared storage is remembered on the platform, so the off-platform check now asserts the
  mapping is unchanged instead of absent.
- The deleted default dataset is no longer the storage expected to exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S
(cherry picked from commit 519338e)
@metalwarrior665
metalwarrior665 merged commit 7de69e5 into master Nov 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants