Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

database initialization problem when using different docker tags? #1639

Closed
branzo opened this issue Jan 30, 2018 · 3 comments
Closed

database initialization problem when using different docker tags? #1639

branzo opened this issue Jan 30, 2018 · 3 comments
Labels

Comments

@branzo
Copy link

branzo commented Jan 30, 2018

Following the request from @mssola to open a new issue regarding the problems with the db when upgrading portus described in #1620 , i tried to reproduce the problem and i got it, these are the steps:

  1. cleared all previously downloaded tags (just to make sure everything is clean)
  2. pulled 2.3 tag (image: opensuse/portus 2.3 d47008369714 17 hours ago)
  3. spinned up a stack using the 2.3 tag for portus and background services, version
  4. populated the db with some teams, namespaces and pushed a few test images
  5. stopped the whole stack with docker-compose down (persistent volumes)
  6. cleared images
  7. pulled head tag (image: opensuse/portus head 42b0d1ac54c0 17 hours ago)
  8. spinned up the same stack using head tag
  9. got the problem when portus tries to initialize database

it seems that the issue does not occur if you repeat steps using the same image, i'm not sure if we should try with different images version of the same tag (i.e. with the next update of head?).

Notes:
2.3 version was 2.3.0@6c27eb83e3b23b12ce62d39e6823ec8cf5747921.
head version was 2.4.0-dev@46ae80aeed17075974988de5a88a75fd9d4ebb53.

@mssola mssola added the bug label Apr 11, 2018
@mssola mssola added this to the Release 2.4 milestone Apr 11, 2018
@fentas
Copy link

fentas commented May 28, 2018

Same problem here, but i did not use head only 2.3.
Got stuck here after pulling latest 2.3 version.

@djvl
Copy link

djvl commented Aug 22, 2018

Today I tried to update an older opensuse/portus:head image (0bf3113a7bed) to 2.3 (5fd3f2196938) and it fails on the exact same issue:

portus_1      | Initializing database                                                                                                                                                                                                                                          
portus_1      | portus_production already exists                                                                                                                                                                                                                               
portus_1      | -- create_table("activities", {:force=>:cascade})                                                                                                                                                                                                              
portus_1      |    -> 0.0213s                                                                                                                                                                                                                                                  
portus_1      | -- add_index("activities", ["key"], {:name=>"index_activities_on_key", :using=>:btree})                                                                                                                                                                        
portus_1      |    -> 0.0067s                                                                                                                                                                                                                                                  
portus_1      | -- add_index("activities", ["owner_id", "owner_type"], {:name=>"index_activities_on_owner_id_and_owner_type", :using=>:btree})                                                                                                                                 
portus_1      |    -> 0.0069s                                                                                                                                                                                                                                                  
portus_1      | -- add_index("activities", ["recipient_id", "recipient_type"], {:name=>"index_activities_on_recipient_id_and_recipient_type", :using=>:btree})                                                                                                                 
portus_1      |    -> 0.0072s                                                                                                                                                                                                                                                  
portus_1      | -- add_index("activities", ["trackable_id", "trackable_type"], {:name=>"index_activities_on_trackable_id_and_trackable_type", :using=>:btree})                                                                                                                 
portus_1      |    -> 0.0071s                                                                                                                                                                                                                                                  
portus_1      | -- add_index("activities", ["trackable_type"], {:name=>"index_activities_on_trackable_type", :using=>:btree})                                                                                                                                                  
portus_1      |    -> 0.0073s                                                                                                                                                                                                                                                  
portus_1      | -- create_table("application_tokens", {:force=>:cascade})                                                                                                                                                                                                      
portus_1      |    -> 0.0205s                                                                                                                                                                                                                                                  
portus_1      | -- add_index("application_tokens", ["user_id"], {:name=>"index_application_tokens_on_user_id", :using=>:btree})                                                                                                                                                
portus_1      |    -> 0.0064s                                                                                                                                                                                                                                                  
portus_1      | -- create_table("comments", {:force=>:cascade})                                                                                                                                                                                                                
portus_1      |    -> 0.0190s                                                                                                                                                                                                                                                  
portus_1      | -- add_index("comments", ["repository_id"], {:name=>"index_comments_on_repository_id", :using=>:btree})                                                                                                                                                        
portus_1      |    -> 0.0066s                                                                                                                                                                                                                                                  
portus_1      | -- add_index("comments", ["user_id"], {:name=>"index_comments_on_user_id", :using=>:btree})                                                                                                                                                                    
portus_1      |    -> 0.0071s                                                                                                                                                                                                                                                  
portus_1      | -- create_table("namespaces", {:force=>:cascade})                                                                                                                                                                                                              
portus_1      | rake aborted!                                                                                                                                                                                                                                                  
portus_1      | ActiveRecord::StatementInvalid: Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails: DROP TABLE `namespaces` CASCADE

mssola added a commit to mssola/Portus that referenced this issue Sep 18, 2018
This task should be used when setting up the database instead of the
usual combination. This handles databases with pending migrations, new
databases, etc.

See SUSE#1639
See SUSE#1712

Signed-off-by: Miquel Sabaté Solà <[email protected]>
mssola added a commit to openSUSE/docker-containers that referenced this issue Sep 18, 2018
The commit 914cc9ebfdee7b22ee934e6cc4bac0bfd6dfa9fd of Portus introduced
the `portus:db:configure` task, which is a replacement for `db:setup` in
containerized environments.

See SUSE/Portus#1639
See SUSE/Portus#1712

Signed-off-by: Miquel Sabaté Solà <[email protected]>
@mssola
Copy link
Collaborator

mssola commented Sep 18, 2018

This has been finally fixed with #1970 and openSUSE/docker-containers@293e289. The head image will contain the fix once it's done building.

Thanks everyone for the feedback 👏

@mssola mssola closed this as completed Sep 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants