__storm_loaded__ called on empty object

Bug #619017 reported by Robert Collins on 2010-08-17
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Storm
Medium
Thomas Herve

Bug Description

I don't know why, but we're triggering the stack below.

What it shows is:
 - an object loaded by a query
 - that is in the object cache [but only the id is populated]
 - has its __storm_loaded__ hook called *before* the object is fully populated
 - which triggers a single lookup of that object

This throws out the query count and is likely making some stuff rather slower than it needs to be, in the places we're using __storm_loaded__

The cause is _get_object's hook running. I have a workaround which is to not run the hook in this particular code path; branch coming soon : but you get to write tests :)

  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/store.py", line 980, in __iter__
    yield self._load_objects(result, values)
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/store.py", line 972, in _load_objects
    return self._find_spec.load_objects(self._store, result, values)
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/store.py", line 1710, in load_objects
    values[values_start:values_end])
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/store.py", line 704, in _load_object
    obj = self._get_object(obj_info, no_hook=False)
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/store.py", line 740, in _get_object
    self._run_hook(obj_info, "__storm_loaded__")
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/store.py", line 749, in _run_hook
    func()
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/sqlobject.py", line 287, in __storm_loaded__
    self._init(None)
  File "/home/robertc/launchpad/lp-branches/working/lib/lp/registry/model/person.py", line 428, in _init
    if self.teamownerID is not None:
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/properties.py", line 60, in __get__
    return obj_info.variables[column].get()
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/store.py", line 899, in _resolve_lazy_value
    result = self._connection.execute(Select(autoreload_columns, where))
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/databases/postgres.py", line 249, in execute
    return Connection.execute(self, statement, params, noresult)
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/database.py", line 238, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/databases/postgres.py", line 259, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/database.py", line 316, in raw_execute
    statement, params or ())
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/database.py", line 367, in _check_disconnect
    return function(*args, **kwargs)
  File "/home/robertc/launchpad/lp-sourcedeps/eggs/storm-0.17-py2.6-linux-x86_64.egg/storm/tracer.py", line 95, in trace
    attr(*args, **kwargs)
  File "/home/robertc/launchpad/lp-branches/working/lib/canonical/launchpad/webapp/adapter.py", line 508, in connection_raw_execute
    traceback.print_stack()

Related branches

Thomas Herve (therve) on 2010-08-17
Changed in storm:
importance: Undecided → Medium
milestone: none → 0.18
Thomas Herve (therve) on 2010-08-17
Changed in storm:
assignee: nobody → Thomas Herve (therve)
status: New → In Progress
Thomas Herve (therve) on 2010-08-19
Changed in storm:
status: In Progress → Fix Committed
Gary Poster (gary) on 2010-10-26
Changed in storm:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers