Merge Request Error

187 views
Skip to first unread message

Ryan Linneman

unread,
Apr 26, 2011, 12:27:46 PM4/26/11
to Gitorious
I've setup a private install of gitorious on ubuntu following
Christians guide at http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server.
Almost everything seems to be functional now. I can seem to find any
other reports of the following issue and am not well versed in Ruby/
Rails. The problem I have is when attempting to review a merge
request, the section "Commits that would be merged" shows the
following "An error has occured. Please try again later." I've looked
into the production.log file and get:

NoMethodError (undefined method `diffs' for nil:NilClass):
app/models/merge_request_version.rb:107:in `single_commit_diff'
vendor/rails/activesupport/lib/active_support/cache.rb:162:in
`fetch'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:
17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:
17:in `ms'
vendor/rails/activesupport/lib/active_support/cache.rb:162:in
`fetch'
app/models/merge_request_version.rb:106:in `single_commit_diff'
app/models/merge_request_version.rb:38:in `diffs'
app/controllers/merge_request_versions_controller.rb:24:in `show'
vendor/rails/actionpack/lib/action_controller/base.rb:1331:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:1331:in
`perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:617:in
`call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:
17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:
17:in `ms'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in
`perform_action_without_flash'
vendor/rails/actionpack/lib/action_controller/flash.rb:146:in
`perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:532:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:532:in
`process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:606:in
`process'
vendor/rails/actionpack/lib/action_controller/base.rb:391:in
`process'
vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:
437:in `call'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:87:in
`dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:121:in
`_call'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:130
vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in
`call'
vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in
`call'
vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/query_cache.rb:34:in `cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in
`cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in
`call'
vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/connection_pool.rb:361:in `call'
vendor/rails/actionpack/lib/action_controller/string_coercion.rb:
25:in `call'
rack (1.0.1) lib/rack/head.rb:9:in `call'
rack (1.0.1) lib/rack/methodoverride.rb:24:in `call'
vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in
`call'
vendor/rails/railties/lib/rails/rack/metal.rb:47:in `call'
vendor/rails/actionpack/lib/action_controller/session/
cookie_store.rb:93:in `call'
vendor/rails/activesupport/lib/active_support/cache/strategy/
local_cache.rb:24:in `call'
vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in
`call'
rack (1.0.1) lib/rack/lock.rb:11:in `call'
rack (1.0.1) lib/rack/lock.rb:11:in `synchronize'
rack (1.0.1) lib/rack/lock.rb:11:in `call'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:in
`call'
passenger (3.0.7) lib/phusion_passenger/rack/request_handler.rb:
96:in `process_request'
passenger (3.0.7) lib/phusion_passenger/abstract_request_handler.rb:
513:in `accept_and_process_next_request'
passenger (3.0.7) lib/phusion_passenger/abstract_request_handler.rb:
274:in `main_loop'
passenger (3.0.7) lib/phusion_passenger/classic_rails/
application_spawner.rb:321:in `start_request_handler'
passenger (3.0.7) lib/phusion_passenger/classic_rails/
application_spawner.rb:275:in `send'
passenger (3.0.7) lib/phusion_passenger/classic_rails/
application_spawner.rb:275:in `handle_spawn_application'
passenger (3.0.7) lib/phusion_passenger/utils.rb:479:in `safe_fork'
passenger (3.0.7) lib/phusion_passenger/classic_rails/
application_spawner.rb:270:in `handle_spawn_application'
passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in
`__send__'
passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in
`server_main_loop'
passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:206:in
`start_synchronously'
passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:180:in
`start'
passenger (3.0.7) lib/phusion_passenger/classic_rails/
application_spawner.rb:149:in `start'
passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:219:in
`spawn_rails_application'
passenger (3.0.7) lib/phusion_passenger/
abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:214:in
`spawn_rails_application'
passenger (3.0.7) lib/phusion_passenger/
abstract_server_collection.rb:82:in `synchronize'
passenger (3.0.7) lib/phusion_passenger/
abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:213:in
`spawn_rails_application'
passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:132:in
`spawn_application'
passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:275:in
`handle_spawn_application'
passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in
`__send__'
passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in
`server_main_loop'
passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:206:in
`start_synchronously'
passenger (3.0.7) helper-scripts/passenger-spawn-server:99


The view of all potential changes by the commit is not rendered. Do
you have any ideas where I may look to resolve this?

Thanks
-Ryan

Marius Mårnes Mathiesen

unread,
Apr 27, 2011, 2:20:41 AM4/27/11
to gito...@googlegroups.com
On Tue, Apr 26, 2011 at 6:27 PM, Ryan Linneman <rlin...@gmail.com> wrote:
I've setup a private install of gitorious on ubuntu following
Christians guide at http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server.
Almost everything seems to be functional now.  I can seem to find any
other reports of the following issue and am not well versed in Ruby/
Rails.  The problem I have is when attempting to review a merge
request, the section "Commits that would be merged" shows the
following "An error has occured. Please try again later."  I've looked
into the production.log file and get:

NoMethodError (undefined method `diffs' for nil:NilClass):
 app/models/merge_request_version.rb:107:in `single_commit_diff'

Ryan,
The problem you're seeing may be caused by some parts missing on your server. A quick background:

- When you create a merge request, a new branch is pushed to the target repository (refs/merge-requests/<merge-request-id>. This branch will be the commit chosen as the last commit in the merge request
- At the same time, one branch is created for each version of a merge request in a hidden tracking repository for the target repository (refs/merge-request/<merge-request-id>/<version>

It could be that one of these branches is missing. To find the path to these repositories on disk:

Assuming the URL to your merge request is /project/repo/merge_requests/1: enter this inside script/console to find the location of the repositories on disk (substitute "project", "repository" and "1" with the real values from your merge request:

mr = Project.find_by_slug("project").repositories.find_by_name("repo").merge_requests.find_by_sequence_number(1)
mr.target_repository.full_repository_path 
mr.tracking_repository.full_repository_path

Now, verify that the merge request branch exists in the target repository:
cat <target_repo_path>/refs/merge-requests/1  # should be the SHA of the merge request
cat <tracking_repo_path>/refs/merge-requests/1/1  # should be the same

Are both of these correct?

Cheers,
- Marius

Ryan Linneman

unread,
Apr 27, 2011, 8:28:06 AM4/27/11
to gito...@googlegroups.com
Thank you so much for helping!  
Unfortunately that's a negative ghost rider, the SHA are not correct.

I was able to find the project but and the repos exist.  However the branch is not pushed and I do not see a file with the SHA in the tracking repo.  

I created a new request just now to test with and took a snapshot 'ps' of the current processes I know to be important for this activity.  The error in the production log is identical to before.  Also, while creating the merge request, I ran tail on the log/message_processing.log and got no messages at all, let alone relevant to the creation of the request, however stomp is running with the command below.

$ env RAILS_ENV=production script/console
Loading production environment (Rails 2.3.5)
>> mr=Project.find_by_slug("iProcessor").repositories.find_by_name("iprocessor-server").merge_requests.find_by_sequence_number(1)
=> #<MergeRequest id: 12, user_id: 1, source_repository_id: 29, target_repository_id: 28, proposal: "", sha_snapshot: nil, status: 1, created_at: "2011-04-27 11:48:43", updated_at: "2011-04-27 11:48:43", source_branch: "master", target_branch: "master", ending_commit: "d4eaeeb87d07f216118d5b1ad8bca962cc5a5f5c", reason: nil, oauth_token: nil, oauth_secret: nil, contribution_agreement_version: nil, updated_by_user_id: nil, status_tag: "Open", summary: "Sample MR", legacy: false, sequence_number: 1>
>> mr.target_repository.full_repository_path
=> "/media/scm/repositories/b6e/640/dba214d183676843ee5684ebaf6473212c.git"
>>  mr.tracking_repository.full_repository_path
=> "/media/scm/repositories/4fe/8c4/e66c64ca544b3840543294e8ef2c38e153.git"
>> quit

## Target
$ ls /media/scm/repositories/b6e/640/dba214d183676843ee5684ebaf6473212c.git/refs/
total 8.0K
drwxr-x--- 2 git gitorious 4.0K 2011-04-26 13:15 heads
drwxr-x--- 2 git gitorious 4.0K 2011-04-26 12:07 tags

## Tracking
$ ls /media/scm/repositories/4fe/8c4/e66c64ca544b3840543294e8ef2c38e153.git/refs/merge-requests/1/
total 0

$ ps aux | grep git
git      16076  0.1 22.9 219336 116056 ?       S    Apr26   1:32 Rails: /var/www/git.usa-800.com/gitorious
git      17323  0.0 14.0 195468   71132 ?      Sl   Apr22    4:01 ruby script/server -d
git      20941  0.0  0.0  31808        280 ?       S    Apr26   0:02 searchd --config /var/www/git.usa-800.com/gitorious/config/ultrasphinx/production.conf
git      24308  0.0  3.0 185200    15496 ?       S    Apr26   0:00 ruby /var/www/git.usa-800.com/gitorious/script/git-daemon -d
git      24727  0.0 20.3 198600  102908 ?      Sl   Apr26    0:47 poller

$ ps aux | grep stomp
root     25829  0.0  2.1  64656 11104 ?        S    Apr26   0:20 /usr/bin/ruby1.8 /usr/bin/stompserver


What direction should I head in?  Thanks again,
- Ryan

--
To post to this group, send email to gito...@googlegroups.com
To unsubscribe from this group, send email to
gitorious+...@googlegroups.com

Marius Mårnes Mathiesen

unread,
Apr 28, 2011, 2:18:10 AM4/28/11
to gito...@googlegroups.com
Ryan,
What puzzles me now is that your message_processing.log doesn't contain any traces of the merge request being processed, let's focus on that now.

When a merge request is created (or rather, its `confirmed_by_user` method is called, which happens when it's created), a message is sent to the message queue by the merge request's `publish_notification` method. This message should be picked up by the poller script, and it should be logged to message_processing.log when it's taken off the queue for processing. I suspect the poller isn't running properly.

The poller will log to message_processing.log once it's running, if it fails to start it will dump errors to tmp/pids/poller.output (not the most obvious place to look, I know). Does this file tell you anything interesting?

Cheers,
- Marius
--
Marius Mårnes Mathiesen
Rubyist, Shortcut AS
Tel.: (+47) 92 60 95 38.

http://shortcut.no

Pedro Kiefer

unread,
Jun 7, 2011, 9:58:20 AM6/7/11
to gito...@googlegroups.com
I'm having the same problem on my local gitorious install, at least on the production machine, didn't check on my dev virtual machine.

It seems that gitorious is not creating the /refs/merge-requests directory, not sure why. The repository in question was one that I manually migrated to gitorious, maybe this directory is created normally on a gitorious managed repo? Should I manually create this for each repository, or this should be automatic (ie. just create when a merge request is first create)?

Output from script/console:
>> mr.target_repository.full_repository_path
=> "/var/git/repositories/2f0/c78/ad7a33b9d36b627be36c5f26a1aa87bfe9.git"
>> mr.tracking_repository.full_repository_path
=> "/var/git/repositories/bf2/0bc/183f15a0eb49b3a018fe27dde6b5ec5f06.git"

Both this directories only have on refs/ 'heads" and 'tags" directories.

tmp/pids/poller.log has this:

#<Errno::ENOENT: No such file or directory - /var/git/repositories/bf2/0bc/183f15a0eb49b3a018fe27dde6b5ec5f06.git/git-daemon-export-ok>
*** below you find all exception objects found in memory, some of them may have been thrown in your application, others may just be in memory because they are standard exceptions ***
#<NoMemoryError: failed to allocate memory>
#<SystemStackError: stack level too deep>
#<fatal: exception reentered>
#<LoadError: no such file to load -- daemons>
#<TypeError: Expected a filter, an endpoint, a callable or a list of any of these.>
#<Errno::ENOENT: No such file or directory - /var/git/repositories/bf2/0bc>
#<ActiveMessaging::StopProcessingException: Time to stop.>
#<SystemExit: exit>

But the file is there with 666 permission. The repository in question has 777 permission, which is odd, all others repositories have 750 permission, and every thins is owned by git.

poller, git-daemon, ultrasphinx and gitorious are all running as git, as they should. I'm not entirely sure what the problem really is!

--

Pedro Kiefer

unread,
Jun 7, 2011, 10:28:09 AM6/7/11
to gito...@googlegroups.com
Same error when I created a project and repository using gitorious only. refs/merge-requests doesn't get created on the repositories neither.

Marius Mårnes Mathiesen

unread,
Jun 8, 2011, 7:54:38 AM6/8/11
to gito...@googlegroups.com
On Tue, Jun 7, 2011 at 3:58 PM, Pedro Kiefer <pki...@gmail.com> wrote:
tmp/pids/poller.log has this:

#<Errno::ENOENT: No such file or directory - /var/git/repositories/bf2/0bc/183f15a0eb49b3a018fe27dde6b5ec5f06.git/git-daemon-export-ok>
*** below you find all exception objects found in memory, some of them may have been thrown in your application, others may just be in memory because they are standard exceptions ***
#<NoMemoryError: failed to allocate memory>

Hmm, this doesn't look too good, is your server really short on memory?

Cheers,
- Marius

Pedro Kiefer

unread,
Jun 8, 2011, 9:20:54 AM6/8/11
to gito...@googlegroups.com
Not really, I have at least 1Gb of free memory (4Gb total), and more 8Gb of free swap, which should be more than enough for my small server.

So I'm really clueless here. Maybe the refactoring that Christian is doing on the ActiveMessaging will solve this, I'll wait for it to be mainlined.

--

Marius Mårnes Mathiesen

unread,
Jun 9, 2011, 3:40:49 AM6/9/11
to gito...@googlegroups.com
On Wed, Jun 8, 2011 at 3:20 PM, Pedro Kiefer <pki...@gmail.com> wrote:
Not really, I have at least 1Gb of free memory (4Gb total), and more 8Gb of free swap, which should be more than enough for my small server.

So I'm really clueless here. Maybe the refactoring that Christian is doing on the ActiveMessaging will solve this, I'll wait for it to be mainlined.

Good point! We're running his branch on a staging server, and it seems to be running just fine. So if you feel like it you could give it a shot?

Cheers,
- Marius
Reply all
Reply to author
Forward
0 new messages