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

Fix bugs when concurrent pushing packages #30335

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

lunny
Copy link
Member

@lunny lunny commented Apr 8, 2024

Fix #30171

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 8, 2024
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 8, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Apr 8, 2024
@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 Apr 8, 2024
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 11, 2024
@lunny
Copy link
Member Author

lunny commented Apr 12, 2024

I encountered a probelm which mentioned in https://github.com/go-gitea/gitea/pull/16510/files#r836054699 . Since there is no unique keys on package_property, it's difficult to know whether we need insert or update them.

defer tests.PrintCurrentTest(t)()

var wg sync.WaitGroup
for i := 0; i < 10; i++ {
Copy link

@tlusser tlusser Apr 16, 2024

Choose a reason for hiding this comment

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

I think this test is not correct - it should look like:
`

	for i := 0; i < 10; i++ {
		wg.Add(1)
		go func(i int) {
			putFile(t, fmt.Sprintf("/%s/%s.jar", packageVersion, strconv.Itoa(i)), "test", http.StatusCreated)
			wg.Done()
		}(i)
	}

`

return nil, err
}
case setting.Database.Type.IsPostgreSQL(), setting.Database.Type.IsSQLite3():
if _, err := db.GetEngine(ctx).Exec("INSERT INTO package (owner_id,`type`,lower_name,name,semver_compatible) VALUES (?,?,?,?,?) ON CONFLICT (owner_id,`type`,lower_name) DO UPDATE SET lower_name=lower_name",
Copy link

Choose a reason for hiding this comment

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

I think this line should look like:
"INSERT INTO package (owner_id,type,lower_name,name,semver_compatible) VALUES (?,?,?,?,?) ON CONFLICT (owner_id,type,lower_name) DO UPDATE SET lower_name=EXCLUDED.lower_name"

@lunny lunny changed the title Add integration test for concurrent maven deploy Fix bugs when concurrent pushing packages May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maven Deploy Issue - Unique Constraint Error
4 participants