Skip to content

Use DB lock to prevent concurrent syncs for the same project - #4418

Merged
flodolo merged 7 commits into
mozilla:mainfrom
flodolo:issue4387_multiple_syncs
Aug 18, 2026
Merged

flodolo merged 7 commits into
mozilla:mainfrom
flodolo:issue4387_multiple_syncs

Conversation

@flodolo

@flodolo flodolo commented Aug 17, 2026 •

Copy link
Copy Markdown
Collaborator

There are 3 changes:

  • Use a DB lock to prevent multiple syncs
  • Make the clone more reliable by removing the folder in case of clone failure.
  • Third commit to make the sync's folder name more readable by removing username and host from SCP-like URLs.

Fixes #4387 and fixes #3887.

@flodolo
flodolo requested a review from eemeli August 17, 2026 07:35

@eemeli eemeli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to the git clone seem completely disconnected from using a DB lock to prevent concurrent syncs for the same project, and should be considered separately.

The core idea of relying on the Sync table data does seem quite good.

Comment thread pontoon/sync/tasks.py Resolved
Comment thread pontoon/sync/tasks.py Outdated
Comment on lines 66 to 69
if prev_busy:
raise RuntimeError(
f"[{project.slug}] Sync aborted: Previous sync still running."
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contents of the first if prev_busy block should be included here, rather than in the transaction, provided that it's the previous sync rows that are locked, and not the project.

Comment thread pontoon/sync/tests/test_models.py Resolved
Comment thread pontoon/sync/repositories/git.py Resolved
Comment thread pontoon/sync/repositories/git.py Resolved

@flodolo flodolo left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the tmp folder approach, and explained why the lock is on the project.

For now, I kept "remove folder when failing to pull" and "use better names for checkout folders". I'd like to avoid having to split them in a separate issue and PR.

Comment thread pontoon/sync/tasks.py Resolved
@flodolo
flodolo requested a review from eemeli August 18, 2026 06:57

@eemeli eemeli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic seems sound now; just need to clean up the LLM-ish comments.

Comment thread pontoon/sync/tasks.py Resolved
Comment thread pontoon/sync/tasks.py Resolved
@flodolo

flodolo commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

The logic seems sound now; just need to clean up the LLM-ish comments.

Those are very much flod-made comments, but OK ;-)

@flodolo
flodolo merged commit b8f14cd into mozilla:main Aug 18, 2026
7 checks passed
@flodolo
flodolo deleted the issue4387_multiple_syncs branch August 18, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple sync operations running at the same time can lead to data loss File exists Git error on sync

2 participants