Jobs & schedulers

Async work and reconciliation

Last verified 8 August 2026 · source-backed

Mivama uses three asynchronous mechanisms: Frappe background jobs, external pull workers and scheduled reconciliation. They solve different failure modes.

Job types

Root workers pull work instead of receiving arbitrary commands from web requests. A claimed job has owner, timestamps and heartbeat. Stale claims can be recovered according to the worker policy; duplicate concurrent execution is prevented with service/workspace locks.

Frappe schedule

Configured in mivama_core/hooks.py:

CadenceFunctionWhy
Dailyreconcile_portal_stripe_subscriptionsRepair webhook gaps against Stripe truth
Dailyclear_old_portal_notificationsBound notification storage
Dailyreconcile_hosting_subscriptionsRepair lifecycle drift
Hourlyretry_pending_portal_stripe_eventsReprocess failed/deferred events
Hourlyexpire_stale_migrationsRevoke stale transfer capabilities
Hourlyprocess_hosting_cancellationsAdvance backup, suspend, retention and delete

Immediate hooks still run; schedulers are the safety net, not the primary user feedback loop.

Idempotency

External IDs deduplicate Stripe events/invoices/subscriptions. Desired-state generation and hash prevent stale host apply. Migration commands require legal state transitions. Studio job/state checks reject incompatible actions. Retried work must either converge safely or return the existing completed result.

Monitoring signals

  • queue depth and oldest queued age;
  • active claim heartbeat age;
  • repeated job retries for one service;
  • Stripe events not Processed;
  • migrations in importing/final sync beyond expected duration;
  • Studio workspaces stuck in provisioning, deploying or rollback;
  • cancellation records past their next-action timestamp;
  • failed email queue entries for essential messages.

Alerts should include stable service/job/migration/workspace IDs, never credentials or raw customer data.