kubitron / redmine_git_hosting

A ChiliProject/Redmine plugin which makes configuring your own git hosting easy.
78 stars 15 forks source link

Fetch_changesets broken for initial push of existing repository #23

Closed Lncn closed 12 years ago

Lncn commented 12 years ago

So my coworker was attempting to create a new project Redmine and push a rather large Git repo to create the repository in Gitolite. Everything on the gitolite end was successful. The problem is, when we try and view the changesets in the repository tab, we get a 500 internal error. If you remember, this is the same issue I saw with ericpaulbishop's plugin and you recommended I try your version:

Processing RepositoriesController#show (for 10.0.13.126 at 2012-03-09 14:10:21) [GET]
Parameters: {"action"=>"show", "id"=>"flashcard-pyrt", "controller"=>"repositories"}
ActiveRecord::StatementInvalid (Mysql::Error: MySQL server has gone away: INSERT INTO `git_caches` (`command_output`, `created_at`, `command`, `proj_identifier`, `updated_at`) VALUES(x'636f6d6d6974203762366662643...<MANY MBs OF ASCII!!!!>...645f707972740a', '2012-03-09 14:10:25', '\'/var/www/redmine/vendor/plugins/redmine_git_hosting/bin/run_git_as_git_user\' \'--git-dir\' \'repositories/flashcard-pyrt.git\' \'-c\' \'core.quotepath=false\' \'-c\' \'log.decorate=no\' \'log\' \'--no-color\' \'--encoding=UTF-8\' \'--raw\' \'--date=iso\' \'- pretty=fuller\' \'--parents\' \'--reverse\' \'master\'', 'flashcard-pyrt', '2012-03-09 14:10:25')):
 lib/redmine/scm/adapters/git_adapter.rb:203:in `revisions'
 app/models/repository/git.rb:152:in `fetch_changesets_without_disable_update'
 app/models/repository/git.rb:147:in `each'
 app/models/repository/git.rb:147:in `fetch_changesets_without_disable_update'
 app/controllers/repositories_controller.rb:92:in `show_without_git_instructions'
 passenger (3.0.11) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
 passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
 passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
 passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
 passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
 passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
 passenger (3.0.11) lib/phusion_passenger/utils.rb:479:in `safe_fork'
 passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
 passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
 passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
 passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
 passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:180:in `start'
 passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
 passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
 passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
 passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
 passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
 passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
 passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
 passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
 passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
 passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
 passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
 passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
 passenger (3.0.11) helper-scripts/passenger-spawn-server:99

 Rendering /var/www/redmine/public/500.html (500 Internal Server Error)

This points me to a problem with pushing the logs to into the cache... As you can see i grabbed the command output line, but striped out most of the ASCII. I think this particular one was like 6MB long and bloats the hell out of my production.log. I tried playing with the cache parameters in the plugin's configure settings, and the other thing that made a difference was setting the max MB cached to 2, and the repositories tab opens, but it has zero revisions and you can see diffs, etc...

I see that it says "MySQL server has gone away". Is it possible there is a timeout on MySQL inserts or something? I know little about that.

kubitron commented 12 years ago

Hello. I suspect that the problem is that your MySQL hasn't been told to allow large updates. You probably need to set the "max_allowed_packet" option in your /etc/my.cnf file.

I have the following (notice, in particular, the "max_allowed_packet"):

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
max_allowed_packet=32M

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

I have my max MB set to 16MB in the actual cache settings. (probably can go up to 32MB, given my configuration, but haven't actually tried it).

Lncn commented 12 years ago

Oh nice! This sounds like exactly what I need. I won't be able to try this until Monday. I'll let you know how it goes.

Speaking of the cache settings, how exactly does the plugin expect those to be set up? Should the Max in the plugin config settings just match the max in the mySQL config? That seems most logical. Maybe we should note this in the plugin's README or Configuration tab.

I'll let you know how it goes in a couple of days.

kubitron commented 12 years ago

Good question on the best cache settings. I made the mySQL setting larger on the outside chance that the plugin had extra overhead in caching. That is one part of the plugin I haven't touched/rewritten yet.

I should definitely put a note in the README...

kubitron commented 12 years ago

p.s. Let me know if this fixes your problem.

Lncn commented 12 years ago

kubitron,

Yes, this fixed my problem. I set it up just like yours (32MB in my.cnf, 16MB in the actual plugin settings) and everything worked. Thanks!

I did run into a different problem dealing with the changeset inserts into the DB running into conflicts, but this may have something to do with the way git-svn migrated the SVN revisions to git hashes or something... Not sure. It was strange because when I clicked the repo tab, it would run into a different conflict each time, but I noticed the svn rev would increase each time and eventually it got through all of them and the repo tab appears as it should. (I had to generate this error about 10 times). This is unrelated though. It works fine now. I'll let you know if I see that again.