mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
bitbake: toaster: work around 'database is locked' error
When sqlite can not cope with a stream of 'insert' queries it throws 'database is locked' exception. Wrapping model.save in transaction.atomic context and repeating the call should solve this issue. (Bitbake rev: eb305308ca8f6228c6f52dac1bd941f29c7e5eb6) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
322b4709d8
commit
507aafbd7a
@@ -29,10 +29,28 @@ from django.core import validators
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import django.db.models.signals
|
import django.db.models.signals
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger("toaster")
|
logger = logging.getLogger("toaster")
|
||||||
|
|
||||||
|
if 'sqlite' in settings.DATABASES['default']['ENGINE']:
|
||||||
|
from django.db import transaction, OperationalError
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
_base_save = models.Model.save
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
with transaction.atomic():
|
||||||
|
return _base_save(self, *args, **kwargs)
|
||||||
|
except OperationalError as err:
|
||||||
|
if 'database is locked' in str(err):
|
||||||
|
logger.warning("%s, model: %s, args: %s, kwargs: %s",
|
||||||
|
err, self.__class__, args, kwargs)
|
||||||
|
sleep(0.5)
|
||||||
|
continue
|
||||||
|
raise
|
||||||
|
|
||||||
|
models.Model.save = save
|
||||||
|
|
||||||
class GitURLValidator(validators.URLValidator):
|
class GitURLValidator(validators.URLValidator):
|
||||||
import re
|
import re
|
||||||
|
|||||||
Reference in New Issue
Block a user