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

Times API breaks after deleting repo containing issues with tracked times #10280

Closed
2 of 7 tasks
bobemoe opened this issue Feb 15, 2020 · 6 comments · Fixed by #11110
Closed
2 of 7 tasks

Times API breaks after deleting repo containing issues with tracked times #10280

bobemoe opened this issue Feb 15, 2020 · 6 comments · Fixed by #11110

Comments

@bobemoe
Copy link
Contributor

bobemoe commented Feb 15, 2020

  • Gitea version (or commit ref): 1.12.0+dev-307-g62a1322cf
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

After deleting a repo the times API has become unusable:

$ curl -X GET "https://bobemoe:[email protected]/api/v1/user/times" -H  "accept: application/json"
{"message":"issue does not exist [id: 9010, repo_id: 0, index: 0]","url":"https://try.gitea.io/api/swagger"}

I've checked the DB and indeed the issue records for the deleted repo have been deleted but there are still records in the tracked_time table that now have a non-existent issue_id:

mysql> select t.*,i.id from tracked_time t left join issue i on t.issue_id=i.id having i.id is null;
+----+----------+---------+--------------+-------+---------+------+
| id | issue_id | user_id | created_unix | time  | deleted | id   |
+----+----------+---------+--------------+-------+---------+------+
|  3 |     1361 |       1 |   1571125831 |  3600 |       0 | NULL |
|  4 |     1361 |       1 |   1571125838 |  1500 |       0 | NULL |
....
@6543
Copy link
Member

6543 commented Feb 16, 2020

so on repoDeletion we have to delete tracked_time too

@stale
Copy link

stale bot commented Apr 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale stale bot added the issue/stale label Apr 17, 2020
@bobemoe
Copy link
Contributor Author

bobemoe commented Apr 17, 2020

Still an issue, confirmed on try.gitea.io

@stale stale bot removed the issue/stale label Apr 17, 2020
@6543
Copy link
Member

6543 commented Apr 17, 2020

I'll have a look at it

@6543
Copy link
Member

6543 commented Apr 17, 2020

ok Idear:

  • fix models.DeleteRepository()
  • add a task to gitea doctor witch check general DB consistency
    (witch can fix DBs witch have already TrackedTimes of deleted repos)

@6543
Copy link
Member

6543 commented Apr 17, 2020

@bobemoe -> #11110 & #11111

zeripath pushed a commit that referenced this issue May 29, 2020
needed to fix issue as described in #10280

* rename check-db to check-db-version
* add check-db-consistency:
* find issues without existing repository
* find pulls without existing issues
* find tracked times without existing issues/pulls
* find labels without repository or org reference

Co-authored-by: guillep2k <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
6543 added a commit to 6543-forks/gitea that referenced this issue May 29, 2020
needed to fix issue as described in go-gitea#10280

* rename check-db to check-db-version
* add check-db-consistency:
* find issues without existing repository
* find pulls without existing issues
* find tracked times without existing issues/pulls
* find labels without repository or org reference

Co-authored-by: guillep2k <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
zeripath pushed a commit that referenced this issue May 29, 2020
Backports the tracked-time fix from #11111 (part of #11111)

Fixes tracked time errors following repo deletion (#10280) and adds the fix to the default doctor tasks
jolheiser pushed a commit that referenced this issue May 29, 2020
needed to fix issue as described in #10280

* rename check-db to check-db-version
* add check-db-consistency:
* find issues without existing repository
* find pulls without existing issues
* find tracked times without existing issues/pulls
* find labels without repository or org reference

Co-authored-by: guillep2k <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>

Co-authored-by: guillep2k <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
ydelafollye pushed a commit to ydelafollye/gitea that referenced this issue Jul 31, 2020
needed to fix issue as described in go-gitea#10280

* rename check-db to check-db-version
* add check-db-consistency:
* find issues without existing repository
* find pulls without existing issues
* find tracked times without existing issues/pulls
* find labels without repository or org reference

Co-authored-by: guillep2k <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants