Closed TheoChevalier closed 2 years ago
Notes:
Solution: try to find common commit that can be used Solution: put the whole thing in a transaction
A couple of notes during dev
_pull
/_push
already happen in a transactiongit pull
happening before _pull
/_push
- https://github.com/wagtail/wagtail-localize-git/blob/main/wagtail_localize_git/sync.py#L179-L181 which is what updates the HEAD reference. we cannot wrap the repository pull in a transaction as that is happening on disk rather than dbI dug into how Pontoon works with VCS and git. It does the expected commit and push, rather than anything more complex like a rebase and force push (which would rewrite references). Given that https://github.com/wagtail/wagtail-localize-git/blob/main/wagtail_localize_git/git.py#L54-L57 should, at most, raise a value error that the commits are different.
@TheoChevalier is it at all possible there was a forced push to the Pontoo repository (always worth checking)
The path I was going previously turned out to be erroneous. The exception is a side effect.
Scenario (easiest is to set a breakpoint on https://github.com/wagtail/wagtail-localize-git/blob/main/wagtail_localize_git/sync.py#L141)
repo.push()
will happily run as it captures issues and returns a list of updated or failed heads. If it fails completely, the list length is 0.I think the best way to account for this is to stop the push (but log the error) then wait for the next sync (either via cron or forced) to pick up the changes from the remote, then push new changes
How does that sound @TheoChevalier ?
Thanks a lot for digging that nasty one, @zerolab! Really not the easiest to reproduce/track down
And yup, your approach seems good to me. We could also probably re-trigger the sync right away (I think that’s what Pontoon does when it detects a change in the repo after it pulled) but just stopping it would work
@TheoChevalier this was code reviewed and got it merged to main
.
Will tweak some of the setup options and make a new release. Note that when upgrading to it, the default branch will be main
, but that can be changed to using the WAGTAILLOCALIZE_GIT_DEFAULT_BRANCH
setting
When Pontoon commits to the repository while
sync_git
is running (after the initial pull, and before the push), it prevents wagtail-localize from committing changes to the repository because the head commit is now different. The next timesync_git
runs, this happens:I’ve hit the issue 3 times, so it seems to be reproducible
The current workaround is to run
DELETE FROM wagtail_localize_git_synclogresource;
DELETE FROM wagtail_localize_git_synclog;