Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Git lock error is seen and upstream changes cannot be pulled when uncommitted changes are present #36781

Open
1 task done
laveena-en opened this issue Oct 9, 2024 · 11 comments · May be fixed by #37300
Open
1 task done
Assignees
Labels
Bug Something isn't working Git Platform Pod Issues related to the git & the app platform Git Product Issues related to version control product High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage Production

Comments

@laveena-en
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Description

Git lock error is seen and upstream changes cannot be pulled when uncommitted changes are present

Steps To Reproduce

  1. Create a git connected app
  2. Create a page and let it stay as an uncommitted change
  3. Make some changes to the application via the remote repo
  4. Try to commit the uncommitted changes from step 2
  5. Notice that git lock error is seen on any discard/pull actions subsequently

Public Sample App

No response

Environment

Production

Severity

High (Blocker to building or releasing)

Issue video log

https://jam.dev/c/b4aaee05-34ff-4f50-a255-5fcd80584f86

Version

v1.43

@laveena-en laveena-en added Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Production Needs Triaging Needs attention from maintainers to triage Git Product Issues related to version control product labels Oct 9, 2024
@github-actions github-actions bot added the Git Platform Pod Issues related to the git & the app platform label Oct 9, 2024
@shanid544
Copy link

@laveena-en Created ticket for this - https://zemoso.atlassian.net/browse/TNOSB-969

@shanid544
Copy link

@laveena-en
Observed Issue

  • When trying to commit and push changes to a remote branch (not the main branch) with existing remote changes:
  • The app prompts, "Looks like there are pending upstream changes. To prevent you from losing history, we will pull the changes and push them to your repo."
  • During the discard action, an Appsmith error occurs: "We were unable to place a lock on the file system to perform command. This error can occur when another process is in progress. Please try again later."

Root Cause Analysis

  • The issue occurs when a commit command attempts to acquire a lock on the file system, which it then saves to Redis using baseArtifactId/baseAppId as the key.
  • The lock has a duration of 3 minutes with 20 retries and a 1-second interval between retries.
  • The commit command obtains this lock before the discard action is attempted. If the user quickly tries to discard, the lock remains active, and they must wait up to 3 minutes for it to be released.

@shanid544
Copy link

@brayn003 Shall I work on this?

@shanid544
Copy link

Solution : Call releaseFileLock() from CommonGitServiceCEImpl.java before throwing the GIT_UPSTREAM_CHANGES error.

@shanid544
Copy link

Test Screen-Shots
When Branch : main
Screenshot from 2024-11-01 12-19-52
Adding one more page to the application
Screenshot from 2024-11-01 14-00-13
Deleting page-1 from remote
Screenshot from 2024-11-01 14-01-13
Trying to push
Screenshot from 2024-11-01 14-02-37
Screenshot from 2024-11-01 14-03-16
The application threw an error (AppsmithError.GIT_UPSTREAM_CHANGES) during execution.
We are asked to pull the changes
Clicking on discard and pull, right after the commit and push
Screenshot from 2024-11-01 14-06-51
No issue with the main branch.
(Since the block acquired by commit is released as part of the global exception handler, the URL exception handler extracts the artifactId specific to the branch. This artifactId is then used to save the lock in Redis, allowing it to be released with the same identifier. For other branches, the base artifactId and branched artifactId will differ, but in the main branch, both will remain the same.)

When Branch is Other than main
Before implementing the solution
I created a branch called test1, added a page locally, and deleted a page from the remote branch. When I tried to push, I received an 'UPSTREAM_GIT ERROR.' I attempted to discard my changes and pull the latest updates, but encountered the following error (see screenshot).
Screenshot from 2024-10-25 17-45-51

After implementing the solution:-
Branch : test - created from main
Screenshot from 2024-11-01 14-14-59
Add one more page & delete one page from remote
Screenshot from 2024-11-01 14-15-50
Screenshot from 2024-11-01 14-16-36
Trying to push
Screenshot from 2024-11-01 14-17-11
Getting error
Screenshot from 2024-11-01 14-17-42
right after, Discard and pull
Screenshot from 2024-11-01 14-17-53

No Error. since releaseLock() has been called just before error throw

Additionally, I am considering updating the error message shown during discard actions. Instead of the generic “another process is in progress,” the updated message would specify the exact process that has obtained the file lock. This change would provide more clarity and help in diagnosing similar issues in the future.

@shanid544
Copy link

@laveena-en @nidhi-nair shall I proceed with PR

@sondermanish
Copy link
Contributor

@shanid544 Thanks for showing interest in contributing to the appsmith. We would be thrilled to facilitate you in making your contribution. Let me first verify the solution and then can help you out with the right steps?
Thanks again @shanid544 !!

@shanid544
Copy link

@sondermanish Please Verify and let me know.Thanks

@shanid544
Copy link

shanid544 commented Nov 6, 2024

@sondermanish Could you please review this approach

@sondermanish
Copy link
Contributor

@shanid544 please proceed with your pr, the changes would do. Thanks again for taking the time to contribute to Appsmith!

@shanid544 shanid544 linked a pull request Nov 8, 2024 that will close this issue
2 tasks
@shanid544
Copy link

@sondermanish Could you please review this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Git Platform Pod Issues related to the git & the app platform Git Product Issues related to version control product High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage Production
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants