[BUG] REPO_INDEXER won't index mirrored repository after sync #7137

Closed
opened 2025-11-02 07:16:40 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @ghost on GitHub (Apr 9, 2021).

  • Gitea version (or commit ref): 1.13.1
  • Git version: Not relevant
  • Operating system:docker image
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist: Not relevant

Description

REPO_INDEXER won't index mirrored repository after sync

Related: #12380 #11200 #11479 #5329

Originally created by @ghost on GitHub (Apr 9, 2021). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.13.1 - Git version: Not relevant - Operating system:docker image <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - Log gist: Not relevant <!-- It really is important to provide pertinent logs --> <!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems --> <!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini --> ## Description <!-- If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please disable the proxy/CDN fully and connect to gitea directly to confirm the issue still persists without those services. --> REPO_INDEXER won't index mirrored repository after sync Related: #12380 #11200 #11479 #5329
GiteaMirror added the type/bug label 2025-11-02 07:16:40 -06:00
Author
Owner

@zeripath commented on GitHub (Apr 9, 2021):

func (r *indexerNotifier) NotifySyncPushCommits(pusher *models.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
	if setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch {
		code_indexer.UpdateRepoIndexer(repo)
	}
	if err := stats_indexer.UpdateRepoIndexer(repo); err != nil {
		log.Error("stats_indexer.UpdateRepoIndexer(%d) failed: %v", repo.ID, err)
	}
}

It might be that you don't have a default branch set?

Go to the Repository Settings and change/re-set the default branch.

@zeripath commented on GitHub (Apr 9, 2021): ```go func (r *indexerNotifier) NotifySyncPushCommits(pusher *models.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { if setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch { code_indexer.UpdateRepoIndexer(repo) } if err := stats_indexer.UpdateRepoIndexer(repo); err != nil { log.Error("stats_indexer.UpdateRepoIndexer(%d) failed: %v", repo.ID, err) } } ``` It might be that you don't have a default branch set? Go to the Repository Settings and change/re-set the default branch.
Author
Owner

@ghost commented on GitHub (Apr 10, 2021):

I tired resetting the default branch but it doesn't work.

Also I didn't see any error in the logs. I am sure that I have RepoIndexerEnabled, as the code search works for plain repos instead of the mirrored ones.

@ghost commented on GitHub (Apr 10, 2021): I tired resetting the default branch but it doesn't work. Also I didn't see any error in the logs. I am sure that I have RepoIndexerEnabled, as the code search works for plain repos instead of the mirrored ones.
Author
Owner

@ghost commented on GitHub (Apr 10, 2021):

@zeripath

Tired on 1.13.7 with many different mirrored repos, but the problem persists.
Also I tried deleting repos.bleve to rebuild the index. The REPO_INDEXER will properly index the current default branch of the mirrored repo, but it's not going to index new commits after sync

@ghost commented on GitHub (Apr 10, 2021): @zeripath Tired on 1.13.7 with many different mirrored repos, but the problem persists. Also I tried deleting `repos.bleve` to rebuild the index. The REPO_INDEXER will properly index the current default branch of the mirrored repo, but it's not going to index new commits after sync
Author
Owner

@ghost commented on GitHub (Apr 26, 2021):

@zeripath Same on v1.14.1

@ghost commented on GitHub (Apr 26, 2021): @zeripath Same on v1.14.1
Author
Owner

@ghost commented on GitHub (May 13, 2021):

Same with v1.14.2

@ghost commented on GitHub (May 13, 2021): Same with v1.14.2
Author
Owner

@lflare commented on GitHub (Feb 22, 2023):

Just to chime in that I am also noticing this issue on v1.18.5. Default branch is set as well.

I patched the original snippet of code to log out the test variables, in the following, and it seems that opts.RefFullName is not the same between push and sync pull.

func (r *indexerNotifier) NotifyPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
	log.Info("stats_indexer.NotifyPushCommits(%d) RefFullName: %s, BranchPrefix: %s, DefaultBranch: %s", repo.ID, opts.RefFullName, git.BranchPrefix, repo.DefaultBranch)

	if setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch {
		code_indexer.UpdateRepoIndexer(repo)
	}
	if err := stats_indexer.UpdateRepoIndexer(repo); err != nil {
		log.Error("stats_indexer.UpdateRepoIndexer(%d) failed: %v", repo.ID, err)
	}
}

func (r *indexerNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
	log.Info("stats_indexer.NotifySyncPushCommits(%d) RefFullName: %s, BranchPrefix: %s, DefaultBranch: %s", repo.ID, opts.RefFullName, git.BranchPrefix, repo.DefaultBranch)

	if setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch {
		code_indexer.UpdateRepoIndexer(repo)
	}
	if err := stats_indexer.UpdateRepoIndexer(repo); err != nil {
		log.Error("stats_indexer.UpdateRepoIndexer(%d) failed: %v", repo.ID, err)
	}
}

When pushing,

2023/02/22 11:07:06 ...n/indexer/indexer.go:128:NotifyPushCommits() [I] [63f5f75a] stats_indexer.NotifyPushCommits(200) RefFullName: refs/heads/main, BranchPrefix: refs/heads/, DefaultBranch: main

When sync pulling,

2023/02/22 11:06:50 ...n/indexer/indexer.go:139:NotifySyncPushCommits() [I] [63f5f749-17] stats_indexer.NotifySyncPushCommits(199) RefFullName: main, BranchPrefix: refs/heads/, DefaultBranch: main

So clearly the comparison of setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch might need to be modified.

@lflare commented on GitHub (Feb 22, 2023): Just to chime in that I am also noticing this issue on v1.18.5. Default branch is set as well. I patched the original snippet of code to log out the test variables, in the following, and it seems that `opts.RefFullName` is not the same between push and sync pull. ```go func (r *indexerNotifier) NotifyPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { log.Info("stats_indexer.NotifyPushCommits(%d) RefFullName: %s, BranchPrefix: %s, DefaultBranch: %s", repo.ID, opts.RefFullName, git.BranchPrefix, repo.DefaultBranch) if setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch { code_indexer.UpdateRepoIndexer(repo) } if err := stats_indexer.UpdateRepoIndexer(repo); err != nil { log.Error("stats_indexer.UpdateRepoIndexer(%d) failed: %v", repo.ID, err) } } func (r *indexerNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { log.Info("stats_indexer.NotifySyncPushCommits(%d) RefFullName: %s, BranchPrefix: %s, DefaultBranch: %s", repo.ID, opts.RefFullName, git.BranchPrefix, repo.DefaultBranch) if setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch { code_indexer.UpdateRepoIndexer(repo) } if err := stats_indexer.UpdateRepoIndexer(repo); err != nil { log.Error("stats_indexer.UpdateRepoIndexer(%d) failed: %v", repo.ID, err) } } ``` When pushing, ``` 2023/02/22 11:07:06 ...n/indexer/indexer.go:128:NotifyPushCommits() [I] [63f5f75a] stats_indexer.NotifyPushCommits(200) RefFullName: refs/heads/main, BranchPrefix: refs/heads/, DefaultBranch: main ``` When sync pulling, ``` 2023/02/22 11:06:50 ...n/indexer/indexer.go:139:NotifySyncPushCommits() [I] [63f5f749-17] stats_indexer.NotifySyncPushCommits(199) RefFullName: main, BranchPrefix: refs/heads/, DefaultBranch: main ``` So clearly the comparison of `setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch` might need to be modified.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7137