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

CSAF upload: trying to insert the same organization #1035

Closed
helio-frota opened this issue Nov 21, 2024 · 2 comments
Closed

CSAF upload: trying to insert the same organization #1035

helio-frota opened this issue Nov 21, 2024 · 2 comments

Comments

@helio-frota
Copy link
Collaborator

helio-frota commented Nov 21, 2024

When trying to upload 296 files via UI we can see the following warning:

2024-11-21T13:34:19.509831Z  WARN ThreadId(36) ingest:load:load:ingest_advisory:ingest_organization:get_organization_by_name:
 sqlx::query: slow statement: execution time exceeded alert threshold 
summary="SELECT \"organization\".\"id\", \"organization\".\"name\", \"organization\".\"cpe_key\", …" 
db.statement="\n\nSELECT\n  \"organization\".\"id\",\n  \"organization\".\"name\",\n  \"organization\".\"cpe_key\",\n  \"organization\".\"website\"\nFROM\n  \"organization\"\nWHERE\n  \"organization\".\"name\" = $1\nLIMIT\n  $2 FOR NO KEY\nUPDATE\n" 
rows_affected=0 rows_returned=1 elapsed=47.105131917s elapsed_secs=47.105131917 slow_threshold=1s format=Advisory labels=Labels(

Then when adding an index for org name, we can fix this warning above but we end up with, trying to insert the same organization again.

@helio-frota helio-frota changed the title CSAF ingestion: Some part of the code is trying to insert the same organization CSAF upload: Some part of the code is trying to insert the same organization Nov 21, 2024
@helio-frota helio-frota changed the title CSAF upload: Some part of the code is trying to insert the same organization CSAF upload: trying to insert the same organization Nov 21, 2024
@ctron
Copy link
Contributor

ctron commented Nov 21, 2024

I guess this is one of your "get or insert" patterns. It might make sense to turn this into an "upsert" statement.

@helio-frota
Copy link
Collaborator Author

I think that makes sense to close and keep the focus on #999

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants