Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
fix lock contention issue by moving git io out of db transaction
Dane Schneider5aee6cd64288
diff --git a/app/server/db/locks.go b/app/server/db/locks.goindex 1f9b3e5a..ffbfee8d 100644--- a/app/server/db/locks.go+++ b/app/server/db/locks.go@@ -356,21 +356,6 @@ func lockRepoDB(params LockRepoParams, numRetry int) (string, error) {goroutineID, time.Since(insertStart))}- // check if git lock file exists- // remove it if so- err = gitRemoveIndexLockFileIfExists(getPlanDir(orgId, planId))- if err != nil {- return "", fmt.Errorf("error removing lock file: %v", err)- }-- if branch != "" {- // checkout the branch- err = gitCheckoutBranch(getPlanDir(orgId, planId), branch)- if err != nil {- return "", fmt.Errorf("error checking out branch: %v", err)- }- }-// Commit the transactionif err = tx.Commit(); err != nil {return "", fmt.Errorf("error committing transaction: %v", err)@@ -448,6 +433,21 @@ func lockRepoDB(params LockRepoParams, numRetry int) (string, error) {}}()+ // check if git lock file exists+ // remove it if so+ err = gitRemoveIndexLockFileIfExists(getPlanDir(orgId, planId))+ if err != nil {+ return "", fmt.Errorf("error removing lock file: %v", err)+ }++ if branch != "" {+ // checkout the branch+ err = gitCheckoutBranch(getPlanDir(orgId, planId), branch)+ if err != nil {+ return "", fmt.Errorf("error checking out branch: %v", err)+ }+ }+if locksVerboseLogging {log.Println("repo locked. id:", newLock.Id)}