{"action":"created","issue":{"url":"https://api.github.com/repos/ckan/ckan/issues/2819","repository_url":"https://api.github.com/repos/ckan/ckan","labels_url":"https://api.github.com/repos/ckan/ckan/issues/2819/labels{/name}","comments_url":"https://api.github.com/repos/ckan/ckan/issues/2819/comments","events_url":"https://api.github.com/repos/ckan/ckan/issues/2819/events","html_url":"https://github.com/ckan/ckan/issues/2819","id":124782337,"number":2819,"title":"InvalidRequestError: This session is in 'prepared' state; no further SQL can be emitted within this transaction","user":{"login":"yanik5","id":3940227,"avatar_url":"https://avatars.githubusercontent.com/u/3940227?v=3","gravatar_id":"","url":"https://api.github.com/users/yanik5","html_url":"https://github.com/yanik5","followers_url":"https://api.github.com/users/yanik5/followers","following_url":"https://api.github.com/users/yanik5/following{/other_user}","gists_url":"https://api.github.com/users/yanik5/gists{/gist_id}","starred_url":"https://api.github.com/users/yanik5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanik5/subscriptions","organizations_url":"https://api.github.com/users/yanik5/orgs","repos_url":"https://api.github.com/users/yanik5/repos","events_url":"https://api.github.com/users/yanik5/events{/privacy}","received_events_url":"https://api.github.com/users/yanik5/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"wardi","id":153258,"avatar_url":"https://avatars.githubusercontent.com/u/153258?v=3","gravatar_id":"","url":"https://api.github.com/users/wardi","html_url":"https://github.com/wardi","followers_url":"https://api.github.com/users/wardi/followers","following_url":"https://api.github.com/users/wardi/following{/other_user}","gists_url":"https://api.github.com/users/wardi/gists{/gist_id}","starred_url":"https://api.github.com/users/wardi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wardi/subscriptions","organizations_url":"https://api.github.com/users/wardi/orgs","repos_url":"https://api.github.com/users/wardi/repos","events_url":"https://api.github.com/users/wardi/events{/privacy}","received_events_url":"https://api.github.com/users/wardi/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2016-01-04T15:47:01Z","updated_at":"2016-03-02T09:30:29Z","closed_at":null,"body":"When submiting a dataset I got next error: \r\n`InvalidRequestError: This session is in 'prepared' state; no further SQL can be emitted within this transaction`\r\n\r\nFull:\r\n```\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/ckan/controllers/package.py', line 727 in new_resource\r\n  dict(data_dict, state='active'))\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/ckan/logic/__init__.py', line 429 in wrapped\r\n  result = _action(context, data_dict, **kw)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/ckan/logic/action/update.py', line 374 in package_update\r\n  model.repo.commit()\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/vdm/sqlalchemy/tools.py', line 107 in commit\r\n  self.session.commit()\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py', line 150 in do\r\n  return getattr(self.registry(), name)(*args, **kwargs)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py', line 789 in commit\r\n  self.transaction.commit()\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py', line 385 in commit\r\n  self._prepare_impl()\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py', line 354 in _prepare_impl\r\n  self.session.dispatch.before_commit(self.session)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/event/attr.py', line 260 in __call__\r\n  fn(*args, **kw)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/ckan/model/extension.py', line 112 in before_commit\r\n  methodcaller('before_commit', session)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/ckan/model/extension.py', line 92 in notify_observers\r\n  func(observer)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/ckan/model/modification.py', line 35 in before_commit\r\n  self.notify_observers(session, self.notify)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/ckan/model/modification.py', line 77 in notify_observers\r\n  method(obj, domain_object.DomainObjectOperation.changed)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/ckan/model/modification.py', line 84 in notify\r\n  observer.notify(entity, operation)\r\nFile '/home/oasis/ckanext-oasis/ckanext/oasis/plugin.py', line 43 in notify\r\n  product_sync(entity.id, entity.title, entity.extras['price'])\r\nFile '/home/oasis/ckanext-oasis/ckanext/oasis/queries.py', line 61 in product_sync\r\n  parthner = session.query(Partner).filter().first()\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py', line 2354 in first\r\n  ret = list(self[0:1])\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py', line 2215 in __getitem__\r\n  return list(res)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py', line 2425 in __iter__\r\n  return self._execute_and_instances(context)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py', line 2438 in _execute_and_instances\r\n  close_with_result=True)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py', line 2429 in _connection_from_session\r\n  **kw)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py', line 881 in connection\r\n  execution_options=execution_options)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py', line 886 in _connection_for_bind\r\n  engine, execution_options)\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py', line 306 in _connection_for_bind\r\n  self._assert_active()\r\nFile '/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py', line 202 in _assert_active\r\n  \"This session is in 'prepared' state; no further \"\r\nInvalidRequestError: This session is in 'prepared' state; no further SQL can be emitted within this transaction.\r\n```\r\n\r\nMy modifications:\r\n\r\nI catch dataset status `active`, when creating one, from `IDomainObjectModification` and add some custom non-blocking queries with `ckan.model.Session` on that event. \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ckan/ckan/issues/comments/191153050","html_url":"https://github.com/ckan/ckan/issues/2819#issuecomment-191153050","issue_url":"https://api.github.com/repos/ckan/ckan/issues/2819","id":191153050,"user":{"login":"yanik5","id":3940227,"avatar_url":"https://avatars.githubusercontent.com/u/3940227?v=3","gravatar_id":"","url":"https://api.github.com/users/yanik5","html_url":"https://github.com/yanik5","followers_url":"https://api.github.com/users/yanik5/followers","following_url":"https://api.github.com/users/yanik5/following{/other_user}","gists_url":"https://api.github.com/users/yanik5/gists{/gist_id}","starred_url":"https://api.github.com/users/yanik5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanik5/subscriptions","organizations_url":"https://api.github.com/users/yanik5/orgs","repos_url":"https://api.github.com/users/yanik5/repos","events_url":"https://api.github.com/users/yanik5/events{/privacy}","received_events_url":"https://api.github.com/users/yanik5/received_events","type":"User","site_admin":false},"created_at":"2016-03-02T09:30:29Z","updated_at":"2016-03-02T09:30:29Z","body":"Looks like simple `ckan.model.Session.commit()` done the trick. \r\nMaybe because I bump from 2.4 to 2.5.1\r\n"}}