|
| 1 | +# Embedded activity leases |
| 2 | + |
| 3 | +A lease records which attempt owns an activity. It is separate from the activity's |
| 4 | +start-to-close, schedule-to-close and heartbeat timeouts, and from workflow run |
| 5 | +and execution timeouts. |
| 6 | + |
| 7 | +For committed activities on persistent storage, the runtime starts an independent |
| 8 | +PHP metadata process before invoking the activity. The callback stays in its |
| 9 | +original PHP process, with its Laravel services, captured state and connections. |
| 10 | +The helper renews only that original attempt and stops when its owner exits. |
| 11 | +It is joined before the callback outcome is recorded. |
| 12 | + |
| 13 | +The helper uses the original database connection settings, including its TLS and |
| 14 | +authentication configuration. Automatic maintenance needs `proc_open` and an |
| 15 | +available PHP CLI executable. Laravel's existing Symfony executable finder locates the CLI binary |
| 16 | +when the activity is invoked from another PHP SAPI. No activity arguments, |
| 17 | +results or exception payloads are sent to the helper. |
| 18 | + |
| 19 | +SQLite maintenance uses the database's current journal mode. Opening the helper |
| 20 | +does not replay a journal-mode setting that the running application has changed. |
| 21 | + |
| 22 | +If process creation or a PHP CLI binary is unavailable, the callback keeps its |
| 23 | +original captured lease and deadline. Short activities retain their previous |
| 24 | +behavior, but automatic renewal is unavailable and grants no additional time. |
| 25 | + |
| 26 | +Runtime renewal records no heartbeat event and supplies no application progress. |
| 27 | +Activities with a heartbeat timeout must still call `heartbeat()` with genuine |
| 28 | +progress. Renewal cannot extend a recorded business deadline, revive an expired |
| 29 | +grant, transfer the attempt to another worker, or authorize a late result. |
| 30 | +Brief database contention retries only inside the last confirmed grant. Loss of |
| 31 | +authority fences the outcome; it cannot interrupt arbitrary blocking PHP code or |
| 32 | +undo an external side effect. |
| 33 | + |
| 34 | +`DW_V2_ACTIVITY_TASK_LEASE_SECONDS` configures the ownership lease, with a default |
| 35 | +of 300 seconds and valid values from 1 through 86400. Increasing it also increases |
| 36 | +how long recovery may wait after an unannounced worker death. It is not an |
| 37 | +activity execution timeout. Keep the usual worker, repair and timeout processing |
| 38 | +running so expired attempts receive a durable recovery outcome. |
| 39 | + |
| 40 | +In-memory databases, uncommitted outer transactions, mocked activities and a |
| 41 | +frozen application test clock have no independently observable live grant. They |
| 42 | +retain the captured lease without an independent helper. Use persistent storage |
| 43 | +and a real clock when qualifying long-running queue workers. Custom database |
| 44 | +connectors must be available to the fresh metadata process; application-specific |
| 45 | +connector bootstraps are not qualified by the built-in driver tests. |
| 46 | + |
| 47 | +Legacy activity jobs that start after their workflow has completed or failed |
| 48 | +retain the original captured lease and outcome handling. They receive no new |
| 49 | +renewal authority. An activity retained by the runtime's explicit abandon policy |
| 50 | +can renew only within that policy's original recorded deadlines. |
0 commit comments