view · edit · sidebar · attach · print · history

20130312-debug-swissmedic-job-invalid-object

<< | Index | >>


Summary

  • Debug Broken Object and Error on Swissmedic Job.

Commit

Index


Search broken Objects

There are still broken Sequence objects.
These Objects caused errors on Jobs.

Swissmedic-followers

/var/www/oddb.org/log/job.pid is deleted
(druby://localhost:10005)
/usr/local/lib/ruby/gems/1.9.1/gems/odba-1.0.8/lib/odba/stub.rb:112:in
`method_missing': undefined method `active?' for []:Array
(NoMethodError)
        from (druby://localhost:10005)
/var/www/oddb.org/src/model/package.rb:413:in `public?'
        from (druby://localhost:10005)
/usr/local/lib/ruby/gems/1.9.1/gems/odba-1.0.8/lib/odba/stub.rb:112:in
`method_missing'
        from (druby://localhost:10005)
/var/www/oddb.org/ext/export/src/generics_xls.rb:96:in `block in
export_generics'
        from (druby://localhost:10005)
/var/www/oddb.org/src/model/sequence.rb:174:in `each'
        from (druby://localhost:10005)
/var/www/oddb.org/src/model/sequence.rb:174:in `each_package'
        from (druby://localhost:10005)

rebuild_indices

DBI::ProgrammingError
ERROR:  text search configuration "default_french" does not exist
NoMethodError
undefined method `active?' for []:Array
/var/ch.oddb.org/src/util/oddbapp.rb:1324:in `instance_eval'
/var/ch.oddb.org/src/model/sequence.rb:64:in `active_packages'
ch.oddb> active_packages.length
-> undefined method `active?' for []:Array

src/util/oddbapp.rb

  def active_packages
    @registrations.inject([]) { |pacs, (iksnr,reg)|
      pacs.concat(reg.active_packages)
    }    
  end

src/model/registration.rb

    def active_packages
      if active?
        @sequences.values.inject([]) do |memo, seq|
          memo.concat seq.active_packages
        end
      else
        []
      end
    end

@src/model/sequence.rb

    def active_packages
      if(active?)
        @packages.values.select { |pac| pac.active? }
      else
        []
      end
    end
    ...
    def active?
      (!@inactive_date || (@inactive_date > @@two_years_ago)) \
        && @registration && @registration.active? && !violates_patent?
    end

This Sequence

ch.oddb> sequences.length
-> 16148
ch.oddb> sequences.select{|seq| !seq.registration.is_a?(ODDB::Registration) }.length #=> sequence
-> 1
ch.oddb> self.registrations.values.select{|reg| !reg.sequences.values.select{|seq| seq.odba_id == 73813 }.empty? }.length #=> registration
-> 1

# repair
ch.oddb> sequences.select{|seq| !seq.registration.is_a?(ODDB::Registration) }.first.registration = self.registrations.values.select{|reg| !reg.sequences.values.select{|seq| seq.odba_id == 73813 }.empty? }.first
-> #<ODDB::Registration:0x0000000b0093e8>
ch.oddb> ODBA.cache.fetch(73813).registration
-> #<ODDB::Registration:0x0000000b0093e8>
ch.oddb> ODBA.cache.fetch(73813).odba_store

ch.oddb> active_packages.length
-> 17999

Then update to prevent this error.

commit

Debug odba INDEX creation

DBI::ProgrammingError
ERROR:  text search configuration "default_german" does not exist
/path/to/ruby/1.9.1/gems/dbd-pg-0.3.9/lib/dbd/pg/statement.rb:62:in `rescue in execute'
/path/to/ruby/1.9.1/gems/dbd-pg-0.3.9/lib/dbd/pg/statement.rb:37:in `execute'


DBI::ProgrammingError
ERROR:  text search configuration "default_french" does not exist
/path/to/ruby/1.9.1/gems/dbd-pg-0.3.9/lib/dbd/pg/statement.rb:62:in `rescue in execute'
/path/to/ruby/1.9.1/gems/dbd-pg-0.3.9/lib/dbd/pg/statement.rb:37:in `execute'

lib/odba/index.rb

    def do_update_index(origin_id, search_text, target_id=nil) # :nodoc:
      ODBA.storage.update_fulltext_index(@index_name, origin_id,
                                         search_text, target_id, 
                                         @dictionary)
    end

lib/odba/storage.rb

    def update_fulltext_index(index_name, origin_id, search_term, target_id, dict)
      search_term = search_term.gsub(/\s+/, ' ').strip
      if(target_id)
        self.dbi.do <<-SQL, origin_id, dict, search_term, target_id
INSERT INTO #{index_name} (origin_id, search_term, target_id)
VALUES (?, to_tsvector(?, ?), ?)
        SQL
      else
        self.dbi.do <<-SQL, dict, search_term, origin_id
UPDATE #{index_name} SET search_term=to_tsvector(?, ?)
WHERE origin_id=?
        SQL
      end 
    end

This is needed to update of odba.
ODBA does not have valid table name of current tsearch2 extension for index creation.

production server also run PostgreSQL 8.3. (But odba has code for < 8.2.)

ch.oddb> generate_dictionaries
-> ERROR:  relation "pg_ts_cfg" does not exist
LINE 1:         DELETE FROM pg_ts_cfg
                            ^

Update odba INDEX creation

setup for fulltext search.

# psql
CREATE EXTENSION tsearch2;

# grant
oddb.org.ruby193=# GRANT ALL ON pg_ts_config to oddb;
GRANT 
oddb.org.ruby193=# GRANT ALL ON pg_ts_config_map to oddb;
GRANT
oddb.org.ruby193=# GRANT ALL ON pg_ts_dict to oddb;
GRANT
oddb.org.ruby193=# GRANT ALL ON pg_ts_parser to oddb;
GRANT
oddb.org.ruby193=# select * from pg_ts_config;
  cfgname   | cfgnamespace | cfgowner | cfgparser 
------------+--------------+----------+-----------
 simple     |           11 |       10 |      3722
 danish     |           11 |       10 |      3722
 dutch      |           11 |       10 |      3722
 english    |           11 |       10 |      3722
 finnish    |           11 |       10 |      3722
 french     |           11 |       10 |      3722
 german     |           11 |       10 |      3722
 hungarian  |           11 |       10 |      3722
 italian    |           11 |       10 |      3722
 norwegian  |           11 |       10 |      3722
 portuguese |           11 |       10 |      3722
 romanian   |           11 |       10 |      3722
 russian    |           11 |       10 |      3722
 spanish    |           11 |       10 |      3722
 swedish    |           11 |       10 |      3722
 turkish    |           11 |       10 |      3722
(16 rows)
oddb.org.ruby193=# \d pg_ts_config_map;
Table "pg_catalog.pg_ts_config_map"
    Column    |  Type   | Modifiers 
--------------+---------+-----------
 mapcfg       | oid     | not null
 maptokentype | integer | not null
 mapseqno     | integer | not null
 mapdict      | oid     | not null
Indexes:
    "pg_ts_config_map_index" UNIQUE, btree (mapcfg, maptokentype, mapseqno)

dictionary of fulltext is needed for index.

z.B.

oddb.org.ruby193=# select * from fachinfo_index_fr limit 3;
 origin_id | search_term | target_id 
-----------+-------------+-----------
  10187788 |             |     11977
  28685169 |             |     11977
  25757193 |             |     18601
(3 rows)

oddb.org.ruby193=# select * from unwanted_effects_index_de limit 3;
 origin_id | search_term | target_id 
-----------+-------------+-----------
  28954758 |             |  25647596
  28954758 |             |  25647641
  28954758 |             |  25647686

But ODBA is needed many change for postgres-8.3 or later.
suspend.


Debug-error-invoice-job

Corrupted Data ODDB:Text::Chapter in invoice objeect.

Error: NoMethodError
Message: undefined method `type' for #<ODDB::Text::Chapter:0x00000010ab3a28>
Backtrace:
/usr/local/lib/ruby/gems/1.9.1/gems/odba-1.0.8/lib/odba/stub.rb:112:in
`method_missing'
/var/www/oddb.org/src/plugin/info_invoicer.rb:23:in `block (2 levels)
in active_companies'
/var/www/oddb.org/src/plugin/info_invoicer.rb:22:in `each'
/var/www/oddb.org/src/plugin/info_invoicer.rb:22:in `block in active_companies'
/var/www/oddb.org/src/plugin/info_invoicer.rb:20:in `each'

strange InvoiceItem.

ch.oddb> invoices.values.select{|inv| !inv.items.values.select{|item| !item.respond_to?(:type) }.empty? }.first.items.values.first.type
-> undefined method `type' for #<ODDB::Text::Chapter:0x0000000a05eee8>
ch.oddb> invoices.values.select{|inv| !inv.items.values.select{|item| !item.respond_to?(:type) }.empty? }.first.items.values.first.class
-> ODDB::InvoiceItem

delete strange Object.

ch.oddb> invoices.values.select{|inv| !inv.items.values.select{|item| !item.respond_to?(:type) }.empty? }.first.items.values.first.odba_id
-> 29502873
ch.oddb> ODBA.cache.fetch(29502873)
-> ODDB::Text::Chapter
ch.oddb> ODBA.cache.fetch(29502873).odba_delete
-> ODDB::Text::Chapter

ch.oddb> invoices.values.select{|inv| !inv.items.values.select{|item| !item.respond_to?(:type) }.empty? }.length
-> 0

Debug Swissindexpharma-plugin-error

Plugin: ODDB::SwissindexPharmaPlugin
Error: TypeError
Message: can't convert nil into Integer
Backtrace:
/var/www/oddb.org/src/plugin/swissindex.rb:234:in `sprintf'
/var/www/oddb.org/src/plugin/swissindex.rb:234:in `block in report'
/var/www/oddb.org/src/plugin/swissindex.rb:233:in `each'
/var/www/oddb.org/src/plugin/swissindex.rb:233:in `report'
/var/www/oddb.org/src/plugin/plugin.rb:54:in `block in log_info'
...

Now Data does not have any probelem for this job.

view · edit · sidebar · attach · print · history
Page last modified on March 13, 2013, at 09:06 AM