Defect #15849

Redmine:Fetch_Changesets Single-inheritance issue in subclass "Repository:Git"

Added by Martin Seener almost 4 years ago. Updated almost 4 years ago.

Status:ClosedStart date:
Priority:HighDue date:
Assignee:-% Done:

0%

Category:SCM
Target version:2.4.3
Resolution:Fixed Affected version:2.4.2

Description

Hi,

today we "migrated" our Redmine Environment from 2.3.1-devel to latest 2.4.2-stable. But we didnt upgrade the old one but instead i made a new installation and linked to it. i copied the files, database.yml and configuration.yml (we have now plugins or themes). then i made the rake generate_secret_token and rake db:migrate RAILS_ENV=production and it indeed did a migration.

Now Redmine runs but i cannot do the fetch_changesets rake task. (Error below!). We`re using Debian Wheezy with RVM 1.17.9 and ruby 1.9.3p362 and i also did a successfuly bundle install. also the user permissions are set as advised.

Redmine itself runs, but not the following task, which worked in the older version:

bundle exec rake redmine:fetch_changesets RAILS_ENV=production

Error:

rake aborted!
The single-table inheritance mechanism failed to locate the subclass: 'Repository::Git'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Repository.inheritance_column to use another column for that information.
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/inheritance.rb:143:in `rescue in find_sti_class'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/inheritance.rb:136:in `find_sti_class'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/inheritance.rb:62:in `instantiate'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/querying.rb:38:in `block (2 levels) in find_by_sql'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/querying.rb:38:in `collect!'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/querying.rb:38:in `block in find_by_sql'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/explain.rb:41:in `logging_query_plan'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/querying.rb:37:in `find_by_sql'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/relation.rb:171:in `exec_queries'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/relation.rb:160:in `block in to_a'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/explain.rb:41:in `logging_query_plan'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/relation.rb:159:in `to_a'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/relation/finder_methods.rb:159:in `all'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/associations/collection_association.rb:382:in `find_target'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/associations/collection_association.rb:335:in `load_target'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/associations/collection_proxy.rb:44:in `load_target'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/associations/collection_proxy.rb:89:in `method_missing'
/var/www/redmine-2.4.2/app/models/repository.rb:330:in `block in fetch_changesets'
/var/www/redmine-2.4.2/app/models/repository.rb:329:in `each'
/var/www/redmine-2.4.2/app/models/repository.rb:329:in `fetch_changesets'
/var/www/redmine-2.4.2/lib/tasks/redmine.rake:47:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => redmine:fetch_changesets
(See full trace by running task with --trace)

Defect15849_db_structure.PNG - db_structure (16.7 KB) Francois Lachance, 2014-01-29 16:04


Related issues

Related to Redmine - Defect #15756: 500 on admin info/settings page on development environment Closed

History

#1 Updated by Christopher Maximov almost 4 years ago

Same here. Redmin 2.4.2 stable using Mercurial repository. Getting this:

The single-table inheritance mechanism failed to locate the subclass: 'Repository::Mercurial'.

Just like in the original post for git.

#2 Updated by Martin Seener almost 4 years ago

Added the same command with --trace:

root@server:/var/www/redmine# RAILS_ENV=production; bundle exec rake redmine:fetch_changesets  --trace
** Invoke redmine:fetch_changesets (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:fetch_changesets
rake aborted!
The single-table inheritance mechanism failed to locate the subclass: 'Repository::Git'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Repository.inheritance_column to use another column for that information.
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/inheritance.rb:143:in `rescue in find_sti_class'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/inheritance.rb:136:in `find_sti_class'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/inheritance.rb:62:in `instantiate'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/querying.rb:38:in `block (2 levels) in find_by_sql'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/querying.rb:38:in `collect!'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/querying.rb:38:in `block in find_by_sql'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/explain.rb:41:in `logging_query_plan'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/querying.rb:37:in `find_by_sql'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/relation.rb:171:in `exec_queries'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/relation.rb:160:in `block in to_a'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/explain.rb:41:in `logging_query_plan'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/relation.rb:159:in `to_a'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/relation/finder_methods.rb:159:in `all'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/associations/collection_association.rb:382:in `find_target'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/associations/collection_association.rb:335:in `load_target'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/associations/collection_proxy.rb:44:in `load_target'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.16/lib/active_record/associations/collection_proxy.rb:89:in `method_missing'
/var/www/redmine-2.4.2/app/models/repository.rb:330:in `block in fetch_changesets'
/var/www/redmine-2.4.2/app/models/repository.rb:329:in `each'
/var/www/redmine-2.4.2/app/models/repository.rb:329:in `fetch_changesets'
/var/www/redmine-2.4.2/lib/tasks/redmine.rake:47:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p362/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => redmine:fetch_changesets

#3 Updated by Martin Seener almost 4 years ago

I tried a bit around with my rails colleague and we found out that we dont know whats going on.

We are easily able to start the rails console and the rake task from within without issues.

bundle exec rails c production

and then the rake task (from the redmine.rake file)
Repository.fetch_changesets

and it goes trough without an error. Thats weird.

Update 5:55pm:

We tried our own Rake Task which is the file foo.rake in lib/tasks with following content:

namespace :foo do
  task :bar => :environment do
    Repository.fetch_changesets
  end
end

and then executed with the following command brings the exakt same error. so it maybe is something wrong with the rake environment??
bundle exec rake foo:bar RAILS_ENV=production

#4 Updated by Martin Seener almost 4 years ago

We tried setting up Redmine 2.4.2 from scratch, added a new DB with own seed data and then only added an existing git repo to a new project. Even then the rake task fails!

But we figured out a workaround which may also work for other SCMs. Our Cronjob now looks like this (we dont use rake anymore):

*/3 8-23 * * * cd /var/www/redmine && echo "Repository.fetch_changesets" | bundle exec rails c production >/dev/null 2>&1

With this, we just pipe the command to fetch the changes directly into the rails console, which works great and does not use rake.

#5 Updated by Francois Lachance almost 4 years ago

Hi there, I got "almost the same problem". First, I'm using SVN instead of GIT.
Then, I decide to try your solution and seem to be working but got this error a little bit down the line:

NoMethodError: undefined method `created_on' for #<Repository::Subversion:0x000000060d2798>
        from /var/lib/gems/1.9.1/gems/activemodel-3.2.16/lib/active_model/attribute_methods.rb:407:in `method_missing'
        from /var/lib/gems/1.9.1/gems/activerecord-3.2.16/lib/active_record/attribute_methods.rb:149:in `method_missing'
        from /var/www/redmine/app/models/changeset.rb:136:in `block (2 levels) in scan_comment_for_issue_ids'
        from /var/www/redmine/app/models/changeset.rb:131:in `each'
        from /var/www/redmine/app/models/changeset.rb:131:in `block in scan_comment_for_issue_ids'
        from /var/www/redmine/app/models/changeset.rb:127:in `scan'
        from /var/www/redmine/app/models/changeset.rb:127:in `scan_comment_for_issue_ids'
        from /var/www/redmine/app/models/changeset.rb:100:in `scan_for_issues'
        from /var/lib/gems/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:432:in `_run__1515758292348163996__create__3917711451105029760__callbacks'
        from /var/lib/gems/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
        from /var/lib/gems/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
        from /var/lib/gems/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
        from /var/lib/gems/1.9.1/gems/activerecord-3.2.16/lib/active_record/callbacks.rb:268:in `create'
        from /var/lib/gems/1.9.1/gems/activerecord-3.2.16/lib/active_record/persistence.rb:348:in `create_or_update'
        from /var/lib/gems/1.9.1/gems/activerecord-3.2.16/lib/active_record/callbacks.rb:264:in `block in create_or_update'
        from /var/lib/gems/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:436:in `_run__1515758292348163996__save__3917711451105029760__callbacks'
... 19 levels...
        from /var/lib/gems/1.9.1/gems/activerecord-3.2.16/lib/active_record/transactions.rb:250:in `transaction'
        from /var/www/redmine/app/models/repository/subversion.rb:71:in `block in fetch_changesets'
        from /var/www/redmine/app/models/repository/subversion.rb:70:in `reverse_each'
        from /var/www/redmine/app/models/repository/subversion.rb:70:in `fetch_changesets'
        from /var/www/redmine/app/models/repository.rb:332:in `block (2 levels) in fetch_changesets'
        from /var/lib/gems/1.9.1/gems/activerecord-3.2.16/lib/active_record/associations/collection_proxy.rb:91:in `each'
        from /var/lib/gems/1.9.1/gems/activerecord-3.2.16/lib/active_record/associations/collection_proxy.rb:91:in `method_missing'
        from /var/www/redmine/app/models/repository.rb:330:in `block in fetch_changesets'
        from /var/www/redmine/app/models/repository.rb:329:in `each'
        from /var/www/redmine/app/models/repository.rb:329:in `fetch_changesets'
        from (irb):1
        from /var/lib/gems/1.9.1/gems/railties-3.2.16/lib/rails/commands/console.rb:47:in `start'
        from /var/lib/gems/1.9.1/gems/railties-3.2.16/lib/rails/commands/console.rb:8:in `start'
        from /var/lib/gems/1.9.1/gems/railties-3.2.16/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

And It is about the same problem when using the repository tab inside Redmine ! Should I open a new ticket ? Someone know why I got a NoMethodError: undefined method `created_on' for #<Repository::Subversion:0x000000060d2798> ?

