Project

General

Profile

Actions

Bug #2158

closed

KB cache recalculator: undefined method write

Added by Alexey Khoroshilov over 12 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
High
Category:
Infrastructure
Start date:
01/04/2012
Due date:
% Done:

0%

Estimated time:
Detected in build:
svn
Platform:
Published in build:

Description

На falcon:

Killing KB cache recalculator...
KB cache recalculator is (hopefully) dead.
/home/tester/ldv/opt/ldv-manager/upload_utils.rb:66:in `block in push': undefined method `write' for nil:NilClass (NoMethodError)
        from <internal:prelude>:10:in `synchronize'
        from /home/tester/ldv/opt/ldv-manager/upload_utils.rb:64:in `push'
        from /home/tester/ldv/opt/bin/ldv-upload:37:in `block in <main>'
        from /home/tester/ldv/opt/bin/ldv-upload:682:in `[]'
        from /home/tester/ldv/opt/bin/ldv-upload:682:in `<main>'

Что-то надо доставить? Или проблемы с ruby-1.9?


Related issues 1 (0 open1 closed)

Blocks Linux Driver Verification - Feature #2206: Release 0.01 version of LDV Analytics CenterClosedEvgeny Novikov01/16/2012

Actions
Actions #1

Updated by Evgeny Novikov over 12 years ago

  • Category set to Infrastructure
  • Status changed from New to Feedback

I saw source:ldv-manager/upload_utils.rb and found out that the problem is related with null pointer dereference that occurs either because of missed initialization or some race. May be there are some other error messages in log, can you examine or attach the full log?

Actions #2

Updated by Alexey Khoroshilov over 12 years ago

There are no other error messages even with LDV_DEBUG=100.
But it looks like the code inside @thread = Thread.new does work at all.

Actions #3

Updated by Alexey Khoroshilov over 12 years ago

The reason is a race condition. The new thread does not start before the first push, so it has no chance to lock the mutex.

Actions #4

Updated by Alexey Khoroshilov over 12 years ago

I have pushed a fix to qa.

Actions #5

Updated by Alexey Khoroshilov over 12 years ago

  • Status changed from Feedback to Resolved
Actions #6

Updated by Evgeny Novikov over 12 years ago

Cool! I have just one assumption. May be we should move

# The mutex will block "write" until everything is initialized
@pipe_guard.lock

outside a new thread execution instead of creating additional init_guard flag? In this case at the beginning of initialization write will be blocked untill a new thread creates pipes. After creature this thread unlocks write:
# Unlock "write" call
@pipe_guard.unlock

Actions #7

Updated by Alexey Khoroshilov over 12 years ago

Evgeny Novikov wrote:

Cool! I have just one assumption. May be we should move
[...]
outside a new thread execution instead of creating additional init_guard flag? In this case at the beginning of initialization write will be blocked untill a new thread creates pipes. After creature this thread unlocks write:
[...]

As far as I understand, mutex in Ruby have to be locked and unlocked by the same thread. That is why lock have to be left in the new thread.

Actions #8

Updated by Evgeny Novikov over 12 years ago

Alexey Khoroshilov wrote:

As far as I understand, mutex in Ruby have to be locked and unlocked by the same thread. That is why lock have to be left in the new thread.

I have tried and found out that this is true. That's why mutexes are useless in this case at all and we should remove them completely. Also I found a workaround for it here (it's similar to your, but may be nicer). I tried it:

require 'thread'

q = Queue.new
@input_pipe = nil

@thread = Thread.new do
        sleep(1)
        @input_pipe = "abc" 
        q.push(:dummy)
end

q.pop
print @input_pipe

and found out that it works (the program prints "abc").

Actions #9

Updated by Vadim Mutilin over 12 years ago

TODO: use Condition Variables (www.rubycentral.com/pickaxe/tut_threads.html) instead of busy wait on init_guard variable

Actions #10

Updated by Evgeny Novikov over 12 years ago

Vadim Mutilin wrote:

TODO: use Condition Variables (www.rubycentral.com/pickaxe/tut_threads.html) instead of busy wait on init_guard variable

Does this belong to the given issue or to the separate one? It seems to me, that the given issue should be closed (may be just take into account comment 8).

Actions #11

Updated by Evgeny Novikov over 12 years ago

Alexey, please close the issue if you haven't any objections.

Actions #12

Updated by Pavel Shved over 12 years ago

Nice bug, by the way :-)

Actions #13

Updated by Evgeny Novikov over 12 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF