loop: avoid deadlock when pushing to a checked out branch
Sketch did a good job with this:
The Problem 🐛
In AgentGitState.handleGitCommits(), there was a double-locking scenario:
Method acquires mutex lock
During git push retry logic, calls IncrementRetryNumber()
IncrementRetryNumber() tries to acquire the same mutex again
Deadlock - thread hangs forever waiting for a lock it already holds
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: sfe0bcab73addc32ak
diff --git a/loop/agent.go b/loop/agent.go
index 561e986..092181b 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -1988,7 +1988,7 @@
originalBranchName := ags.branchNameLocked(branchPrefix)
for retries := range 10 {
if retries > 0 {
- ags.IncrementRetryNumber()
+ ags.retryNumber++
}
branch := ags.branchNameLocked(branchPrefix)