-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Maven Deploy Issue - Unique Constraint Error #30171
Comments
I can reproduce a different unique constraint error (
with this test file:
The test is based on
Hope this helps! |
Created a PR #30335 and put your tests there. |
We observed the same or similar bug when migrating several TB of Maven artifacts to a Gitea Maven repository. We now have many packages that cannot be deleted, because the corresponding (S3?) BLOB cannot be found. |
Hello! BR, PS: I also had to fix the test since it could have uploaded the same package twice, but it expected it to upload only once. (go routine variable capture issue) |
@lunny : Do you think you code works with the updated test? |
My code doesn't work for now because I think the table package_property needs some changes. |
@tlusser your proposed hotfix helped, but I found out another problem that was not yet solved when pushing a high amount of submodules with a single mvn deploy. Maven does uploads in parallel. When a POM and a JAR are uploaded for the same new version at the same point in time, it can happen that the package_version contains the string 'null' in metadata_json. This makes the package_version unusable and returns error 500 for queries of the API or UI.
As you can see, created_unix is the same. I could identify the problem and extend your hotfix to cover it. There's a race condition in UploadPackageFile. The assumption of the original author is that mavendata_json is set during a POM file upload for an existing version or if the POM file is the first upload to the new version at createPackageAndVersion. This fixed the issue for us. |
For everybody who needs this quick fix please see tlusser@fb925d1 |
So we don't have a fix included in 1.22.1? My fix could be improved to base the mutex on the package version that is going to be created in the db. That would not slow down other maven uploads which are creating different package versions. |
I think we can send a PR to have a lock based on |
Thank you for providing a fix in next bugfix release. Will you also include checks in doctor command to clean invalid data out of the database? |
As I know, only the table |
Hello, Are you sure, that there can not be any issues? |
Fixed by #31954 |
Description
We believe that we've found a concurrency bug when doing maven deploys. Depending on network latency or some other factors,
mvn deploy
may succeed or fail (500 internal server error, see log below). Our project consists of three files:It seems to us that these files are uploaded in parallel which causes a unique constraint violation in our Postgres database when working with the
package_versions
table. We couldn't find any maven configuration where we could manipulate maven's upload/deploy behavior, so we currently are in a position where we can't circumvent the problem. We also tried to change Postgres' default isolation level from read_commited to serializable, but doing so causes a different 500 internal server error.journalctl:
After the failed upload, opening the artifact page throws another 500 which is caused by a nil pointer error (see screenshot).
Gitea Version
1.21.10
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
Git Version
No response
Operating System
Debian GNU/Linux 12 (bookworm)
How are you running Gitea?
We are using the official binary (manually downloaded) on a self hosted Debian server using systemd
Database
PostgreSQL
The text was updated successfully, but these errors were encountered: