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

Deadlock on exception when opening connection #90

Open
arnauorriols opened this issue Dec 18, 2018 · 4 comments
Open

Deadlock on exception when opening connection #90

arnauorriols opened this issue Dec 18, 2018 · 4 comments
Labels
need info Need more information for reproduce

Comments

@arnauorriols
Copy link

When SqliteDict is initialized, a connection to SQLite is opened (in here). This connection might fail.

If an exception happens, the connection does not get opened. However, the initialization still tries to create the table. In the commit of that operation, the execution is deadlocked, because the code keeps waiting infinitely in the req Queue.

@menshikh-iv
Copy link
Contributor

Hi @arnauorriols, can you add a code example that reproduces this error (so we can fix it)?

@menshikh-iv menshikh-iv added the need info Need more information for reproduce label Jan 17, 2019
@bluenote10
Copy link

I think I'm having the same issue. Steps to reproduce:

  • create write protected folder.
  • try to open a non-existing DB in the folder sqlitedict.SqliteDict("/tmp/write_protected/non_existing.sqlite", tablename="test", autocommit=True).

This crashes internally (traceback visible on stdout) but never returns, looking like the mentioned deadlocked.

@arnauorriols
Copy link
Author

arnauorriols commented Jun 21, 2019

Hi @arnauorriols, can you add a code example that reproduces this error (so we can fix it)?

I've opened #97 proposing a fix.

padelt pushed a commit to padelt/sqlitedict that referenced this issue Feb 21, 2020
…ion; avoid deadlock after race condition where command is enqueued before thread can signal an exception piskvorky#90
@padelt
Copy link

padelt commented Feb 21, 2020

@arnauorriols realized that #97 has a race condition. #107 is my fresh approach that solves the undetected failure to open the connection (on first command exection) which currently leads to a deadlock in the calling code. It also avoids the race condition when the thread's run() is slower to set self.exception than the calling code executes a command (including a then false negative exception check) and then deadlocking on the answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need info Need more information for reproduce
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants