Skip to content

[apscheduler] make the managed job store immutable at runtime - #287

Open
ricardo-agz wants to merge 1 commit into
mainfrom
ricardo/aps-declared-only-jobs
Open

[apscheduler] make the managed job store immutable at runtime#287
ricardo-agz wants to merge 1 commit into
mainfrom
ricardo/aps-declared-only-jobs

Conversation

@ricardo-agz

@ricardo-agz ricardo-agz commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Rejects runtime job creation and mutation on the managed store

Rationale:

Runtime cache is not durable enough / expose the api needed to reliably implement dynamic job creation / mutation

Eviction would mean a runtime-added job would get dropped, or a modified job would silently revert back to it's original config, we should enable this later once our store can offer those durability guarantees

scheduler.pause_job("cleanup")
# APSchedulerConfigurationError: cannot update job "cleanup" at runtime:
# the managed job store is immutable at runtime; change the declaration
# and deploy, or gate the job's work with state your application owns

The gate lives in the coordinator, not the patched scheduler methods, so in-wake self-mutations (which bypass the wrappers in queue-serving runtimes) are covered by the same check.

With runtime writes gone, every record is a declaration plus progress, so the provenance concept (declared vs runtime records) is meaningless and this PR deletes it outright — nothing has shipped, so there is no legacy state to respect.

Deliberately unchanged

  • Declaration-time add_job() and scheduled_job() (that is how declared jobs exist).
  • Execution progress writes (cas_update/cas_remove from the wake path) and reconciliation.
  • Scheduler-level start()/pause()/resume() — documented as operational control; pause() is not a kill switch.

A future durable backend can lift the restriction behind the same Backend protocol without an API change.

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vercel-py Ready Ready Preview Aug 12, 2026 2:20am

Request Review

@ricardo-agz
ricardo-agz marked this pull request as draft August 12, 2026 00:38
@ricardo-agz
ricardo-agz force-pushed the ricardo/aps-declared-only-jobs branch from 30f6230 to b4d8872 Compare August 12, 2026 01:24
@ricardo-agz ricardo-agz changed the title [apscheduler] restrict the managed job store to declared jobs [apscheduler] make the managed job store immutable at runtime Aug 12, 2026
@ricardo-agz
ricardo-agz force-pushed the ricardo/aps-declared-only-jobs branch from b4d8872 to fc6c0b8 Compare August 12, 2026 02:04
@ricardo-agz
ricardo-agz force-pushed the ricardo/aps-declared-only-jobs branch from fc6c0b8 to 49461d8 Compare August 12, 2026 02:15
@ricardo-agz
ricardo-agz force-pushed the ricardo/aps-declared-only-jobs branch from 49461d8 to d1c9e2f Compare August 12, 2026 02:20
@ricardo-agz
ricardo-agz marked this pull request as ready for review August 12, 2026 02:55
@ricardo-agz
ricardo-agz requested a review from nsidnev August 12, 2026 02:55
@ricardo-agz
ricardo-agz force-pushed the ricardo/aps-declared-only-jobs branch from d1c9e2f to 11b28c7 Compare August 13, 2026 21:58
Base automatically changed from ricardo/aps-consolidate-stores to main August 13, 2026 22:33
Runtime and in-wake job creation and mutation now raise: an
evictable, per-region cache cannot durably hold state that only
exists at runtime, and a silently lost pause or removal resurrects
work an operator stopped. The store holds code-declared jobs plus
execution progress, all reconstructable from code and the in-flight
messages.

Jobs change by deploying changed declarations; a job that must not
run is stopped by removing or gating its declaration, or by a flag
in application-owned storage. Dynamic schedules belong in an
application-owned database; one-shot work in a delayed queue
message. A future durable backend can lift the restriction behind
the same Backend protocol without an API change.
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.

1 participant