Git Locker issue while discard and pull is fixed#37300
Git Locker issue while discard and pull is fixed#37300shanid544 wants to merge 1 commit intoappsmithorg:releasefrom
Conversation
WalkthroughThe changes in Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java (4)
Line range hint
256-260: Simplify null checks inisBaseGitMetadataInvalidmethodThe null checks for
gitArtifactMetadatacan be simplified for clarity.Consider simplifying the method as:
- return Optional.ofNullable(gitArtifactMetadata).isEmpty() - || Optional.ofNullable(gitArtifactMetadata.getGitAuth()).isEmpty() - || StringUtils.isEmptyOrNull(gitArtifactMetadata.getGitAuth().getPrivateKey()) - || StringUtils.isEmptyOrNull(gitArtifactMetadata.getGitAuth().getPublicKey()); + return gitArtifactMetadata == null + || gitArtifactMetadata.getGitAuth() == null + || StringUtils.isEmptyOrNull(gitArtifactMetadata.getGitAuth().getPrivateKey()) + || StringUtils.isEmptyOrNull(gitArtifactMetadata.getGitAuth().getPublicKey());
Line range hint
970-986: Ensure file locks are always released inmergeBranchIf an error occurs after acquiring the file lock in the
mergeBranchmethod, the lock may not be released, potentially causing deadlocks.Use
doFinallyto ensure the file lock is released regardless of the outcome:.flatMap(tuple -> { // existing code }) -.onErrorResume( - error -> releaseFileLock(baseArtifactId).then(Mono.error(error))); +.doFinally(signalType -> releaseFileLock(baseArtifactId));
Line range hint
313-350: Release file locks in error cases inpullArtifactIn the
pullArtifactmethod, if an error occurs after acquiring the file lock, it may not be released.Modify error handling to ensure the lock is released:
.flatMap(tuple -> { // existing code }) -.name(GitSpan.OPS_PULL) -.tap(Micrometer.observation(observationRegistry)); +.onErrorResume(error -> releaseFileLock(baseArtifact.getGitArtifactMetadata().getDefaultArtifactId()) + .then(Mono.error(error))) +.name(GitSpan.OPS_PULL) +.tap(Micrometer.observation(observationRegistry));
Line range hint
1290-1300: Ensure file locks are released inpushArtifactErrorRecoveryIn
pushArtifactErrorRecovery, the file lock may not be released if an error occurs.Ensure the lock is released in all cases:
return Mono.just(pushResult) + .doFinally(signalType -> releaseFileLock(artifact.getGitArtifactMetadata().getDefaultArtifactId()));
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java(1 hunks)
|
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected. |
|
This PR has been closed because of inactivity. |
Description
When there are uncommitted changes in a Git-connected app, and the user attempts to pull upstream changes, a "Git lock" error appears. This prevents the user from discarding or pulling changes, causing workflow disruptions.
Steps to Reproduce:
Create a git connected app
Create a page and let it stay as an uncommitted change
Make some changes to the application via the remote repo
Try to commit the uncommitted changes from step 2
Notice that git lock error is seen on any discard/pull actions subsequently
Updated Steps to Reproduce:
Create a Git-connected app.
Create a new branch from the main branch.
Create a page with uncommitted changes.
Make additional changes to the app in the remote repository on the same branch.
Attempt to commit the uncommitted changes from Step 3.
Notice the Git lock error when trying to discard or pull changes.
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.
Solution
Call releaseFileLock() from CommonGitServiceCEImpl.java before throwing the GIT_UPSTREAM_CHANGES error.
Fixes #36781
Automation
/ok-to-test tags=""
🔍 Cypress test results
Caution
If you modify the content in this section, you are likely to disrupt the CI result for your PR.
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
New Features
Bug Fixes
Analytics
Refactor