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

Incorrect transaction state after obj.flush() caused "release unlocked lock" error in SQLite #157

andreymal opened this Issue Jan 31, 2016 · 1 comment


None yet
2 participants

andreymal commented Jan 31, 2016

I don't understand what's going on here, but it fails

from pony.orm import *

db = Database()

class TestPost(db.Entity):
    category = Optional('TestCategory')

class TestCategory(db.Entity):
    posts = Set(TestPost)

db.bind('sqlite', ':memory:')

with db_session:
    post = TestPost()
    post.flush()        # Remove one of these lines,
    post.category       # and this will work fine
    print('Created post id:',


  File "/usr/lib/python3.5/site-packages/pony/orm/", line 395, in __exit__
  File "<string>", line 2, in commit
  File "/usr/lib/python3.5/site-packages/pony/", line 65, in cut_traceback
    return func(*args, **kwargs)
  File "/usr/lib/python3.5/site-packages/pony/orm/", line 291, in commit
    transact_reraise(CommitException, exceptions)
  File "/usr/lib/python3.5/site-packages/pony/orm/", line 275, in transact_reraise
    reraise(exc_class, new_exc, tb)
  File "/usr/lib/python3.5/site-packages/pony/", line 92, in reraise
    try: raise exc.with_traceback(tb)
  File "/usr/lib/python3.5/site-packages/pony/orm/", line 285, in commit
    try: primary_cache.commit()
  File "/usr/lib/python3.5/site-packages/pony/orm/", line 1451, in commit
    provider.commit(cache.connection, cache)
  File "/usr/lib/python3.5/site-packages/pony/orm/dbproviders/", line 226, in commit
pony.orm.core.CommitException: RuntimeError: release unlocked lock

MySQL works good

@kozlovsky kozlovsky closed this in ecab21b Feb 2, 2016


This comment has been minimized.

Show comment
Hide comment

kozlovsky Feb 2, 2016


Thank for the reporting, should be fixed now!


kozlovsky commented Feb 2, 2016

Thank for the reporting, should be fixed now!

@kozlovsky kozlovsky added the bug label Feb 4, 2016

@kozlovsky kozlovsky added this to the 0.6.3 milestone Feb 4, 2016

@kozlovsky kozlovsky changed the title from sqlite3 and orm relation after flush: release unlocked lock to Incorrect transaction state after obj.flush() caused "release unlocked lock" error in SQLite Feb 5, 2016

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