#6 Updated by Gregor K almost 4 years ago

I have the same problem with SNV, please find a fix for this.

#7 Updated by Daniel Felix almost 4 years ago

Did you run all database migrations? It seems that the column "created_on" is missing.

#8 Updated by Francois Lachance almost 4 years ago

You seem to be right (see attached picture of my DB structure surrounding repository.
However, this is the list of command I ran to update redmine (Debian 7):

  338  mysql -uroot -pxxxxxxxx redmine_default < /mnt/svnbak/redmine_db_latest.sql
  339  history | more
  340  cd ..
  341  rake db:migrate RAILS_ENV=production
  342  ll
  343  history | more
  344  rake redmine:plugins:migrate RAILS_ENV=production
  345  rake db:migrate RAILS_ENV=production
  346  history | more
  347  rake tmp:cache:clear
  348  rake tmp:sessions:clear
  349  service apache2 start

Can you tell me on which table and what is the type of the column "created_on" so I can try to add it manually and try again please;
many thanks
Francois L

#9 Updated by A B almost 4 years ago

It appears that r12389 was the change that broke this. The following patch partially reverts this and fixes the issue for us (note: this is unlikely to be the real fix, as the CommandFailed class definition is now duplicated, which doesn't bother ruby per se but is ugly nevertheless):

--- ./lib/redmine/scm/adapters/abstract_adapter.rb.orig    2014-02-02 00:10:30.391088211 -0800
+++ ./lib/redmine/scm/adapters/abstract_adapter.rb    2014-02-02 00:02:16.051390905 -0800
@@ -24,6 +24,9 @@
 module Redmine
   module Scm
     module Adapters
+      class CommandFailed < StandardError #:nodoc:
+      end
+
       class AbstractAdapter #:nodoc:

         # raised if scm command exited with error, e.g. unknown revision.

#10 Updated by Toshi MARUYAMA almost 4 years ago

  • Related to Defect #15756: 500 on admin info/settings page on development environment added

#11 Updated by Toshi MARUYAMA almost 4 years ago

  • Status changed from New to Closed
  • Target version set to 2.4.3

I have confirmed this error on 2.4.2.
I have confirmed this error was fixed on 2.4-stable by #15756.

#12 Updated by Toshi MARUYAMA almost 4 years ago

  • Resolution set to Fixed

Also available in: Atom PDF