Remove the IS_DEFERRED_WORKSPACE_MIGRATION_ACTIONS_ENABLED feature flag

Merged
CH
1mo ago
+594-293

Follow-up to #29066. Removes IS_DEFERRED_WORKSPACE_MIGRATION_ACTIONS_ENABLED: deferred workspace migration actions are now the default everywhere, and callers that need the old inline behaviour pass shouldDeferActions: false (the standard app sync and the dev seeder already do, since #29066).

The flag has been on for every workspace in prod-eu since 2026-10-28. Before that, 347 workspaces had it from 2026-10-19: about 1,400 actions ran, all on the first attempt, with no stale resets and no invalid indexes or unvalidated foreign keys left behind.

What changes

  • WorkspaceMigrationRunnerService no longer reads the flag: it defers whenever shouldDeferActions is true (the default), and the in-flight schema guard always applies, unchanged.
  • Upgrade workspace commands never defer: every validateBuildAndRun* and runner call in upgrade-version-command/ passes shouldDeferActions: false, as do the service calls they make (createManyFields, deleteOneObject, and upgradeApplication in 2-23, threaded down to the manifest sync). When shouldDeferActions is false, the runner builds indexes and validates FKs inline and skips the in-flight guard, so these callers never read core.deferredWorkspaceMigrationAction. Self-hosted upgrades run before the worker starts, and cross-version upgrades run older commands before that table exists (pre-2.42) or has its current columns (2.42 to 2.43). Editing previous-version command directories needs the ci:allow-previous-version-upgrade-mutation label.
  • Deferred handlers skip targets that no longer exist instead of failing. delete_logicFunctionResources treats FILE_NOT_FOUND as done, which covers functions whose application was uninstalled (it used to fail 3 times with "Application not found"). validate_foreignKey returns when the field's object or its relation target has been deleted. Because the runner processes a workspace's actions in order and stops at the first failure, those failures used to hold every queued index build and FK validation behind them, so the in-flight guard rejected the workspace's schema changes until retries ran out.
  • The flag key, its admin panel entry and the generated GraphQL enums are removed. Leftover featureFlag rows are harmless: Workspace.featureFlags filters unknown keys.

Tests

Integration tests now always go through the deferred path, so a test that chains schema changes would hit the in-flight guard while the previous change's index builds or FK validations are still queued. The new waitForDeferredWorkspaceMigrationActionsOrThrow() util polls core.deferredWorkspaceMigrationAction until nothing is pending or in progress, and throws right away with lastError if a queued action already failed once. It only looks at build_index and validate_foreignKey, the actions the guard blocks on, and sleeps through node:timers/promises with an attempt cap because some suites enable jest fake timers in their setup. It runs before every schema-changing test helper (object and field create, update and delete), after the REST suites' createTestObjectViaGraphql / createTestFieldViaGraphql, before the direct createManyFields in setupTestObjectsWithAllFieldTypes, and before each MCP metadata tool call. Upgrade specs that call a command's runOnWorkspace directly wait for queued actions first. The guard itself is unchanged.

Behaviour change

  • Through the API, deleting a workflow, discarding a draft, uninstalling an app or removing workflows from an app manifest now deletes workflow runs asynchronously. The workflow deletion cleanup and application workflow removal integration tests wait for that with expectEventually, and the separate "persisted cleanup" test is folded into the main deletion test.

Tested locally

  • workspace:seed:dev with no worker running: completes, no deferred action is queued, all 307 index metadata rows have a valid index and every foreign key is validated.
  • createOneObject through the API with no worker: 5 build_index and 5 validate_foreignKey actions are queued and a second schema change gets the 409. Once the worker starts it drains all 10 in about 6s, each under 200ms, and the same change then goes through.
  • Upgrade path, through the real command app context with core.deferredWorkspaceMigrationAction renamed away to mimic a pre-2.42 instance: two consecutive commands passing shouldDeferActions: false (create an object, then add a many-to-one relation on it) both succeed, and every foreign key is validated and every index built. With the table restored, the same kind of migration without the flag queues its actions as usual.
  • Integration suites deferred-workspace-migration-actions, workflow-deletion-cleanup and the 38 object and field metadata suites pass (run with an earlier version of this branch that also waited in the guard).