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

"database is locked" #65

Closed
sharpaper opened this issue May 20, 2020 · 1 comment
Closed

"database is locked" #65

sharpaper opened this issue May 20, 2020 · 1 comment

Comments

@sharpaper
Copy link

I'm having some issues with concurrency. I'm using rdflib-sqlalchemy with a sqlite backend and I see this error from time to time

sqlalchemy.exc.OperationalError
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
[SQL: PRAGMA main.table_info("kb_cabe862c6b_asserted_statements")]
(Background on this error at: http://sqlalche.me/e/e3q8)

I think I might be opening/closing too many connections, but I'm not sure how to handle this.
What is the correct usage for dealing with concurrent requests? Should I open a global rdflib.Graph() object and keep using that? I think SQLAlchemy is supposed to maintain a connection pool and handle concurrency automatically, but I still see these errors.
Thank you.

@mwatts15
Copy link
Collaborator

It's difficult for me to say without a small, self-contained example of the issue you are experiencing, but it looks like SQLite isn't designed for a high degree of write concurrency which may be important to consider for your use-case.

With regard to pooling, rdflib-sqlalchemy creates one SQLAlchemy Engine for every instantiation of the store, so if you want to take advantage of connection pooling at that level, then you'd probably want to reuse the same RDFLib Store/Graph. Also note that you can pass arguments to create_engine if needed to tune connection pooling parameters.

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

No branches or pull requests

2 participants