Skip to content

fix(git): serialize concurrent pushes and refresh refs to avoid stale state#76

Open
karnirathorewolf wants to merge 1 commit into
bluebrown:mainfrom
karnirathorewolf:fix/serialize-concurrent-git-pushes-in-same-repo
Open

fix(git): serialize concurrent pushes and refresh refs to avoid stale state#76
karnirathorewolf wants to merge 1 commit into
bluebrown:mainfrom
karnirathorewolf:fix/serialize-concurrent-git-pushes-in-same-repo

Conversation

@karnirathorewolf
Copy link
Copy Markdown
Contributor

This pull request improves the reliability of concurrent git operations by ensuring that each repo and ref pair is handled safely, preventing race conditions and stale state issues. The most important changes are:

Concurrency control for git operations:

  • Introduced a pushLocks field in the Pool struct to serialize handler execution per repo:ref pair, preventing concurrent goroutines from racing on git push to the same branch. (task/pool.go)
  • In the Dispatch method, added logic to acquire and release a mutex for each repo:ref pair, ensuring that only one handler operates on a given branch at a time. (task/pool.go)

Ensuring up-to-date git state:

  • Added a new Refresh function to the git bindings that fetches the latest state of a ref from origin (shallow, depth 1), to avoid using stale local state. (git/bindings.go)
  • In the KoboldHandler, now calls git.Refresh before switching branches to ensure the latest remote state is fetched, reducing the risk of push rejections due to outdated data. (task/handler.go)

related to issue fixes #71

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.

Error on git push command - after each commit, pushing may not work due to other changes

1 participant