プロジェクト

全般

プロフィール

Vote #73646

未完了

ActiveRecord::RecordNotUnique for git repository

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

ステータス:
New
優先度:
低め
担当者:
-
カテゴリ:
SCM_3
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
3
version_id:
0
issue_org_id:
13592
author_id:
75235
assigned_to_id:
0
comments:
7
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
68
ステータス-->[New]

説明

I've installed Redmine and linked it to a git repository that's been running development for a very long time (heavy, active development for about a year). Upon trying to load the Repository tab for the project I get an error. Here's the relevant section of the log:

Started GET "/redmine/projects//repository" for 173.164.56.105 at 2013-03-25 16:22:29 -0600
Processing by RepositoriesController#show as HTML
Parameters: {"id"=>"fredchat"}
Current user: admin (id=1)
Completed 500 Internal Server Error in 912ms

ActiveRecord::RecordNotUnique (Mysql2::Error: Duplicate entry '1-2a5b30caa8969dded7f57c9cda5f914ea88ea29f' for key 'changesets_repos_rev': INSERT INTO changesets (comments, commit_date, committed_on, committer, repository_id, revision, scmid, user_id) VALUES ('Merge branch \'autoupdate\' of into autoupdate', '2012-09-14 12:08:21', '2012-09-14 12:08:21', 'My Name myemail@myemail.com', 1, '2a5b30caa8969dded7f57c9cda5f914ea88ea29f', '2a5b30caa8969dded7f57c9cda5f914ea88ea29f', 4)):
app/models/repository/git.rb:222:in save_revision'
app/models/repository/git.rb:211:in
block (2 levels) in save_revisions'
app/models/repository/git.rb:208:in block in save_revisions'
app/models/repository/git.rb:207:in
each'
app/models/repository/git.rb:207:in save_revisions'
app/models/repository/git.rb:154:in
fetch_changesets'
app/controllers/repositories_controller.rb:114:in `show'


journals

I've attached a patch that fixes this issue by prepending underscores to non-unique commit SHA-1s in a before_create handler
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
You're not supposed to have a duplicate SHA-1, do you know why you have this?
--------------------------------------------------------------------------------
SHA-1 is collision-resistant, but mathematically speaking there's no way it can be collision proof. In especially large datasets it's entirely possible for two checksums to be the same-look up the birthday problem.
--------------------------------------------------------------------------------
Scratch that, it actually looks like it's trying to overwrite the same revisions, so somewhere the check to see if a revision has already been inserted is failing.
--------------------------------------------------------------------------------
Are these really the same hash values?

It is very rare case on Mercurial *valid* repository.
http://mercurial.selenic.com/wiki/FAQ/TechnicalDetails

Redmine checks hash before inserting database.
source:tags/2.3.0/app/models/repository/git.rb#L167

So, "Not Unique" error does not happen on *single process*.
But, it happens on *multi processe*.
In this case, you can ignore it.
See #13086.
--------------------------------------------------------------------------------
I just ran into this issue. I fixed it by truncating the three 'changesets' tables in the redmine DB.

It can be caused by refreshing or making two requests to a new repository from redmine at once. The two requests run in parallel and cause each other to collide. Any attempt made after this occurs to access the repo fails as Redmine tries to insert everything anew rather than update the data in the database, causing more collisions.

Definately something that needs to be dealt with in the redmine code. I've learnt my lesson, but this could cause major issues with a busy redmine server.
--------------------------------------------------------------------------------


related_issues

relates,Needs feedback,13086,"Mysql::Error: Duplicate entry" in fetching revisions
relates,New,2824,MySQL Deadlock Error when showing a big repository

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

  • カテゴリSCM_3 にセット

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

いいね!0
いいね!0