Skip to content

Run database updates before any cache rebuild on TEST/LIVE deploys - #64

Merged
kurowski merged 1 commit into
mainfrom
deploy-updb-before-cache-rebuild
Nov 24, 2026
Merged

kurowski merged 1 commit into
mainfrom
deploy-updb-before-cache-rebuild

Conversation

@kurowski

Copy link
Copy Markdown
Member

Problem

Deploy to TEST for ucdcweb2 failed after a Drupal core upgrade from 11.1.10 to 11.4.11:

terminus drush -- cache-rebuild
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'alias' in 'INSERT INTO'

_pantheon_complete_deployment runs cache-rebuild before drush deploy. Against LIVE's synced database, the new core rebuilt the router before its update hook had added the router.alias column. The deploy then stopped with TEST still in maintenance mode.

1780e49 and f0a549d already handled this, but only for major upgrades. Minor releases change the schema too.

Change

drush deploy already runs updatedb, then config:import, then cache:rebuild, so nothing needs to rebuild caches before it. This PR removes:

  • the cache-rebuild before drush deploy
  • the env:clear-cache before env:deploy, which fails the same way when an earlier deploy stalled with new code on the old schema (the cache clear at the end still runs)
  • _drupal_major_upgrade_pending and the extra updatedb, which only worked around the two calls above

The TEST/LIVE deploy is now: maintenance on → env:deploy → drush deploy → maintenance off → env:clear-cache. The training deploy also calls _pantheon_complete_deployment and gets the same fix.

Testing

Only bash -n has been run so far. To verify: after this image is published, run a normal (sync) Deploy to TEST on ucdcweb2. LIVE is still on 11.1, so this reproduces the original failure and should now pass. Do this before ucdcweb2 deploys to LIVE.

🤖 Generated with Claude Code

Deploying ucdcweb2 to TEST failed after a Drupal core upgrade from 11.1
to 11.4: cache-rebuild ran before drush deploy, so the new core code
rebuilt its router against the live database's old schema and hit
"Unknown column 'alias'". The earlier fix only covered major upgrades,
but minor releases change the schema too.

drush deploy already runs updatedb before config:import and
cache:rebuild, so drop the cache-rebuild in front of it, the pre-deploy
env:clear-cache (which fails the same way after a stalled deploy), and
the major-version detection that only existed to work around them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kurowski
kurowski marked this pull request as draft November 12, 2026 17:32
@kurowski

Copy link
Copy Markdown
Member Author

see comments here https://github.com/UCEAP/.github-private/wiki/Developer-Meeting-Agenda-2026-11-12#deployment-change and think REAL HARD about them before merging

@kurowski

Copy link
Copy Markdown
Member Author

Reviewed the concerns from the 2026-11-12 dev meeting notes against Drush 13.6 / Drupal core 11.4 source:

  • Stale cached config breaking config:import: not an issue. drush deploy runs updatedb → config:import → cache:rebuild → deploy:hook, and updatedb always calls drupal_flush_all_caches() on completion (cache-clear defaults to true), whether or not updates ran. Config import always starts from flushed caches.
  • Discovering code for new modules: updatedb runs under the update kernel. UpdateKernel::initializeContainer() forces a container rebuild from the code on disk and never caches it, so new modules' services and classes are visible to update hooks.
  • Service definition changes in update hooks: same reason, update hooks get the new container. Drush also rebuilds the container in-process between hook_update_N and hook_post_update_NAME. Deploy hooks are still the right place for anything needing the fully booted site.

Remaining difference: discovery/plugin caches aren't flushed before hook_update_N, so an update hook that depends on a new plugin definition could see stale data. That matches core's update.php and Drush's documented deploy sequence, and Drupal's guidance is that hook_update_N shouldn't rely on those APIs. The old order, by contrast, reliably fails whenever a core release adds a schema column (e.g. router.alias in 11.4).

Dropping the env:clear-cache before env:deploy is also fine. It ran against the old code, and the clear at the end still runs.

Next check: a normal (sync) Deploy to TEST on ucdcweb2 once the image publishes. LIVE is still on 11.1, so that run reproduces the original failure.

🤖 Generated with Claude Code

@kurowski
kurowski marked this pull request as ready for review November 24, 2026 20:23
@kurowski
kurowski merged commit cf8854a into main Nov 24, 2026
1 check passed
@kurowski
kurowski deleted the deploy-updb-before-cache-rebuild branch November 24, 2026 20:23
kurowski added a commit that referenced this pull request Nov 24, 2026
The image build looked up the latest atuin and gh release assets through
api.github.com without authentication. Shared CI runners regularly hit its
rate limit, so jq got an error object instead of a release, curl got no URL,
and the build failed (scheduled run 45119517088, and the arm64 leg of
45480383545 after merging #64).

atuin now downloads from releases/latest/download/<asset>, which needs no
API call. gh's asset names include the version, so the version comes from
the releases/latest redirect instead. curl -f makes a bad download fail at
the curl step instead of as a confusing tar error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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