Defect #2882
closedtrackers doubled
100%
Description
Hello guys,
we used to use 0.7.3 for long time in our company. Suddenly several months ago we found that tracker names are doubled (New Issue). I checked the database contents but it looks like it's correct
mysql> select * from trackers; +----+--------------------+-------------+----------+---------------+ | id | name | is_in_chlog | position | is_in_roadmap | +----+--------------------+-------------+----------+---------------+ | 1 | Chyba | 1 | 1 | 0 | | 2 | Vylepšení | 1 | 2 | 1 | | 3 | Podpora na místě | 1 | 3 | 1 | | 4 | Podpora vzdáleně | 0 | 4 | 1 | | 6 | Reklamace | 1 | 5 | 1 | | 7 | Objednávka | 0 | 6 | 1 | | 8 | Dotaz | 1 | 7 | 1 | +----+--------------------+-------------+----------+---------------+
We didn't care about it much because it's just a small cosmetic issue. I decided to upgrade to 0.8.1 today and the doubled trackers are still on place. Is there any help for me?
Files
Updated by Jean-Philippe Lang almost 16 years ago
Not able to reproduce. Can you attach the html source of the page where it happens please?
Updated by Robert Cerny almost 16 years ago
- File Redmine.html Redmine.html added
Enclosed please find requested data
Updated by Jean-Philippe Lang almost 16 years ago
Maybe you have duplicated rows in your projects_trackers
table (this table stores this association between project and trackers).
Can you check that?
Updated by Robert Cerny almost 16 years ago
mysql> select * from projects_trackers; +------------+------------+ | project_id | tracker_id | +------------+------------+ | 1 | 1 | | 1 | 2 | | 2 | 3 | | 3 | 1 | | 3 | 3 | | 5 | 3 | | 5 | 2 | | 5 | 4 | | 3 | 4 | | 2 | 1 | | 2 | 2 | | 2 | 4 | | 6 | 1 | | 6 | 2 | | 6 | 3 | | 6 | 4 | | 5 | 1 | | 8 | 1 | | 8 | 2 | | 9 | 1 | | 9 | 2 | | 9 | 3 | | 9 | 4 | | 2 | 6 | | 11 | 1 | | 11 | 2 | | 12 | 7 | | 5 | 6 | | 5 | 7 | | 13 | 1 | | 13 | 2 | | 2 | 7 | | 14 | 1 | | 14 | 2 | | 13 | 8 | | 1 | 1 | | 1 | 2 | | 2 | 3 | | 3 | 1 | | 3 | 3 | | 5 | 3 | | 5 | 2 | | 5 | 4 | | 3 | 4 | | 2 | 1 | | 2 | 2 | | 2 | 4 | | 6 | 1 | | 6 | 2 | | 6 | 3 | | 6 | 4 | | 5 | 1 | | 8 | 1 | | 8 | 2 | | 9 | 1 | | 9 | 2 | | 9 | 3 | | 9 | 4 | | 2 | 6 | | 11 | 1 | | 11 | 2 | | 12 | 7 | | 5 | 6 | | 5 | 7 | | 13 | 1 | | 13 | 2 | | 2 | 7 | | 14 | 1 | | 14 | 2 | | 13 | 8 | +------------+------------+ 70 rows in set (0.03 sec)
Updated by Jean-Philippe Lang almost 16 years ago
- Status changed from New to Closed
- Resolution set to Cant reproduce
I was right, all the lines are duplicated. The solution is to manually remove all the duplicates.
I've migrated several database and never faced this problem. And I can't see what could have produced this, so I close this defect. Reopen if you have any idea about the cause of this problem.
Updated by Jean-Philippe Lang almost 16 years ago
- remove duplicates, if any
- add a unique index to avoid this kind of problem
Updated by Eric Davis over 15 years ago
- File 2882-use-uniq-for-habtm.patch 2882-use-uniq-for-habtm.patch added
- Status changed from Closed to Reopened
- Assignee set to Jean-Philippe Lang
- Resolution deleted (
Cant reproduce)
I just got hit by this bug. Somehow my Redmine was trying to insert duplicate Trackers and MySQL threw back an error from this unique index. Since the MySQL error wasn't being caught, it rendered the 500 error page. By I removing the database index and added the :uniq
option to the Projects / Trackers association I was able to prevent this error while still keeping the trackers from duplicating.
Jean-Philippe: Since this patch backs out your change, can you review this patch before I commit it?
Updated by Eric Davis over 15 years ago
Here's the backtrace I got. Redmine version is r2757.
A ActiveRecord::StatementInvalid occurred in projects#add: Mysql::Error: Duplicate entry '85-3' for key 1: INSERT INTO `projects_trackers` (`project_id`, `tracker_id`) VALUES (85, 3) /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log_without_newrelic_instrumentation' ------------------------------- Request: ------------------------------- * URL : https://projects.littlestreamsoftware.com/projects/new * IP address: * Parameters: {"commit"=>"Save", "enabled_modules"=>["issue_tracking", "time_tracking", "files", "budget_module", "customer_module", "schedule_module"], "project"=>{"issue_custom_field_ids"=>[""], "name"=>"removed", "tracker_ids"=>["3", ""], "description"=>"removed", "homepage"=>"", "is_public"=>"0", "identifier"=>"removed", "parent_id"=>"54", "custom_field_values"=>{"6"=>"Prospecting", "2"=>"0", "3"=>"", "4"=>""}}, "action"=>"add", "controller"=>"projects"} * Rails root: /home/websites/projects.littlestreamsoftware.com/releases/20090517194548 ------------------------------- Backtrace: ------------------------------- /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log_without_newrelic_instrumentation' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb:54:in `log_with_capture_sql' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb:37:in `log_without_trace_Database___adapter_name____args_1__' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:41:in `trace_method_execution_with_scope' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb:36:in `log_without_trace_Database___adapter_name____args_1__' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:138:in `log_without_trace_Database_all' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:41:in `trace_method_execution_with_scope' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:137:in `log_without_trace_Database_all' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:141:in `log' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:309:in `execute' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:171:in `insert_sql' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:319:in `insert_sql' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:44:in `insert_without_query_dirty' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:18:in `insert' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/has_and_belongs_to_many_association.rb:56:in `insert_record' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:145:in `send' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:145:in `send' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations.rb:1391:in `after_create_or_update_associated_records_for_trackers' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:359:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `each' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `send' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:359:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations.rb:1391:in `after_create_or_update_associated_records_for_trackers' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `send' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `evaluate_method' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:166:in `call' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:93:in `run' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:92:in `each' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:92:in `send' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:92:in `run' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:277:in `run_callbacks' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/callbacks.rb:315:in `callback' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/callbacks.rb:238:in `create_without_timestamps' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/timestamp.rb:29:in `create' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2699:in `create_or_update_without_callbacks' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/callbacks.rb:222:in `create_or_update' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2383:in `save_without_validation' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/validations.rb:1009:in `save_without_dirty' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/dirty.rb:79:in `save_without_transactions' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:179:in `send' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:179:in `with_transaction_returning_status' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:129:in `transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:138:in `transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:178:in `with_transaction_returning_status' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:146:in `save_without_trace_ActiveRecord___self_class_name__save' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:158:in `rollback_active_record_state!' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:146:in `save_without_trace_ActiveRecord___self_class_name__save' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:138:in `save_without_trace_ActiveRecord_save' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:41:in `trace_method_execution_with_scope' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:137:in `save_without_trace_ActiveRecord_save' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:141:in `save_without_trace_ActiveRecord_all' [RAILS_ROOT]/vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:141:in `save' [RAILS_ROOT]/app/controllers/projects_controller.rb:77:in `add'
Updated by Jean-Philippe Lang over 15 years ago
Eric, I don't think removing the unique index and ignoring duplicates is the right solution.
I'd really prefer this defect to be fixed instead, if it is confirmed.
Did you get this error with any plugin installed (see #3368)?
Updated by Eric Davis over 15 years ago
- Status changed from Reopened to Closed
- % Done changed from 0 to 100
- Resolution set to Cant reproduce
Jean-Philippe Lang wrote:
Did you get this error with any plugin installed (see #3368)?
You're right. I thought I was testing with a clean Redmine install earlier (fresh database, no plugins, from trunk) but I must have had something else loaded. When I installed the Stuff To Do plugin (like in #3368), I was able to reproduce the error. It looks like the require 'project'
in the plugin was the cause. Why a require
caused a MySQL error, I do not know....
Sorry for the noise and thank you for reviewing the patch.