<< Masa.20100921-trace-import-limitation-process | 2010 | Masa.20100917-hack-limitationText-class >>
fail
9:00
fail
11:00
Link
masa@masa ~/ywesee/oddb.org $ ruby -rdebug bin/oddbd Debug.rb Emacs support available. /usr/lib64/ruby/site_ruby/1.8/auto_gem.rb:4:begin (rdb:1) c /usr/lib64/ruby/1.8/drb/drb.rb:1651: `DRb::DRbServerNotFound' (DRb::DRbServerNotFound) from /usr/lib64/ruby/1.8/drb/drb.rb:1044:in `initialize' from /home/masa/ywesee/oddb.org/src/util/currency.rb:4:in `new' from /home/masa/ywesee/oddb.org/src/util/currency.rb:4 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from bin/oddbd:8 /usr/lib64/ruby/1.8/drb/drb.rb:1651: raise DRbServerNotFound unless server (rdb:1) l [1646, 1655] in /usr/lib64/ruby/1.8/drb/drb.rb 1646 # If the above rule fails to find a server, a DRbServerNotFound 1647 # error is raised. 1648 def current_server 1649 drb = Thread.current['DRb'] 1650 server = (drb && drb['server']) ? drb['server'] : @primary_server => 1651 raise DRbServerNotFound unless server 1652 return server 1653 end 1654 module_function :current_server 1655 (rdb:1)
Link
trace_local_var
def trace_local_var(var) old_var = Object.new set_trace_func proc {|event, file, line, id, binding, klass, *rest| if event == 'line' || event == 'return' begin v = eval(var, binding) puts "#{file}:#{line}:#{klass}:#{id} #{var}=#{v.inspect}" if old_var != (old_var = v) rescue NameError end end } end
bin/oddbd
#!/usr/bin/env ruby # OddbServer $: << File.expand_path("../src", File.dirname(__FILE__)) $: << File.expand_path("..", File.dirname(__FILE__)) require 'drb/drb' require 'util/currency' require 'util/oddbapp' require 'etc/db_connection' require 'trace_local_var' trace_local_var("limitation_text")
Log
init system init system: 4.021021 setup drb-delegation reset reset: 4.032912 system initialized initialized: 4.032984 /usr/lib64/ruby/site_ruby/1.8/odba/persistable.rb:578: [BUG] Segmentation fault ruby 1.8.6 (2009-06-08) [x86_64-linux] Abgebrochen
Experiment
src/util/oddbapp.rb
def search_oddb(query, lang) p @registrations.length p @registrations['38294'].class masa = @registrations['38294'] result = ODDB::SearchResult.new result.exact = true result.search_query = query # atcless if(query == 'atcless') atc = ODDB::AtcClass.new('n.n.') atc.sequences = atcless_sequences atc.instance_eval { alias :active_packages :packages } result.atc_classes = [atc] result.search_type = :atcless return result end # iksnr or ean13 if(match = @@iks_or_ean.match(query)) iksnr = match[1] if(reg = registration(iksnr)) p iksnr p masa == reg
Result
OddbPrevalence 9673 ODDB::Registration "38294" true
Therefore
Experiment
src/util/oddbapp.rb
module ODDB class App < SBSM::DRbServer .... def initialize opts={} @rss_mutex = Mutex.new @admin_threads = ThreadGroup.new start = Time.now @system = ODBA.cache.fetch_named('oddbapp', self){ OddbPrevalence.new } p @system.registrations.length $masa = @system.registrations['38294'] p $masa.packages[1].limitation_text.to_s
if(reg = registration(iksnr)) p $masa == reg reg.packages.each do |pack| p pack.limitation_text.to_s end
Result
6 "01.04.10.: Einfache Sedativa/Tranquillantia\n\nGesamthaft zugelassen 120 Punkte. Iniectabilia sine limitatione" init system init system: 4.038211 setup drb-delegation reset reset: 4.049746 system initialized initialized: 4.049819 true "" "01.04.10.: Einfache Sedativa/Tranquillantia\n\nGesamthaft zugelassen 120 Punkte. Iniectabilia sine limitatione" "" "01.04.10.: Einfache Sedativa/Tranquillantia\n\nGesamthaft zugelassen 120 Punkte. Iniectabilia sine limitatione" "01.04.10.: Einfache Sedativa/Tranquillantia\n\nGesamthaft zugelassen 120 Punkte. Iniectabilia sine limitatione" "01.04.10.: Einfache Sedativa/Tranquillantia\n\nGesamthaft zugelassen 120 Punkte. Iniectabilia sine limitatione" true
Therefore
@system = ODBA.cache.fetch_named('oddbapp', self){ OddbPrevalence.new }
Question
Notes
Source code
odba/lib/odba/cache.rb#fetch_named
def fetch_named(name, odba_caller, &block) # :nodoc: fetch_or_do(name, odba_caller) { dump = ODBA.storage.restore_named(name) if(dump.nil?) odba_obj = block.call odba_obj.odba_name = name odba_obj.odba_store(name) odba_obj else fetch_or_restore(name, dump, odba_caller) end } end
Before this method called, the following methods, ODBA::Cache#setup and ODBA::Cache#clean_prefetched, are also called
odba/lib/odba/cache.rb#setup
# Create necessary DB-Structure / other storage-setup def setup ODBA.storage.setup self.indices.each_key { |index_name| ODBA.storage.ensure_target_id_index(index_name) } create_deferred_indices nil end
odba/lib/odba/cache.rb#clean_prefetched
# overrides the ODBA_PREFETCH constant and @odba_prefetch instance variable # in Persistable. Use this if a secondary client is more memory-bound than # performance-bound. def clean_prefetched(flag=true) if(@clean_prefetched = flag) clean end end
BraSt