-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Adding logging mechanism to find out context of redis git locks (
#33895) ## Description - Introduction of context to redis file locks for git operations. Now the lock would be aware of what command has placed the it. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Git" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9318823149> > Commit: 278716d > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9318823149&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No
- Loading branch information
1 parent
eb0c13d
commit 8b9406b
Showing
16 changed files
with
157 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 26 additions & 7 deletions
33
app/server/appsmith-server/src/main/java/com/appsmith/server/git/GitRedisUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,57 @@ | ||
package com.appsmith.server.git; | ||
|
||
import com.appsmith.external.git.constants.GitSpan; | ||
import com.appsmith.server.exceptions.AppsmithError; | ||
import com.appsmith.server.exceptions.AppsmithException; | ||
import com.appsmith.server.helpers.RedisUtils; | ||
import io.micrometer.observation.ObservationRegistry; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.observability.micrometer.Micrometer; | ||
import reactor.core.publisher.Mono; | ||
import reactor.util.retry.Retry; | ||
|
||
import static com.appsmith.server.helpers.GitUtils.MAX_RETRIES; | ||
import static com.appsmith.server.helpers.GitUtils.RETRY_DELAY; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class GitRedisUtils { | ||
|
||
private final RedisUtils redisUtils; | ||
private final ObservationRegistry observationRegistry; | ||
|
||
public Mono<Boolean> addFileLock(String defaultApplicationId, Boolean isRetryAllowed) { | ||
public Mono<Boolean> addFileLock(String defaultApplicationId, String commandName, Boolean isRetryAllowed) { | ||
long numberOfRetries = Boolean.TRUE.equals(isRetryAllowed) ? MAX_RETRIES : 0L; | ||
|
||
log.info( | ||
"Git command {} is trying to acquire the lock for application id {}", | ||
commandName, | ||
defaultApplicationId); | ||
return redisUtils | ||
.addFileLock(defaultApplicationId) | ||
.addFileLock(defaultApplicationId, commandName) | ||
.retryWhen(Retry.fixedDelay(numberOfRetries, RETRY_DELAY) | ||
.onRetryExhaustedThrow((retryBackoffSpec, retrySignal) -> { | ||
throw new AppsmithException(AppsmithError.GIT_FILE_IN_USE); | ||
})); | ||
if (retrySignal.failure() instanceof AppsmithException) { | ||
throw (AppsmithException) retrySignal.failure(); | ||
} | ||
|
||
throw new AppsmithException(AppsmithError.GIT_FILE_IN_USE, commandName); | ||
})) | ||
.name(GitSpan.ADD_FILE_LOCK) | ||
.tap(Micrometer.observation(observationRegistry)); | ||
} | ||
|
||
public Mono<Boolean> addFileLock(String defaultApplicationId) { | ||
return addFileLock(defaultApplicationId, Boolean.TRUE); | ||
public Mono<Boolean> addFileLock(String defaultApplicationId, String commandName) { | ||
return addFileLock(defaultApplicationId, commandName, true); | ||
} | ||
|
||
public Mono<Boolean> releaseFileLock(String defaultApplicationId) { | ||
return redisUtils.releaseFileLock(defaultApplicationId); | ||
return redisUtils | ||
.releaseFileLock(defaultApplicationId) | ||
.name(GitSpan.RELEASE_FILE_LOCK) | ||
.tap(Micrometer.observation(observationRegistry)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.