Skip to content
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

branch does not exist #28056

Closed
AuspeXeu opened this issue Nov 14, 2023 · 7 comments · Fixed by #28361
Closed

branch does not exist #28056

AuspeXeu opened this issue Nov 14, 2023 · 7 comments · Fixed by #28361
Assignees
Labels
issue/workaround it is or has a workaround type/bug

Comments

@AuspeXeu
Copy link

AuspeXeu commented Nov 14, 2023

Description

2023/11/14 18:18:16 ...s/web/repo/branch.go:58:Branches() [E] LoadBranches: branch does not exist [repo_id: 158 name: master]
2023/11/14 18:18:58 ...s/web/repo/branch.go:58:Branches() [E] LoadBranches: branch does not exist [repo_id: 158 name: master]

Only shows 1 but I have 2 branches in the repo, one of which is called master.

image

Gitea Version

1.21.0

@lunny
Copy link
Member

lunny commented Nov 15, 2023

Please run sync branches on admin panel as a workaround.

@lunny lunny added the issue/workaround it is or has a workaround label Nov 15, 2023
@AuspeXeu
Copy link
Author

That worked. Thanks.

@yinheli
Copy link

yinheli commented Nov 16, 2023

Thanks, It works

@chnorton
Copy link

Is there any information on what the cause of this is? Appreciate that there's a workaround when it happens, but it's pretty concerning that information is just being lost from the database.

@lunny
Copy link
Member

lunny commented Nov 29, 2023

I think it's a bug. It's possible after the upgrade, user haven't visit the repository UI but push something first. The pushupdate functions haven't check and do a sync and directly add a new branch, then the sync will never be triggered.

@lunny lunny self-assigned this Nov 29, 2023
lunny added a commit that referenced this issue Dec 9, 2023
Fix #28056 

This PR will check whether the repo has zero branch when pushing a
branch. If that, it means this repository hasn't been synced.

The reason caused that is after user upgrade from v1.20 -> v1.21, he
just push branches without visit the repository user interface. Because
all repositories routers will check whether a branches sync is necessary
but push has not such check.

For every repository, it has two states, synced or not synced. If there
is zero branch for a repository, then it will be assumed as non-sync
state. Otherwise, it's synced state. So if we think it's synced, we just
need to update branch/insert new branch. Otherwise do a full sync. So
that, for every push, there will be almost no extra load added. It's
high performance than yours.

For the implementation, we in fact will try to update the branch first,
if updated success with affect records > 0, then all are done. Because
that means the branch has been in the database. If no record is
affected, that means the branch does not exist in database. So there are
two possibilities. One is this is a new branch, then we just need to
insert the record. Another is the branches haven't been synced, then we
need to sync all the branches into database.
lunny added a commit to lunny/gitea that referenced this issue Dec 9, 2023
Fix go-gitea#28056

This PR will check whether the repo has zero branch when pushing a
branch. If that, it means this repository hasn't been synced.

The reason caused that is after user upgrade from v1.20 -> v1.21, he
just push branches without visit the repository user interface. Because
all repositories routers will check whether a branches sync is necessary
but push has not such check.

For every repository, it has two states, synced or not synced. If there
is zero branch for a repository, then it will be assumed as non-sync
state. Otherwise, it's synced state. So if we think it's synced, we just
need to update branch/insert new branch. Otherwise do a full sync. So
that, for every push, there will be almost no extra load added. It's
high performance than yours.

For the implementation, we in fact will try to update the branch first,
if updated success with affect records > 0, then all are done. Because
that means the branch has been in the database. If no record is
affected, that means the branch does not exist in database. So there are
two possibilities. One is this is a new branch, then we just need to
insert the record. Another is the branches haven't been synced, then we
need to sync all the branches into database.
lunny added a commit that referenced this issue Dec 11, 2023
Fix #28056
Backport #28361 

This PR will check whether the repo has zero branch when pushing a
branch. If that, it means this repository hasn't been synced.

The reason caused that is after user upgrade from v1.20 -> v1.21, he
just push branches without visit the repository user interface. Because
all repositories routers will check whether a branches sync is necessary
but push has not such check.

For every repository, it has two states, synced or not synced. If there
is zero branch for a repository, then it will be assumed as non-sync
state. Otherwise, it's synced state. So if we think it's synced, we just
need to update branch/insert new branch. Otherwise do a full sync. So
that, for every push, there will be almost no extra load added. It's
high performance than yours.

For the implementation, we in fact will try to update the branch first,
if updated success with affect records > 0, then all are done. Because
that means the branch has been in the database. If no record is
affected, that means the branch does not exist in database. So there are
two possibilities. One is this is a new branch, then we just need to
insert the record. Another is the branches haven't been synced, then we
need to sync all the branches into database.
@dongfo
Copy link

dongfo commented Jan 8, 2024

how to fix lost data?

@lunny
Copy link
Member

lunny commented Jan 8, 2024

how to fix lost data?

#28056 (comment)

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jan 8, 2024
fuxiaohei pushed a commit to fuxiaohei/gitea that referenced this issue Jan 17, 2024
Fix go-gitea#28056 

This PR will check whether the repo has zero branch when pushing a
branch. If that, it means this repository hasn't been synced.

The reason caused that is after user upgrade from v1.20 -> v1.21, he
just push branches without visit the repository user interface. Because
all repositories routers will check whether a branches sync is necessary
but push has not such check.

For every repository, it has two states, synced or not synced. If there
is zero branch for a repository, then it will be assumed as non-sync
state. Otherwise, it's synced state. So if we think it's synced, we just
need to update branch/insert new branch. Otherwise do a full sync. So
that, for every push, there will be almost no extra load added. It's
high performance than yours.

For the implementation, we in fact will try to update the branch first,
if updated success with affect records > 0, then all are done. Because
that means the branch has been in the database. If no record is
affected, that means the branch does not exist in database. So there are
two possibilities. One is this is a new branch, then we just need to
insert the record. Another is the branches haven't been synced, then we
need to sync all the branches into database.
silverwind pushed a commit to silverwind/gitea that referenced this issue Feb 20, 2024
Fix go-gitea#28056 

This PR will check whether the repo has zero branch when pushing a
branch. If that, it means this repository hasn't been synced.

The reason caused that is after user upgrade from v1.20 -> v1.21, he
just push branches without visit the repository user interface. Because
all repositories routers will check whether a branches sync is necessary
but push has not such check.

For every repository, it has two states, synced or not synced. If there
is zero branch for a repository, then it will be assumed as non-sync
state. Otherwise, it's synced state. So if we think it's synced, we just
need to update branch/insert new branch. Otherwise do a full sync. So
that, for every push, there will be almost no extra load added. It's
high performance than yours.

For the implementation, we in fact will try to update the branch first,
if updated success with affect records > 0, then all are done. Because
that means the branch has been in the database. If no record is
affected, that means the branch does not exist in database. So there are
two possibilities. One is this is a new branch, then we just need to
insert the record. Another is the branches haven't been synced, then we
need to sync all the branches into database.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/workaround it is or has a workaround type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants