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

Followup to pinned Issues #24945

Merged
merged 6 commits into from
May 30, 2023
Merged

Followup to pinned Issues #24945

merged 6 commits into from
May 30, 2023

Conversation

JakobDev
Copy link
Contributor

This addressees some things from #24406 that came up after the PR was merged. Mostly from @delvh.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 26, 2023
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 26, 2023
@silverwind
Copy link
Member

Test failure unrelated.

Copy link
Member

@silverwind silverwind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unpin works now for me.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 26, 2023
models/issues/issue.go Outdated Show resolved Hide resolved
web_src/css/repo.css Outdated Show resolved Hide resolved
@techknowlogick techknowlogick added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label May 26, 2023
@silverwind
Copy link
Member

silverwind commented May 27, 2023

The TestAPIListPinnedIssues failure is now showing on other PRs as well, so it's definitely a flaky test:

https://github.com/go-gitea/gitea/actions/runs/5098326031/jobs/9165402897?pr=24948

@JakobDev can you check it? If you think you can not fix it, please skip the test on CI. We can not tolerate flaky tests.

router: completed POST /api/v1/repos/user2/repo1/issues/3/pin?token=707257d4850c020f16fee26af4032734a2d96761 for test-mock:12345, 204 No Content in 126.3ms @ repo/issue_pin.go:16(repo.PinIssue)
    testlogger.go:60: 2023/05/27 10:33:47 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/repos/user2/repo1/issues/pinned for test-mock:12345, 200 OK in 6.0ms @ repo/issue_pin.go:175(repo.ListPinnedIssues)
    api_issue_pin_test.go:170: 
        	Error Trace:	/home/runner/work/gitea/gitea/tests/integration/api_issue_pin_test.go:170
        	Error:      	Not equal: 
        	            	expected: 1
        	            	actual  : 0
        	Test:       	TestAPIListPinnedIssues
panic: runtime error: index out of range [0] with length 0 [recovered]
	panic: runtime error: index out of range [0] with length 0

@silverwind silverwind added this to the 1.20.0 milestone May 27, 2023
@silverwind
Copy link
Member

I've seen this TestAPIListPinnedIssues failure a few times now, it seems like every other CI run fails with it, definitely a important issue currently.

@JakobDev
Copy link
Contributor Author

Is there any Way to cause this failure replaceable?

@silverwind
Copy link
Member

silverwind commented May 27, 2023

Is there any Way to cause this failure replaceable?

If you can run integration locally (I personally have not figured it out yet how to), try running it a few hundret times, maybe while creating a bit of load in the background:

while true; do GITEA_CONF=tests/sqlite.ini go test -tags sqlite,sqlite_unlock_notify -count=1 -run TestAPIListPinnedIssues ./tests/integration done

Otherwise, try adding some debug prints here maybe and run it on the CI.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented May 28, 2023

About CI failure, I guess it's caused by this line:

issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{RepoID: repo.ID})

Sometimes you get a plain issue, sometimes you get a PR issue (IsPullRequest=true), database doesn't guarantee the result's order if the query is only "SELECT" without "ORDER BY"

-> Test query must have order by explicilty to avoid unstable results #24963


And I can see there are also some (unrelated to the failure) bugs in old code, eg: return is missing for these ctx.Error. Similar mistakes happen quite frequently in many PRs, that's why I suggested #24120 but it seems not getting enough interest. Maybe it needs to mention more maintainers to take a look.

	// If we don't do this, it will crash when trying to add the unpin event to the comment history
	err = issue.LoadRepo(ctx)
	if err != nil {
		ctx.Error(http.StatusInternalServerError, "LoadRepo", err)
		// FIXME: return here
	}

	err = issue.Unpin(ctx, ctx.Doer)
	if err != nil {
		ctx.Error(http.StatusInternalServerError, "UnpinIssue", err)
		// FIXME: return here
	}

	ctx.Status(http.StatusNoContent)

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 28, 2023
@JakobDev
Copy link
Contributor Author

It is really weird, that the test suite gives IsPull a random value if you don't set it. I have now ut explicit to false. Let's see if that fixes the Problem.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented May 28, 2023

It is really weird, that the test suite gives IsPull a random value if you don't set it. I have now ut explicit to false. Let's see if that fixes the Problem.

See my comment above, there are more than one issue records for issues_model.Issue{RepoID: repo.ID} in database, some of them are plain issues, some of them are PR issues.

Sometimes you get a plain issue, sometimes you get a PR issue (IsPullRequest=true), database doesn't guarantee the result's order if the query is only "SELECT" without "ORDER BY"
-> Test query must have order by explicilty to avoid unstable results #24963

#24963 will fix this problem for all tests, including this TestAPIListPinnedIssues

Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Two nits:

  • log.Error(err.Error()) could be improved to log.Error("{detailed message}: %v", err), to provide more useful information in log.
    • And log.Error(userString) is not right in some cases, if there is a % in userString, it breaks the formatter.
  • , IsPull: false could be reverted to before, because by default IsPull is false, this statement is a no-op.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 29, 2023
Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I had to guess, there are still some routes that don't handle the case "issue cannot pinned as too many are pinned" correctly.
Either way, I can accept this PR as it is now.

@silverwind
Copy link
Member

Need to run make fmt.

@JakobDev
Copy link
Contributor Author

All requested changes have been done!

Need to run make fmt.

Why do I forget this so often?

@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 30, 2023
@silverwind silverwind enabled auto-merge (squash) May 30, 2023 14:56
@silverwind silverwind merged commit 1b11529 into go-gitea:main May 30, 2023
20 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 30, 2023
@JakobDev JakobDev deleted the pinfix branch May 30, 2023 15:32
zjjhot added a commit to zjjhot/gitea that referenced this pull request May 31, 2023
* upstream/main:
  Remove the service worker (go-gitea#25010)
  Add user level action runners (go-gitea#24995)
  Update github.com/google/go-github to v52 (go-gitea#24004)
  various style fixes (go-gitea#25008)
  Add show timestamp/seconds and fullscreen options to action page (go-gitea#24876)
  Fix markdown link to awesome gitea (go-gitea#25009)
  Followup to pinned Issues (go-gitea#24945)
  revert the removed method to fix tmpl break on graph page (go-gitea#25005)
  Refactor diffFileInfo / DiffTreeStore  (go-gitea#24998)
  Fix delete user account modal (go-gitea#25004)
  Clean up github actions (go-gitea#24984)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants