Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #10123

Closed
Open
Created Apr 07, 2016 by Administrator@rootOwner

Migration 20130403003950 fails

Created by: elyulka

Summary

gitlab/gitlab-ce:latest docker image using empty external postgresql fails during initialization

Steps to reproduce

  1. Setup empty postgresql database and allow access by user git and password git.

My docker-compose.yml

web:
  image: 'gitlab/gitlab-ce:latest'                                                                                                                         restart: always
  hostname: '192.168.1.102'
  environment:                                                                                                                                               GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://192.168.1.102:8005'
      postgresql['enable'] = false
      gitlab_rails['db_username'] = 'git'
      gitlab_rails['db_host'] = '192.168.1.3'
      gitlab_rails['db_password'] = 'git'
  ports:
    - '8005:80'
    - '443:443'
    - '8022:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'
  1. Run:
docker-compose up
  1. See error

Expected behavior

Started&working gitlab.

Relevant logs and/or screenshots

docker-compose output:

web_1 | ================================================================================
web_1 | Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
web_1 | ================================================================================
web_1 |
web_1 | Mixlib::ShellOut::ShellCommandFailed
web_1 | ------------------------------------
web_1 | Expected process to exit with [0], but received '1'
web_1 | ---- Begin output of "bash"  "/tmp/chef-script20160407-27-v42kkx" ----
web_1 | STDOUT: rake aborted!
web_1 | StandardError: An error has occurred, this and all later migrations canceled:
web_1 |
web_1 | PG::UndefinedColumn: ERROR:  column projects.pending_delete does not exist
web_1 | LINE 1: SELECT  "projects".* FROM "projects" WHERE "projects"."pendi...
web_1 |                                                    ^
web_1 | : SELECT  "projects".* FROM "projects" WHERE "projects"."pending_delete" = 'f'  ORDER BY "projects"."id" ASC LIMIT 1000/opt/gitlab/embedded/servi
c
...
web_1 | ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column projects.pending_delete does not exist
web_1 | LINE 1: SELECT  "projects".* FROM "projects" WHERE "projects"."pendi...
web_1 |                                                    ^
web_1 | : SELECT  "projects".* FROM "projects" WHERE "projects"."pending_delete" = 'f'  ORDER BY "projects"."id" ASC LIMIT 1000
...
web_1 | Tasks: TOP => db:migrate
web_1 | (See full trace by running task with --trace)
web_1 | == 20130403003950 AddLastActivityColumnIntoProject: migrating =================
web_1 | -- add_column(:projects, :last_activity_at, :datetime)
web_1 |    -> 0.0019s
web_1 | -- add_index(:projects, :last_activity_at)
web_1 |    -> 0.0103s
web_1 | STDERR:
web_1 | ---- End output of "bash"  "/tmp/chef-script20160407-27-v42kkx" ----
web_1 | Ran "bash"  "/tmp/chef-script20160407-27-v42kkx" returned 1
...
web_1 | /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activerecord-4.2.5.2/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (
required)>'
web_1 | Tasks: TOP => db:migrate
web_1 | (See full trace by running task with --trace)
web_1 | == 20130403003950 AddLastActivityColumnIntoProject: migrating =================
web_1 | -- add_column(:projects, :last_activity_at, :datetime)
web_1 |    -> 0.0019s
web_1 | -- add_index(:projects, :last_activity_at)
web_1 |    -> 0.0103s
web_1 | STDERR:                                                                                                                                 [26/1862]
web_1 | ---- End output of "bash"  "/tmp/chef-script20160407-27-v42kkx" ----
web_1 | Ran "bash"  "/tmp/chef-script20160407-27-v42kkx" returned 1
web_1 |
web_1 | Resource Declaration:
web_1 | ---------------------
web_1 | # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb
web_1 |
web_1 |  41: bash "migrate gitlab-rails database" do
web_1 |  42:   code <<-EOH
web_1 |  43:     set -e
web_1 |  44:     log_file="/tmp/gitlab-rails-db-migrate-$(date +%s)-$$/output.log"
web_1 |  45:     umask 077
web_1 |  46:     mkdir $(dirname ${log_file})
web_1 |  47:     /opt/gitlab/bin/gitlab-rake db:migrate 2>& 1 | tee ${log_file}
web_1 |  48:     STATUS=${PIPESTATUS[0]}
web_1 |  49:     echo $STATUS > #{db_migrate_status_file}
web_1 |  50:     exit $STATUS
web_1 |  51:   EOH
web_1 |  52:   notifies :run, 'execute[enable pg_trgm extension]', :before unless OmnibusHelper.not_listening?("postgresql") || !node['gitlab']['postgres
ql']['enable']
web_1 |  53:   notifies :run, "execute[clear the gitlab-rails cache]", :immediately unless OmnibusHelper.not_listening?("redis")
web_1 |  54:   dependent_services.each do |svc|
web_1 |  55:     notifies :restart, svc, :immediately
web_1 |  56:   end
web_1 |  57:   not_if "(test -f #{db_migrate_status_file}) && (cat #{db_migrate_status_file} | grep -Fx 0)"
web_1 |  58: end
web_1 |

web_1 | Compiled Resource:
web_1 | ------------------
web_1 | # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb:41:in `from_file'
web_1 |
web_1 | bash("migrate gitlab-rails database") do
web_1 |   action [:run]
web_1 |   retries 0
web_1 |   retry_delay 2
web_1 |   default_guard_interpreter :default
web_1 |   command "migrate gitlab-rails database"
web_1 |   backup 5
web_1 |   returns 0
web_1 |   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    STATUS=${PIPESTATUS[0]}\n    echo $STATUS > /var/opt/gitlab/gitlab-rails/upgrade-sta
tus/db-migrate-265f796\n    exit $STATUS\n"
web_1 |   interpreter "bash"
web_1 |   declared_type :bash
web_1 |   cookbook_name "gitlab"
web_1 |   recipe_name "database_migrations"
web_1 |   not_if "(test -f /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-265f796) && (cat /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate
-265f796 | grep -Fx 0)"
web_1 | end
web_1 |
web_1 | gitlab_web_1 exited with code 0

Output of checks

Results of GitLab Application Check

Can not run

sudo gitlab-rake gitlab:check SANITIZE=true

Container exits too fast.

Results of GitLab Environment Info

Can not run

sudo gitlab-rake gitlab:env:info

Container exits too fast.

Possible fixes

Migration 20130403003950_add_last_activity_column_into_project.rb fails during startup. As i see from its code:

Project.find_each do |project|
      last_activity_date = if project.last_activity
                             project.last_activity.created_at
                           else
                             project.updated_at
                           end

      project.update_attribute(:last_activity_at, last_activity_date)
    end

Migration uses latest Project model to update data of the old schema. But latest Project has new field pending_delete added in the 20160122185421_add_pending_delete_to_project.rb migration.

Migrations must use pure sql queries to update data to avoid such problems.

Assignee
Assign to
Time tracking