Error trying to update from 7.12.2 to 7.13.0 migrate gitlab-rails database

A week ago I installed gitlab-ce-7.12.2~omnibus.1-1.x86_64 from the gitlab repository. Today I just tried to update from gitlab-ce-7.13.0-ce.0.el7.x86_64. Then we see the error bellow:

Error executing action `run` on resource 'bash[migrate gitlab-rails database]'

Steps:

  • yum clean all

  • yum check-update

    gitlab-ce.x86_64 7.13.0-ce.0.el7 gitlab_gitlab-c

  • yum update -y
    full log after the error:


    [2015-07-22T09:36:58-03:00] INFO: remote_file[/var/opt/gitlab/gitlab-rails/VERSION] sending run action to bash[migrate gitlab-rails database] (delayed)

    ================================================================================
    Error executing action run on resource 'bash[migrate gitlab-rails database]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20150722-15166-17irst1" ----
    STDOUT: rake aborted!
    StandardError: An error has occurred, this and all later migrations canceled:

    PG::DuplicateColumn: ERROR:  column "session_expire_delay" of relation "application_settings" already exists
    : ALTER TABLE "application_settings" ADD COLUMN "session_expire_delay" integer DEFAULT 10080 NOT NULL/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in async_exec'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in block in execute'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract_adapter.rb:378:in block in log'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activesupport-4.1.11/lib/active_support/notifications/instrumenter.rb:20:in instrument'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract_adapter.rb:372:in log'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in execute'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/schema_statements.rb:375:in add_column'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/schema_statements.rb:398:in add_column'
    /opt/gitlab/embedded/service/gitlab-rails/config/initializers/postgresql_limit_fix.rb:15:in add_column_with_limit_filter'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:656:in block in method_missing'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:628:in block in say_with_time'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:628:in say_with_time'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:648:in method_missing'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20150609141121_add_session_expire_delay_for_application_settings.rb:3:in change'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:602:in exec_migration'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:586:in block (2 levels) in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:585:in block in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in with_connection'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:584:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:759:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:998:in block in execute_migration_in_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:1044:in block in ddl_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in block in transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in within_new_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/transactions.rb:208:in transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:1044:in ddl_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:997:in execute_migration_in_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:959:in block in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:955:in each'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:955:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:814:in up'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:792:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/railties/databases.rake:34:in block (2 levels) in <top (required)>'
    ActiveRecord::StatementInvalid: PG::DuplicateColumn: ERROR:  column "session_expire_delay" of relation "application_settings" already exists
    : ALTER TABLE "application_settings" ADD COLUMN "session_expire_delay" integer DEFAULT 10080 NOT NULL
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in async_exec'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in block in execute'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract_adapter.rb:378:in block in log'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activesupport-4.1.11/lib/active_support/notifications/instrumenter.rb:20:in instrument'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract_adapter.rb:372:in log'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in execute'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/schema_statements.rb:375:in add_column'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/schema_statements.rb:398:in add_column'
    /opt/gitlab/embedded/service/gitlab-rails/config/initializers/postgresql_limit_fix.rb:15:in add_column_with_limit_filter'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:656:in block in method_missing'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:628:in block in say_with_time'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:628:in say_with_time'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:648:in method_missing'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20150609141121_add_session_expire_delay_for_application_settings.rb:3:in change'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:602:in exec_migration'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:586:in block (2 levels) in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:585:in block in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in with_connection'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:584:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:759:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:998:in block in execute_migration_in_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:1044:in block in ddl_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in block in transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in within_new_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/transactions.rb:208:in transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:1044:in ddl_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:997:in execute_migration_in_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:959:in block in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:955:in each'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:955:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:814:in up'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:792:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/railties/databases.rake:34:in block (2 levels) in <top (required)>'
    PG::DuplicateColumn: ERROR:  column "session_expire_delay" of relation "application_settings" already exists
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in async_exec'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in block in execute'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract_adapter.rb:378:in block in log'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activesupport-4.1.11/lib/active_support/notifications/instrumenter.rb:20:in instrument'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract_adapter.rb:372:in log'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in execute'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/schema_statements.rb:375:in add_column'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/postgresql/schema_statements.rb:398:in add_column'
    /opt/gitlab/embedded/service/gitlab-rails/config/initializers/postgresql_limit_fix.rb:15:in add_column_with_limit_filter'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:656:in block in method_missing'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:628:in block in say_with_time'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:628:in say_with_time'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:648:in method_missing'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20150609141121_add_session_expire_delay_for_application_settings.rb:3:in change'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:602:in exec_migration'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:586:in block (2 levels) in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:585:in block in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in with_connection'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:584:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:759:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:998:in block in execute_migration_in_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:1044:in block in ddl_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in block in transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in within_new_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/transactions.rb:208:in transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:1044:in ddl_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:997:in execute_migration_in_transaction'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:959:in block in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:955:in each'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:955:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:814:in up'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:792:in migrate'
    /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.1.11/lib/active_record/railties/databases.rake:34:in block (2 levels) in <top (required)>'
    Tasks: TOP => db:migrate
    (See full trace by running task with --trace)
    == 20141118150935 AddAuditEvent: migrating ====================================
    -- create_table(:audit_events)
       -> 0.1390s
    -- add_index(:audit_events, :author_id)
       -> 0.0042s
    -- add_index(:audit_events, :type)
       -> 0.0050s
    -- add_index(:audit_events, [:entity_id, :entity_type])
       -> 0.0037s
    == 20141118150935 AddAuditEvent: migrated (0.1521s) ===========================

    == 20150609141121 AddSessionExpireDelayForApplicationSettings: migrating ======
    -- add_column(:application_settings, :session_expire_delay, :integer, {:default=>10080, :null=>false})
    STDERR: 
    ---- End output of "bash"  "/tmp/chef-script20150722-15166-17irst1" ----
    Ran "bash"  "/tmp/chef-script20150722-15166-17irst1" returned 1

    Resource Declaration:
    ---------------------
    # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/migrate_database.rb

     19:   bash "migrate #{params[:name]} database" do
     20:     code <<-EOH
     21:       set -e
     22:       log_file="/tmp/#{params[:name]}-db-migrate-$(date +%s)-$$/output.log"
     23:       umask 077
     24:       mkdir $(dirname ${log_file})
     25:       #{params[:command]} 2>& 1 | tee ${log_file}
     26:       exit ${PIPESTATUS[0]}
     27:     EOH
     28:     action params[:action]
     29:   end
     30: end

    Compiled Resource:
    ------------------
    # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/migrate_database.rb:19:in block in from_file'

    bash("migrate gitlab-rails database") do
      params {:command=>"/opt/gitlab/bin/gitlab-rake db:migrate", :action=>:nothing, :name=>"gitlab-rails"}
      action :nothing
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      command "migrate gitlab-rails database"
      backup 5
      returns 0
      code "      set -e\n      log_file=\"/tmp/gitlab-rails-db-migrate-$(date +%s)-$$/output.log\"\n      umask 077\n      mkdir $(dirname ${log_file})\n      /opt/gitlab/bin/gitlab-rake db:migrate 2>& 1 | tee ${log_file}\n      exit ${PIPESTATUS[0]}\n"
      interpreter "bash"
      declared_type :bash
      cookbook_name "gitlab"
      recipe_name "database_migrations"
    end

    [2015-07-22T09:37:20-03:00] INFO: remote_file[/var/opt/gitlab/gitlab-rails/VERSION] sending run action to execute[clear the gitlab-rails cache] (delayed)
    [2015-07-22T09:37:25-03:00] INFO: execute[clear the gitlab-rails cache] ran successfully
    [2015-07-22T09:37:25-03:00] INFO: template[/var/opt/gitlab/gitlab-ci/etc/application.yml] sending run action to execute[clear the gitlab-ci cache] (delayed)
    [2015-07-22T09:37:31-03:00] INFO: execute[clear the gitlab-ci cache] ran successfully
    [2015-07-22T09:37:31-03:00] INFO: remote_file[/var/opt/gitlab/gitlab-ci/VERSION] sending run action to bash[migrate gitlab-ci database] (delayed)
    [2015-07-22T09:37:33-03:00] INFO: bash[migrate gitlab-ci database] ran successfully
    [2015-07-22T09:37:33-03:00] ERROR: Running exception handlers
    [2015-07-22T09:37:33-03:00] ERROR: Exception handlers complete
    [2015-07-22T09:37:33-03:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out
    [2015-07-22T09:37:33-03:00] ERROR: Found 1 errors, they are stored in the backtrace
    [2015-07-22T09:37:35-03:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
    aviso: o scriptlet %posttrans(gitlab-ce-7.13.0-ce.0.el7.x86_64) falhou, status de saída 1
    Non-fatal POSTTRANS scriptlet failure in rpm package gitlab-ce-7.13.0-ce.0.el7.x86_64
      Verifying    : gitlab-ce-7.13.0-ce.0.el7.x86_64                                                    1/2 
      Verifying    : gitlab-ce-7.12.2~omnibus.1-1.x86_64                                                 2/2 

    Updated:
      gitlab-ce.x86_64 0:7.13.0-ce.0.el7                                                                     

    Finished!

What I need to do next?

Thanks in advance.

Hi Adriano, were you able to resolve this? I’m having a very similar issue with 7.12.2

Thanks !

Same here. Any clues?