mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	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. I've applied necessary changes that takes batch length from below config (app.ini) ``` [queue.code_indexer] BATCH_LENGTH=<length_int> ``` and batches all requests to Elasticsearch in chunks as configured in the above config
This commit is contained in:
		@@ -180,11 +180,17 @@ func (b *Indexer) Index(ctx context.Context, repo *repo_model.Repository, sha st
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(reqs) > 0 {
 | 
						if len(reqs) > 0 {
 | 
				
			||||||
		_, err := b.inner.Client.Bulk().
 | 
							esBatchSize := 50
 | 
				
			||||||
			Index(b.inner.VersionedIndexName()).
 | 
					
 | 
				
			||||||
			Add(reqs...).
 | 
							for i := 0; i < len(reqs); i += esBatchSize {
 | 
				
			||||||
			Do(ctx)
 | 
								_, err := b.inner.Client.Bulk().
 | 
				
			||||||
		return err
 | 
									Index(b.inner.VersionedIndexName()).
 | 
				
			||||||
 | 
									Add(reqs[i:min(i+esBatchSize, len(reqs))]...).
 | 
				
			||||||
 | 
									Do(ctx)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user