-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Move all push update operations to a queue #10133
Move all push update operations to a queue #10133
Conversation
} | ||
|
||
func initPushQueue() error { | ||
pushQueue = queue.CreateQueue("push_update", handle, []*PushUpdateOptions{}).(queue.Queue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are defaults that maybe we should want to change, here. Like BATCH_LENGTH = 20
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be changed by user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that it might be useful to tailor these defaults. We're currently using the same queue defaults for all queues, but maybe git-centered activity queues could benefit from defaults different than e-mail delivery activity queues, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is wanted specific defaults overrides would be set:
gitea/modules/setting/queue.go
Lines 87 to 163 in e4b3f35
// NewQueueService sets up the default settings for Queues | |
// This is exported for tests to be able to use the queue | |
func NewQueueService() { | |
sec := Cfg.Section("queue") | |
Queue.DataDir = sec.Key("DATADIR").MustString("queues/") | |
if !filepath.IsAbs(Queue.DataDir) { | |
Queue.DataDir = filepath.Join(AppDataPath, Queue.DataDir) | |
} | |
Queue.Length = sec.Key("LENGTH").MustInt(20) | |
Queue.BatchLength = sec.Key("BATCH_LENGTH").MustInt(20) | |
Queue.ConnectionString = sec.Key("CONN_STR").MustString(path.Join(AppDataPath, "")) | |
Queue.Type = sec.Key("TYPE").MustString("persistable-channel") | |
Queue.Network, Queue.Addresses, Queue.Password, Queue.DBIndex, _ = ParseQueueConnStr(Queue.ConnectionString) | |
Queue.WrapIfNecessary = sec.Key("WRAP_IF_NECESSARY").MustBool(true) | |
Queue.MaxAttempts = sec.Key("MAX_ATTEMPTS").MustInt(10) | |
Queue.Timeout = sec.Key("TIMEOUT").MustDuration(GracefulHammerTime + 30*time.Second) | |
Queue.Workers = sec.Key("WORKERS").MustInt(1) | |
Queue.MaxWorkers = sec.Key("MAX_WORKERS").MustInt(10) | |
Queue.BlockTimeout = sec.Key("BLOCK_TIMEOUT").MustDuration(1 * time.Second) | |
Queue.BoostTimeout = sec.Key("BOOST_TIMEOUT").MustDuration(5 * time.Minute) | |
Queue.BoostWorkers = sec.Key("BOOST_WORKERS").MustInt(5) | |
Queue.QueueName = sec.Key("QUEUE_NAME").MustString("_queue") | |
Queue.SetName = sec.Key("SET_NAME").MustString("") | |
// Now handle the old issue_indexer configuration | |
section := Cfg.Section("queue.issue_indexer") | |
sectionMap := map[string]bool{} | |
for _, key := range section.Keys() { | |
sectionMap[key.Name()] = true | |
} | |
if _, ok := sectionMap["TYPE"]; !ok { | |
switch Indexer.IssueQueueType { | |
case LevelQueueType: | |
_, _ = section.NewKey("TYPE", "level") | |
case ChannelQueueType: | |
_, _ = section.NewKey("TYPE", "persistable-channel") | |
case RedisQueueType: | |
_, _ = section.NewKey("TYPE", "redis") | |
default: | |
log.Fatal("Unsupported indexer queue type: %v", | |
Indexer.IssueQueueType) | |
} | |
} | |
if _, ok := sectionMap["LENGTH"]; !ok { | |
_, _ = section.NewKey("LENGTH", fmt.Sprintf("%d", Indexer.UpdateQueueLength)) | |
} | |
if _, ok := sectionMap["BATCH_LENGTH"]; !ok { | |
_, _ = section.NewKey("BATCH_LENGTH", fmt.Sprintf("%d", Indexer.IssueQueueBatchNumber)) | |
} | |
if _, ok := sectionMap["DATADIR"]; !ok { | |
_, _ = section.NewKey("DATADIR", Indexer.IssueQueueDir) | |
} | |
if _, ok := sectionMap["CONN_STR"]; !ok { | |
_, _ = section.NewKey("CONN_STR", Indexer.IssueQueueConnStr) | |
} | |
// Handle the old mailer configuration | |
section = Cfg.Section("queue.mailer") | |
sectionMap = map[string]bool{} | |
for _, key := range section.Keys() { | |
sectionMap[key.Name()] = true | |
} | |
if _, ok := sectionMap["LENGTH"]; !ok { | |
_, _ = section.NewKey("LENGTH", fmt.Sprintf("%d", Cfg.Section("mailer").Key("SEND_BUFFER_LEN").MustInt(100))) | |
} | |
// Handle the old test pull requests configuration | |
// Please note this will be a unique queue | |
section = Cfg.Section("queue.pr_patch_checker") | |
sectionMap = map[string]bool{} | |
for _, key := range section.Keys() { | |
sectionMap[key.Name()] = true | |
} | |
if _, ok := sectionMap["LENGTH"]; !ok { | |
_, _ = section.NewKey("LENGTH", fmt.Sprintf("%d", Repository.PullRequestQueueLength)) | |
} | |
} |
30ae45a
to
558e7ac
Compare
In the new commit of this PR, I added a |
Codecov Report
@@ Coverage Diff @@
## master #10133 +/- ##
==========================================
+ Coverage 43.71% 43.96% +0.25%
==========================================
Files 586 588 +2
Lines 81351 82339 +988
==========================================
+ Hits 35563 36203 +640
- Misses 41393 41703 +310
- Partials 4395 4433 +38
Continue to review full report at Codecov.
|
558e7ac
to
bedfacd
Compare
It's ready to review. |
} | ||
|
||
func initPushQueue() error { | ||
pushQueue = queue.CreateQueue("push_update", handle, []*PushUpdateOptions{}).(queue.Queue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that it might be useful to tailor these defaults. We're currently using the same queue defaults for all queues, but maybe git-centered activity queues could benefit from defaults different than e-mail delivery activity queues, for example.
a9aeaac
to
7492438
Compare
7492438
to
76317f3
Compare
can you resolve conflicts? |
76317f3
to
0317473
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions. |
Conflicts |
0317473
to
8db5483
Compare
0783368
to
3f0a790
Compare
Codecov Report
@@ Coverage Diff @@
## master #10133 +/- ##
==========================================
- Coverage 43.18% 43.16% -0.02%
==========================================
Files 651 652 +1
Lines 72145 72085 -60
==========================================
- Hits 31154 31114 -40
+ Misses 35942 35926 -16
+ Partials 5049 5045 -4
Continue to review full report at Codecov.
|
I'm just unsure, but there is only one removed line, do this code really work 😅 ? If I remember correctly git push things are initialy handled by the HookPreReceive in routers/private/... |
693b0e8
to
6dc2016
Compare
ebf97bb
to
afc655d
Compare
@6543 please review again. |
_, err = git.NewCommand("update-server-info").RunInDir(repoPath) | ||
if err != nil { | ||
return fmt.Errorf("Failed to call 'git update-server-info': %v", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned that this is outdated - update-server-info is only used for dumb HTTP and therefore this should be removed.
It's also running at the wrong time here. If we want to use update-server-info we should be using a git post-update hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then again it appears we do support the info/refs
endpoint ... hmm ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm old code has it too - so I'm ok with it - if this gets problematic I think this can have its own pull
👇 so LGTM from my side :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested works
failed unrelated |
More and more operations will be fired when commits pushed, so move it to a queue is a better way. It will let git clients receive reponse quicker and also, we could add more operations when pushing. i.e. cache big repos, language calculations and etc.