view · edit · sidebar · attach · print · history

20100920-trace-limitationText-object

<< Masa.20100921-trace-import-limitation-process | 2010 | Masa.20100917-hack-limitationText-class >>


  1. Trace searching process with debug mode
  2. Trace searching process with set_trace_func method
  3. Trace OddbPrevalence@registration
  4. Read and Trace ODBA.cache.fetch_named

Goal
  • Trace limitation_text object / 50%
Milestones
  1. Try to trace the searching process with debugger fail 9:00
  2. Try to trace the searching process with set_trace_func method fail 11:00
  3. Trace OddbPrevalance@registrations 15:00
  4. Read ODBA.cache.fetch_named 16:40
  5. Trace ODBA.cache.fetch_named
  6. Try tracel_local_var in the other class stop
Summary
Commits
ToDo Tomorrow
  1. Dimdi-Import-Error.
Keep in Mind
Attached Files

Trace searching process with debugger

Link

Log
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) 

Trace searching process with set_trace_func method

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

Trace OddbPrevalence@registration

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

  • At least, @registrations have already been set before search_oddb method called
  • @registrations is a instance variable of OddbPrevalence which is NOT under ODDB module

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

src/util/oddbapp.rb

      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
      }
  • This method looks getting the @registraions information

Question

  • All the data is cached in the memory in the booting up process?

Notes

  • Cache data at the last run of system may be saved somewhere via ODBA

Read and Trace ODBA.cache.fetch_named

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

  • The things I would like to know are
    • if all the data is restored at the boot process or not
      • this means no more database design (mapping to objects) is needed?
    • how the data cache process is at the first time when no cache data is saved
    • if the cache data is directly saved from import processes (import scripts run) or not
    • etc...
view · edit · sidebar · attach · print · history
Page last modified on July 13, 2011, at 11:59 AM