プロジェクト

全般

プロフィール

Vote #63397

完了

Error fetching git changesets

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
SCM_3
対象バージョン:
開始日:
2008/06/10
期日:
進捗率:

0%

予定工数:
category_id:
3
version_id:
2
issue_org_id:
1419
author_id:
1270
assigned_to_id:
0
comments:
10
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

I've been using redmine for a while now, but a few weeks ago the changesets stopped importing from git. When I run @Repository.fetch_changesets@, I get this error:

ActiveRecord::StatementInvalid: Mysql::Error: Column 'changeset_id' cannot be null: INSERT INTO changes (`changeset_id`, `action`, `revision`, `branch`, `from_path`, `from_revision`, `path`) VALUES(NULL, 'M', NULL, NULL, NULL, NULL, 'config/aaf.rb')
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract_adapter.rb:128:in `log'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:243:in `execute'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:253:in `insert'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1811:in `create_without_callbacks'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:254:in `create_without_timestamps'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/timestamp.rb:39:in `create'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1789:in `create_or_update_without_callbacks'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:242:in `create_or_update'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1545:in `save_without_validation'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/validations.rb:752:in `save_without_transactions'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:129:in `save'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/database_statements.rb:59:in `transaction'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:95:in `transaction'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:121:in `transaction'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:129:in `save'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:451:in `create'
    from ./script/../config/../config/../app/models/repository/git.rb:59:in `fetch_changesets'
    from ./script/../config/../config/../app/models/repository/git.rb:58:in `each'
    from ./script/../config/../config/../app/models/repository/git.rb:58:in `fetch_changesets'
    from ./script/../config/../config/../app/models/repository/git.rb:50:in `reverse_each'
    from ./script/../config/../config/../app/models/repository/git.rb:50:in `fetch_changesets'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/database_statements.rb:59:in `transaction'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:95:in `transaction'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:121:in `transaction'
    from ./script/../config/../config/../app/models/repository/git.rb:49:in `fetch_changesets'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/core_ext/symbol.rb:10:in `__send__'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/core_ext/symbol.rb:10:in `to_proc'
    from ./script/../config/../config/../app/models/repository.rb:87:in `each'
    from ./script/../config/../config/../app/models/repository.rb:87:in `fetch_changesets'

journals

Please read [[SubmittingBugs]] and provide the required information.
--------------------------------------------------------------------------------
* MySQL 4.1.20
* Ruby 1.8.6
* Rails 2.0.2
* Redmine r1524
* Git 1.5.3.4
--------------------------------------------------------------------------------
I get the same problem here, it suddenly started to happen today, without notice. It was working perfectly an hour ago and now poof, I get the same exception.

* MySQL 4.1.22
* Ruby 1.8.7 (2008-08-11 patchlevel 72) [powerpc-darwin8]
* Rails 2.0.2
* Redmine r1557
* Git 1.6.0
--------------------------------------------------------------------------------
Still occuring after upgrading to:
* Rails 2.1
* Redmine r1769
--------------------------------------------------------------------------------
I was able to get around this by deleting all the existing Changesets and then re-importing them:

script/runner 'Changeset.destroy_all; Repository.fetch_changesets'

--------------------------------------------------------------------------------
Yes, deleting changesets and re-importing them work, that's what I did too. But the bug can reappear after a while. It did for me yesterday...
--------------------------------------------------------------------------------
Git does not return the commits in chronological order.

So this bug is initiated by the sort order of the _has_many :changesets_ association in the _repository_ model.
This ordering affects the result of _repository#latest_changeset_ which will be given to _git_adapter#revisions_ as the _identifier_from_ parameter. Thus the changesets fetched from git might contain changesets, that have been created in the redmine database before.

The fix we applied is:

<pre>
in repository.rb:

+ has_many :changesets, :dependent => :destroy, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
- has_many :changesets, :dependent => :destroy, :order => "#{Changeset.table_name}.id DESC"
</pre>

And it seems to work fine so far. (No need to delete all changesets and reimport them.)
--------------------------------------------------------------------------------
Another solution to the above problem would be to override _repository#latest_changeset_ within the git.rb, so only git will be influenced by that fix.

<pre>
# in git.rb:
def latest_changeset
changesets.find(:first, :order => "#{Changeset.table_name}.id DESC")
end
</pre>
--------------------------------------------------------------------------------
A quick correction: in #note-7 the '+' and '-' signs of the diff are permuted. It should be
<pre>
- has_many :changesets, :dependent => :destroy, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
+ has_many :changesets, :dependent => :destroy, :order => "#{Changeset.table_name}.id DESC"
</pre>
--------------------------------------------------------------------------------
r1953 should fix this problem. It now checks that the changeset is not in the database before inserting it.
I prefer not to rely on the order in which git returns the changesets.
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリSCM_3 にセット
  • 対象バージョン0.8_2 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0