mirror of
https://github.com/go-gitea/gitea
synced 2024-12-25 20:54:50 +01:00
Backport #29062 by @inferno-umar Fix for gitea putting everything into one request without batching and sending it to Elasticsearch for indexing as issued in #28117 This issue occured in large repositories while Gitea tries to index the code using ElasticSearch. Co-authored-by: dark-angel <70754989+inferno-umar@users.noreply.github.com>
This commit is contained in:
parent
7ed79b748f
commit
f0d34cd3b9
1 changed files with 11 additions and 5 deletions
|
@ -180,12 +180,18 @@ func (b *Indexer) Index(ctx context.Context, repo *repo_model.Repository, sha st
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(reqs) > 0 {
|
if len(reqs) > 0 {
|
||||||
|
esBatchSize := 50
|
||||||
|
|
||||||
|
for i := 0; i < len(reqs); i += esBatchSize {
|
||||||
_, err := b.inner.Client.Bulk().
|
_, err := b.inner.Client.Bulk().
|
||||||
Index(b.inner.VersionedIndexName()).
|
Index(b.inner.VersionedIndexName()).
|
||||||
Add(reqs...).
|
Add(reqs[i:min(i+esBatchSize, len(reqs))]...).
|
||||||
Do(ctx)
|
Do(ctx)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue