view · edit · sidebar · attach · print · history

20111103-debug-odba-stub-error-ruby193-oddb_org

<< | Index | >>


  1. Review ODBA::Stub error

Goal/Estimate/Evaluation
  • Debug ODBA::Stub error on Ruby 1.9.3 / 30% / 30%

Review ODBA::Stub error

Problem

  • ODBA::Stub error happens while migrate_to_utf8 method runs on Ruby 1.9.3
ODBA::Stub was unable to replace Hash#27577207 from ODDB::Fachinfo:#1418110
ODBA::Stub was unable to replace Hash#27577524 from ODDB::Patinfo:#1151
ODBA::Stub was unable to replace Hash#27577812 from ODDB::Fachinfo:#1861266
ODBA::Stub was unable to replace Hash#27578095 from ODDB::AddressSuggestion:#881704
...

Note

Experiment

ch.oddb> ODBA.cache.fetch('27577207')
-> {}
ch.oddb> ODBA.cache.fetch('1418110')
-> #<ODDB::FachinfoDocument2001:0x000000048a5cb0>
ch.oddb> odba_container = ODBA.cache.fetch('1418110'); ODBA.cache.fetch('27577207', odba_container)
-> {}

Note

  • It runs without OdbaError

Experiment

masa@masa ~/ywesee/oddb.org.ruby193 $ psql -U postgres oddb.org
psql (8.4.2)
Geben Sie »help« für Hilfe ein.

oddb.org=# SELECT content FROM object WHERE odba_id = 27577207;
 content 
---------
(0 Zeilen)

oddb.org=# SELECT content FROM object WHERE odba_id = 1418110;
(data is shown)

Note

  • An object (odba_id = 27577207) does not exist before migrate_to_utf8 runs
  • The fundamental cause of this error is that there is no object corresponding to the odba_id in the database
  • ODBA::Cache#load_object
    def load_object(odba_id, odba_caller)
      start = Time.now if(@debug)
      dump = ODBA.storage.restore(odba_id)
  • The dump becomes nil, which means there is no object of the odba_id saved in the database
  • Actually, the error comes when an object is saved with odba_store method
  • More precise part of the code is odba/lib/persistable.rb#odba_replace_persistables
    def odba_replace_persistables # :nodoc:
 ...
      odba_serializables.each { |name|
        var = instance_variable_get(name)
        if(var.is_a?(ODBA::Stub))
          instance_variable_set(name, var.odba_instance)
        end
      }
    end
  • var is a serialized object, spedified by ODBA_SERIALIZABLE array in a class
  • somehow odba_id of var increases then odba_instance method fails because in the Stub#odba_instance method ODBA.cache.fetch('odba_id') fails because the odba_id is not saved in the database

Check the number of objects (max odba_id) before migrate_to_utf8 runs

ch.oddb> ODBA.storage.max_id
-> 27577023

Experiment

  • lib/odba/persistable.rb
    def odba_replace_persistables # :nodoc:
 ...
      odba_serializables.each { |name|
        var = instance_variable_get(name)
        if(var.is_a?(ODBA::Stub))
          #instance_variable_set(name, var.odba_instance)
          instance_variable_set(name, var)
        end
      }
    end
  • src/util/oddbapp.rb
    def _migrate_child_to_utf8 child, queue, table, iconv, opts={}
      when ODBA::Persistable, ODBA::Stub
        if child = child.odba_instance
          if child.odba_unsaved?
            _migrate_to_utf8 [child], table, iconv, opts
          elsif opts[:all]
            #odba_id = child.odba_id
            if odba_id = child.instance_variable_get('@odba_id')

Note

  • If we call odba_id method for a no-odba_id-assigned object the odba_id will increment and be newly provided despite that the object is not saved in the database

Setup

  • restore database
$ sudo -u postgres dropdb oddb.org; sudo -u postgres createdb -E UTF8 -T template0 oddb.org
$ zcat ../oddb.org/data/sql/oddb.org.20111102.sql.gz | psql -U postgres oddb.org

Run

$ ruby193 -I ../oddb/lib bin/oddbd > log.dat 2>&1
  • bin/admin
ch.oddb> migrate_to_utf8

Result

  • Let's see tomorrow
view · edit · sidebar · attach · print · history
Page last modified on November 03, 2011, at 04:51 PM