Sqlite database locked - regression introduced in 2.4.5?
See original GitHub issueBelow an excerpt from my CherryPy app.
The app receives bursts of ajax calls to cncprogram_done
. Sometimes just 1 or 2 calls, sometimes up to 10 or 20 at a time (I will eventually optimize it, but for now I’m OK with it).
I just upgraded to Peewee 2.8.3 and only the first call of each burst works, the other calls say peewee.OperationalError: database is locked
while executing part.save()
.
I tried to revert to older versions, and I found out that with Peewee 2.4.4 works well and with the 2.4.5 fails.
I reverted back to 2.4.4 on the production server and everything seems to work fine.
Any idea whether I am doing something wrong or this is really a regression? Where do I start investigating?
Here is (part of) the code:
db = peewee.SqliteDatabase(path_name + '/doc.db', threadlocals=True)
class PeeweeModel(peewee.Model):
class Meta:
database = db
class CncProgramPart(PeeweeModel):
sheet = peewee.ForeignKeyField(CncProgramSheet, related_name='parts')
part_number = peewee.CharField()
time_finished = peewee.DateTimeField(default=0)
remake = peewee.BooleanField(default=False)
comment = peewee.CharField(default='')
def render(self, settings):
return render('cncprogram_edit_part_row.html',
{'part': self, 'settings': settings})
class DocFinder:
@cherrypy.expose
def cncprogram_done(self, rowid, value):
with db.transaction():
checked = value == 'true'
now = time.time()
part = CncProgramPart.get(CncProgramPart.id == rowid[9:])
if checked and not part.remake and not part.comment:
part.time_finished = now
part.comment = ''
part.remake = False
part.save()
elif part.time_finished:
part.time_finished = 0
part.save()
return part.render(Settings())
Issue Analytics
- State:
- Created 7 years ago
- Comments:40 (40 by maintainers)
Top Results From Across the Web
Release History Of SQLite
Release History. This page provides a high-level summary of changes to SQLite. For more detail, see the Fossil checkin logs at ...
Read more >SQLite database locking errors cause fatal errors - Drupal
Problem/Motivation. SQLite does not support row level locks, so when it executes a write statement it locks the entire database.
Read more >532555 - sqlite error : database is locked - chromium - Monorail
1503, mint 13. Flash Version: 18.0.0.233 (Disabled) This [mis]behavior started after updating Chrome to version 45.0.2454.85
Read more >Java prog#7. Database is locked problem solution ... - YouTube
Java prog#7. Database is locked problem solution in Java Netbeans and Sqlite (mysql).
Read more >SQLite/GPKG database locked during canvas refresh - QGIS ...
As above, during canvas refresh (only sqlite layers), when redraw isn't finished - hit "save edits" causes SQLite error "database is locked".
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another thing you should always be doing is specifying
journal_mode='wal'
when you instantiate your Sqlite database. This allows multiple readers to co-exist with a single writer, and I think this may also magically solve your issues:I have something awesome you can try…
It’s currently only in master branch, but if you want to try it out it should solve your problem.
In the
playhouse.sqliteq
module is a class namedSqliteQueueDatabase
. Replace this:With this:
At the same time, remove all calls to db.connect() and db.close().