Skip to content

Database migrations failed for upgrade from 18.1.2 to 18.2.0

Summary

Database migrations failed for upgrade from 18.1.2 to 18.2.0.

Logs show the following migrations started:

  • AddBulkImportConfigurationsOrganizationIdNotNull
  • AddForeignKeyToAiActiveContextCodeEnabledNamespaces
  • AddIncidentManagementPendingAlertEscalationsProjectIdNotNull
  • AddIssuableResourceLinksNamespaceIdNotNull
  • AddSentryIssuesNamespaceIdNotNull
  • CreateAiActiveContextCodeEnabledNamespaces
  • FinalizeBackfillIssueCustomerRelationsContactsNamespaceId

and the following completed:

  • AddBulkImportConfigurationsOrganizationIdNotNull
  • AddIncidentManagementPendingAlertEscalationsProjectIdNotNull
  • AddIssuableResourceLinksNamespaceIdNotNull
  • AddSentryIssuesNamespaceIdNotNull
  • CreateAiActiveContextCodeEnabledNamespaces
  • FinalizeBackfillIssueCustomerRelationsContactsNamespaceId

suggesting that AddForeignKeyToAiActiveContextCodeEnabledNamespaces did not complete.

Using gitlab-rails dbconsole I got the further information

command:

select state, state_change, wait_event_type, query from pg_stat_activity where pid = (SELECT pid FROM pg_locks WHERE locktype = 'advisory');

result:

active | 2025-07-21 10:35:00.354397+00 | Lock | /application:web,db_config_database:gitlabhq_production,db_config_name:main/ C REATE INDEX CONCURRENTLY "index_dts_on_expiring_at_seven_days_notification_sent_at" ON "deploy_tokens" ("expires_at", "id") WHERE revoked = false AND seven_days_notification_sent_at IS NULL

This suggests a different migration from the above.

The related migrations are:

Steps to reproduce

Unable to reproduce in a development environment.

What is the current bug behavior?

Migrations job fails.

What is the expected correct behavior?

Migration job should finish within minutes.

Edited by 🤖 GitLab Bot 🤖