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

Use an abstract lock layer to allow distributed lock between multiple Gitea instances #26486

Closed
wants to merge 6 commits into from

Conversation

lunny
Copy link
Member

@lunny lunny commented Aug 14, 2023

Fix #19620
Replace #22176

@lunny lunny added the type/enhancement An improvement of existing functionality label Aug 14, 2023
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 14, 2023
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Aug 14, 2023
Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am absolutely not a fan of the variable naming in this PR.

custom/conf/app.example.ini Outdated Show resolved Hide resolved
docs/content/administration/config-cheat-sheet.en-us.md Outdated Show resolved Hide resolved
@@ -1395,6 +1395,11 @@ However, later updates removed those options, and now the only options are `gith
However, if you want to use actions from other git server, you can use a complete URL in `uses` field, it's supported by Gitea (but not GitHub).
Like `uses: https://gitea.com/actions/checkout@v3` or `uses: http://your-git-server/actions/checkout@v3`.

## Sync (`sync`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a small description of what this section does would be useful.
Sync is such a universal term that it could mean anything, i.e. "PR reloading settings", "syncs with external mirrors", …
Perhaps we even need to think about renaming this section.

Copy link
Contributor

@harryzcy harryzcy Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we just call it lock here, or maybe cluster

modules/setting/sync.go Outdated Show resolved Hide resolved
services/cron/tasks.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 14, 2023
func newRedisLockService(connection string) *redisLockService {
client := nosql.GetManager().GetRedisClient(connection)

pool := goredis.NewPool(client) // or, pool := redigo.NewPool(...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the comment necessary

}
defer func() {
if _, err := lock.Unlock(); err != nil {
log.Error("lock.Unlock: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we want to move the log to inside redisLockService, this "lock.Unlock" doesn't really provide information specific to this function, and then we can just defer lock.Unlock() here

}
defer func() {
_, err := lock.Unlock()
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_, err := lock.Unlock(); err != nil {

@@ -1395,6 +1395,11 @@ However, later updates removed those options, and now the only options are `gith
However, if you want to use actions from other git server, you can use a complete URL in `uses` field, it's supported by Gitea (but not GitHub).
Like `uses: https://gitea.com/actions/checkout@v3` or `uses: http://your-git-server/actions/checkout@v3`.

## Sync (`sync`)
Copy link
Contributor

@harryzcy harryzcy Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we just call it lock here, or maybe cluster

## Sync (`sync`)

- `LOCK_SERVICE_TYPE`: **memory**: Lock service type, could be `memory` or `redis`
- `LOCK_SERVICE_CONN_STR`: **\<empty\>**: Ignored when `LOCK_SERVICE_TYPE` is `memory`. For `redis` use something like `redis://127.0.0.1:6379/0`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is different from test, which is addrs=127.0.0.1:6379 db=0

@lunny
Copy link
Member Author

lunny commented Aug 19, 2024

@delvh @harryzcy please review #31813

lafriks pushed a commit that referenced this pull request Sep 6, 2024
… between multiple Gitea instances (#31813)

Replace #26486 
Fix #19620

---------

Co-authored-by: Jason Song <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replace sync module
4 participants