Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DetachedInstanceError accessing dbnode attributes on SqlAlchemy #1292

Closed
sphuber opened this issue Mar 17, 2018 · 1 comment
Closed

DetachedInstanceError accessing dbnode attributes on SqlAlchemy #1292

sphuber opened this issue Mar 17, 2018 · 1 comment

Comments

@sphuber
Copy link
Contributor

sphuber commented Mar 17, 2018

When running a workchain on the latest workflows branch at some point a DetachedInstanceError is raised when self.dbnode.uuid is called. This is the full stack trace:

03/17/2018 02:21:53 PM, aiida.orm.implementation.general.calculation.work.WorkCalculation: [REPORT] [149|PwBaseWorkChain|on_except]: Traceback (most recent call last):
  File "/home/sphuber/.virtualenvs/aiida_plugin/src/plumpy/plumpy/events.py", line 119, in _run
    self._callback(*self._args, **self._kwargs)
  File "/home/sphuber/code/aiida/env/plugin/aiida-core/aiida/work/persistence.py", line 104, in save_checkpoint
    bundle = Bundle(process, class_loader.CLASS_LOADER)
  File "/home/sphuber/.virtualenvs/aiida_plugin/src/plumpy/plumpy/persistence.py", line 48, in __init__
    self.update(savable.save(class_loader_=class_loader_))
  File "/home/sphuber/.virtualenvs/aiida_plugin/src/plumpy/plumpy/persistence.py", line 464, in save
    base.call_with_super_check(self.save_instance_state, out_state)
  File "/home/sphuber/.virtualenvs/aiida_plugin/src/plumpy/plumpy/base/utils.py", line 33, in call_with_super_check
    fn(*args, **kwargs)
  File "/home/sphuber/code/aiida/env/plugin/aiida-core/aiida/work/workchain.py", line 62, in save_instance_state
    out_state[self._CONTEXT] = serialize_data(self.ctx)
  File "/home/sphuber/code/aiida/env/plugin/aiida-core/aiida/utils/serialize.py", line 56, in serialize_data
    return {encode_key(key): serialize_data(value) for key, value in data.iteritems()}
  File "/home/sphuber/code/aiida/env/plugin/aiida-core/aiida/utils/serialize.py", line 56, in <dictcomp>
    return {encode_key(key): serialize_data(value) for key, value in data.iteritems()}
  File "/home/sphuber/code/aiida/env/plugin/aiida-core/aiida/utils/serialize.py", line 56, in serialize_data
    return {encode_key(key): serialize_data(value) for key, value in data.iteritems()}
  File "/home/sphuber/code/aiida/env/plugin/aiida-core/aiida/utils/serialize.py", line 56, in <dictcomp>
    return {encode_key(key): serialize_data(value) for key, value in data.iteritems()}
  File "/home/sphuber/code/aiida/env/plugin/aiida-core/aiida/utils/serialize.py", line 52, in serialize_data
    return '{}{}'.format(_PREFIX_VALUE_NODE, data.uuid)
  File "/home/sphuber/code/aiida/env/plugin/aiida-core/aiida/orm/implementation/sqlalchemy/node.py", line 677, in uuid
    return unicode(self.dbnode.uuid)
  File "/home/sphuber/.virtualenvs/aiida_plugin/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 237, in __get__
    return self.impl.get(instance_state(instance), dict_)
  File "/home/sphuber/.virtualenvs/aiida_plugin/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 578, in get
    value = state._load_expired(state, passive)
  File "/home/sphuber/.virtualenvs/aiida_plugin/local/lib/python2.7/site-packages/sqlalchemy/orm/state.py", line 474, in _load_expired
    self.manager.deferred_scalar_loader(self, toload)
  File "/home/sphuber/.virtualenvs/aiida_plugin/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 610, in load_scalar_attributes
    (state_str(state)))
DetachedInstanceError: Instance <DbNode at 0x7fb2b5c0acd0> is not bound to a Session; attribute refresh operation cannot proceed

This happens when the persister tries to persist the context of the workchain, so it serialized the contents of the context, which then needs to get the uuid of a Node which sequentially trigger the error.

@sphuber sphuber added this to the v0.12.0 milestone Mar 17, 2018
@sphuber
Copy link
Contributor Author

sphuber commented Mar 19, 2018

I have not been able to reproduce the problem in workflows branch, however, it was occurring in the develop branch as well. There it was a manifestation of issue #1353 where the context of WorkChains was not being serialized. This has now been fixed in PR #1354

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant