view · edit · sidebar · attach · print · history


<< Masa.20120217-fix-errors-check-threads-problem-oddb_org | Index | Masa.20120215-save-attachment-bsv_xml-fix-ddd_price-interaction-snapback-interaction-key-oddb_org-update-just_medical-decorators-ebps-updated-oddb2tdat-check-grid_c-htmlgrid >>

  1. Fix interaction algorithm
  2. Fix FloatDomainError
  3. Add Migel and Interactions link in mobile look and feel
  4. Check threads management
  5. Create threads management

  1. Changed interactions algorithm to search atc-code. When some atc-codes are found, the atc-code(atc_class) that has more packages is taken. (
  2. Fix FloatDomainError. Division by zero happend when ddd_price was calculated. (
  3. Added Migel and Interactions in mobile lookandfeel (
  4. Added thread status information in status log (

Fix interaction algorithm


Note (for development)

  • atc-code corresponding to a substance in interaction_basket is searched in src/view/interactions/resultlist.rb by using @session.search_oddb method and @session.persistent_user_input(:query)
  • It is a point that the search is done with NOT substance data, BUT user input data that is used by searching.
  • The search word becomes sometimes package name, sometimes Wirkstoff name, etc.
  • A substance instance sometimes has some atc-codes (atc_class instances).
  • If more than one atc-code is found by @session.search_oddb method, the atc_class that has more packages is taken.

Fix FloatDomainError




Add Migel and Interactions link in mobile look and feel



Check threads management

Refer to


  • When and how do the number of threads go up and down in



  • /usr/local/lib/ruby/1.9.1/drb/drb.rb
    def main_loop
      Thread.start(@protocol.accept) do |client|
        @grp.add Thread.current
p "@grp = #{@grp},@grp.list.length = #{@grp.list.length}"
  • src/util/oddbapp.rb
    def log_size
        format = "%s %s: sessions: %4i - threads: %4i (%s) Group: %s - memory: %4iMB %s"
            thread_groups ={|th|}.uniq
            lines.unshift sprintf(format, alarm,
                                  time.strftime('%Y-%m-%d %H:%M:%S'),
                                  sessions, threads, threads_status.join(' '), thread_groups.join(','), mbytes, gc)


  • oddbd
  • ab
 /usr/sbin/ab -n 300 -c 100

Console log

"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 84"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 85"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 86"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 87"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 87"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 88"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 89"

Status log

  2012-02-16 11:56:24: sessions:  122 - threads:   88 (run:1 sleep:87 aborting:0 dead:0) Group: #<ThreadGroup:0x00000000ddb760>,#<ThreadGroup:0x00000000de1480> - memory: 1112MB 
  2012-02-16 11:56:18: sessions:   53 - threads:   61 (run:2 sleep:59 aborting:0 dead:0) Group: #<ThreadGroup:0x00000000ddb760>,#<ThreadGroup:0x00000000de1480> - memory:  879MB 
  2012-02-16 11:56:09: sessions:    0 - threads:   18 (run:2 sleep:16 aborting:0 dead:0) Group: #<ThreadGroup:0x00000000ddb760>,#<ThreadGroup:0x00000000de1480> - memory:  500MB 


  • DRb creates new threads when many accesses happen at the same time
  • The number of threads is related to the number of access at the same timne
  • The number of sessions is related to the number of user who accesses to
  • If one user (program) accesses to 100 times at the same time, for example using 100 brawsers, the number of sessions is 1 but the number of threads becomes 100.
  • After the request task is finished, the thread is killed by DRb and GC deletes the thread.

Create threads management


  • If the number of threads goes over a limit, the next request is passed to a read only server


  1. how to pass a request to the read only server
  2. (how to get a response from the read only server)
  3. which class should check the number of threads regularly
  4. read only server should be updated


  • doc/index.rbx runs on Apache (mod_ruby)
  • After the rebooting apache, the number of threads goes down.
  • The threads must be created by oddbd, not mod_ruby (apache).
  • Which part of oddb application creates a new thread?
  • SBSM::Request runs on mod_ruby
  • SBSM::Session, which is inherited by ODDB::Session, runs on oddbd

One certain thing

  • I can check the number of threads going up in drb.rb#main_loop (/usr/local/lib/ruby/1.9.1/drb/drb.rb)
    def main_loop
      Thread.start(@protocol.accept) do |client|
        @grp.add Thread.current
  • The question is: when is the 'Thread.current' is created
view · edit · sidebar · attach · print · history
Page last modified on February 16, 2012, at 05:36 PM