ericpaulbishop / redmine_git_hosting

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

Inserting large changeset in the cache breaks Repository view #142

Closed Lncn closed 12 years ago

Lncn commented 12 years ago

This may or may not be the exact cause, but I don't have much experience with the internals of this plugin or Redmine (Or Ruby/Rails to be honest). Here is a little background, as my setup may have something to do with the problem:

I am running Redmine (1.3) on an internal network in my office and I wanted to create a project for users to post issues on bugs and feature requests for Redmine itself so we can track any changes we make to the server.

I basically wanted to keep the production/test code under git control on the server and I will simply 'git push' from the served directory to the git repository where Gitolite stores the repos. This basically acts as a working backup and allows us to visually track our Redmine setup's changesets within Redmine repository browser.

I set this up today and was apparently wrong is how easy I thought this would be. Here is what I did:

1) Created "Redmine" project within Redmine 2) On the server's Redmine directory, /var/www/redmine/, I did a git init to initialize the repo and git add . to add all files under redmine. I committed this to the local repo as the Initial commit 3) Now, I wanted to have the redmine code show up on the project's repository tab, so I did a git push and got no complaints from the git or the gitolite server

Now, when I check the repository tab in our Redmine project, I get a 404 error. I did a little snooping and noticed that the production.log said that the MySQL INSERT into the changeset cache was failing. (Also, I noticed the log jumps ~30MB each time I do this):

Processing RepositoriesController#show (for 10.0.13.126 at 2012-01-21 12:18:20)
   Parameters: {"action"=>"show", "id"=>"tmsmine", "controller"=>"repositories"}
 Fethcing changes for /tmp/redmine_git_hosting/gitolite-admin
 Creating MD5 digests for Redmine Git Hosting hook
 Digest for post-receive.redmine_gitolite.rb: 08e9b3cf99fa6285331ccdcef8b9a0d3
 Our hook is already installed

 ActiveRecord::StatementInvalid (Mysql::Error: MySQL server has gone away: INSERT
   lib/redmine/scm/adapters/git_adapter.rb:301:in `diff'
   app/models/repository.rb:144:in `diff'
   vendor/plugins/redmine_diff_email/app/models/diff_mailer.rb:11:in `diff_notifi
   app/models/repository/git.rb:180:in `save_revision'
   app/models/repository/git.rb:156:in `fetch_changesets'
   app/models/repository/git.rb:154:in `fetch_changesets'
   lib/redmine/scm/adapters/git_adapter.rb:279:in `revisions'
   lib/redmine/scm/adapters/git_adapter.rb:203:in `revisions'
   app/models/repository/git.rb:152:in `fetch_changesets'
   app/models/repository/git.rb:147:in `each'
   app/models/repository/git.rb:147:in `fetch_changesets'
   app/controllers/repositories_controller.rb:92:in `show_without_git_instruction
   passenger (3.0.11) lib/phusion_passenger/rack/request_handler.rb:96:in `proces
   passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:513:in `a
   passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:274:in `m
   passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:
   passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:
   passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:
   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:
   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_mai
   passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:in `start_sync
   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:
   passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_
   passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:132:in
   passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_
   passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:82:in `
   passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:79:in `
   passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_
   passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_applic
   passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn
   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_mai
   passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:in `start_sync
   passenger (3.0.11) helper-scripts/passenger-spawn-server:99

As you can obviously see, these lines aren't complete. The rest of the '''ActiveRecord::StatementInvalid (Mysql::Error: MySQL server has gone away: INSERT''' line is something like 30MB long!! It's the command_output response to the git show. Obviously, this show command's diff is VERY large, since I added all files in a single commit, so this could be the problem...

I'm assuming either I don't have something set up correctly to accept such a large response in the MySQL table, or I'm hitting a timeout or something. Anyone have any clue on what I could do to fix this or if this is actually a bug?

Lncn commented 12 years ago

I fixed the repository tab by changing the Max Element Cache Size to 8MB (it was at 16MB), but if I try to click the revision number of one of the files, I get the Internal Error again.

kubitron commented 12 years ago

Two problems here. (1) This version of the plugin has a serious performance problem that causes things to timeout with large changesets. (2) This version of the plugin doesn't work with redmine 1.3.

Go here:

https://github.com/kubitron/redmine_git_hosting/

Hopefully this will help.

Lncn commented 12 years ago

Hey thanks man! I actually went to pick this back up yesterday evening and found your fork with the performance and "resilient" changes and figured I would try that next. (I see most of those changes are in your master now, unless I missed something...)

I'll let you know how it goes.

kubitron commented 12 years ago

Yup. Everything on my master branch. Let me know.

kubitron commented 12 years ago

I would say, if this helps, that you should close out this issue. If you decide to use my master branch, post future bugs on my project page.

Lncn commented 12 years ago

Yes, your master branch fixed my issues. I nearly forgot to close this. Thanks!

I should note though, the redmine_diff_email plugin did not interact well with the version of this plugin that I was using. I never figured out the root cause because I uninstalled redmine_diff_email, updated redmine_git_hosting with kubitron's master changes, then reinstalled redmine_diff_email and all is well.