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

Reduce the chance of database locks interrupting soud syncing. #11886

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions kolibri/core/device/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from kolibri.core.fields import JSONField
from kolibri.core.public.constants.user_sync_options import STALE_QUEUE_TIME
from kolibri.core.utils.cache import process_cache as cache
from kolibri.core.utils.lock import retry_on_db_lock
from kolibri.core.utils.validators import JSON_Schema_Validator
from kolibri.deployment.default.sqlite_db_names import SYNC_QUEUE
from kolibri.plugins.app.utils import interface
Expand Down Expand Up @@ -433,6 +434,12 @@ def increment_and_backoff_next_attempt(self):
# exponential backoff with min of 30 seconds
self.set_next_attempt(28 + 2 ** self.attempts)

# Saving these models seems unusually prone to hitting database locks, so we'll retry
# the save operation if we hit a lock.
@retry_on_db_lock
def save(self, *args, **kwargs):
return super(SyncQueue, self).save(*args, **kwargs)

class Meta:
unique_together = ("user_id", "instance_id")

Expand Down
Loading