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 race condition in doesProjectExist #601

Merged
merged 2 commits into from
Feb 29, 2024
Merged

Fix race condition in doesProjectExist #601

merged 2 commits into from
Feb 29, 2024

Conversation

nscuro
Copy link
Member

@nscuro nscuro commented Feb 28, 2024

Description

Fixes race condition in doesProjectExist by enforcing uniqueness as database constraints, instead of trying to do it in the application code.

Addressed Issue

Fixes DependencyTrack/hyades#1101

Additional Details

This bug affects DT v4.x as well, but because we can't create partial indexes there (DataNucleus doesn't give us that much control), we can't really fix it.

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have added corresponding update logic
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

@nscuro nscuro added the defect Something isn't working label Feb 28, 2024
@nscuro nscuro added this to the 5.4.0 milestone Feb 28, 2024
@nscuro nscuro marked this pull request as draft February 28, 2024 12:20
@nscuro nscuro marked this pull request as ready for review February 28, 2024 12:47
VithikaS
VithikaS previously approved these changes Feb 28, 2024
VithikaS
VithikaS previously approved these changes Feb 29, 2024
... by enforcing uniqueness as database constraints, instead of trying to do it in the application code.

This bug affects DT v4.x as well, but because we can't create partial indexes there (DataNucleus doesn't give us that much control), we can't really fix it.

Fixes DependencyTrack/hyades#1101

Signed-off-by: nscuro <[email protected]>
Tests made bad assumptions about duplicate projects being allowed.

Also, remove `JdbiTestUtil` which was only necessary to run JDBI tests with H2. Since we dropped H2, this is no longer required.

Signed-off-by: nscuro <[email protected]>
@nscuro nscuro merged commit 330b793 into main Feb 29, 2024
6 checks passed
@nscuro nscuro deleted the issue-1101 branch February 29, 2024 15:57
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
defect Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition in doesProjectExist can cause duplicate projects to be created
2 participants