Skip to content

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

@ghost

Description

  • 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

Activity

zeripath

zeripath commented on Apr 9, 2021

@zeripath
Contributor
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.

ghost

ghost commented on Apr 10, 2021

@ghost

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 changed the title [-]REPO_INDEXER won't index mirrored repository, even if the NotifySyncPushCommits is called[/-] [+]REPO_INDEXER won't index mirrored repository[/+] on Apr 10, 2021
ghost

ghost commented on Apr 10, 2021

@ghost

@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 changed the title [-]REPO_INDEXER won't index mirrored repository[/-] [+][BUG] REPO_INDEXER won't index mirrored repository after sync[/+] on Apr 10, 2021
ghost

ghost commented on Apr 26, 2021

@ghost

@zeripath Same on v1.14.1

ghost

ghost commented on May 13, 2021

@ghost

Same with v1.14.2

lflare

lflare commented on Feb 22, 2023

@lflare
Contributor

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.

added a commit that references this issue on May 26, 2023
f9cfd6c
locked as resolved and limited conversation to collaborators on Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @zeripath@noerw@lflare

      Issue actions

        [BUG] REPO_INDEXER won't index mirrored repository after sync · Issue #15367 · go-gitea/gitea