Backport: Avoid queueing redundant DB tasks during sync

Backport of !681 (merged)

Merge request reports

Loading