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

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

Closed
andreymal opened this issue Jan 31, 2016 · 1 comment
Labels
Milestone

Comments

@andreymal
Copy link

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:')
db.generate_mapping(create_tables=True)

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

Traceback:

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

MySQL works good

@kozlovsky
Copy link
Member

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 sqlite3 and orm relation after flush: release unlocked lock 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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants