kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Device > Facilities - The syncing task is doubled in the Task manager and takes too long

Open pcenov opened this issue 4 months ago • 7 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Observed behavior

Observed while testing v0.19.5-rc0 but not a regression as I am able to replicate it in Kolibri 0.19.4 as well:

When I go to Device > Settings and I initiate a sync session to KDP for the first time then in the Task manager I see that the task is doubled. The sync concludes successfully after about 25 minutes but looking at the logs I am seeing the following exception:

ERROR 2026-07-10 17:38:30,408 kolibri.core.tasks.job Job kdp_sync_23926d7a6467b99e39e8d0ae611a50d0 raised an exception: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/kolibri/core/tasks/job.py", line 370, in execute
    result = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/kolibri/core/tasks/registry.py", line 235, in __call__
    return self.func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/kolibri/core/auth/tasks.py", line 310, in dataportalsync
    call_command(command, **kwargs)
  File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/__init__.py", line 181, in call_command
    return command.execute(*args, **defaults)
  File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3/dist-packages/kolibri/core/tasks/management/commands/base.py", line 28, in handle
    return self.handle_async(*args, **options)
  File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/commands/sync.py", line 180, in handle_async
    self._sync(sync_session_client, **options)
  File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/utils.py", line 447, in _sync
    custom_signals,
  File "/usr/lib/python3/dist-packages/kolibri/core/auth/management/utils.py", line 631, in _push
    sync_client.finalize()
  File "/usr/lib/python3/dist-packages/kolibri/dist/morango/sync/syncsession.py", line 705, in finalize
    self.proceed_to_and_wait_for(transfer_stages.DESERIALIZING)
  File "/usr/lib/python3/dist-packages/kolibri/dist/morango/sync/syncsession.py", line 665, in proceed_to_and_wait_for
    ) from self.context.error
morango.errors.MorangoError: Stage `deserializing` failed

https://github.com/user-attachments/assets/17cf19eb-aa53-4d3c-a6e7-f60892c9adda

Logs: logs.zip

Expected behavior

The task should not be doubled and causing an exception in the logs. The syncing should not be taking that much time.

Steps to reproduce the issue

  1. Install Kolibri 19.4
  2. Setup a full facility and navigate to Device > Settings
  3. Click the Sync button and select KDP as the source and proceed
  4. Observe that there are 2 simultaneous tasks in the Task manager

Usage Details

Chrome - Ubuntu 22, Windows 11 v0.19.5-rc0

pcenov avatar Jul 10 '26 15:07 pcenov

@radinamatic @rtibbles

pcenov avatar Jul 10 '26 15:07 pcenov

This is almost certainly a consequence of the auto-code sync task to KDP - we should make sure to dedup syncs to KDP, and just do an early reschedule of the scheduled one in this case. I think this is reasonable to do for all scheduled syncs too, not just to KDP.

rtibbles avatar Jul 22 '26 23:07 rtibbles

Plan: Stop a manual "Sync" from creating a second, concurrent sync task when a scheduled recurring sync for the same target already exists — instead reschedule the existing scheduled job to run now.

  • [ ] Preserve recurrence when a scheduled job is re-enqueued for an immediate run
  • [ ] Converge manual and scheduled KDP syncs onto one deterministic job
  • [ ] Extend deduplication to scheduled peer facility syncs
  • [ ] Verify the end-to-end fix and guard the frontend contract

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
  • Ran the project's full test suite and linter before committing
  • For UI changes: captured live screenshots to verify rendering
  • For backend changes: verified with example API/CLI output

rtibblesbot avatar Jul 23 '26 00:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 23 '26 05:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 23 '26 23:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 24 '26 05:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 27 '26 12:07 rtibblesbot