trustification / trustify

Apache License 2.0
10 stars 19 forks source link

Ensure vulnerability.identifier is unique. #473

Closed bobmcwhirter closed 3 months ago

bobmcwhirter commented 3 months ago

Add an EXCLUSIVE lock while ingesting vuln identifiers to prevent us from getting into an error state neeedlessly.

Fixes #471

ctron commented 3 months ago

Hm, that feels a bit drastic. Maybe necessary. Maybe there's a way to transform this indeed into an upsert, which should achieve the same? Anyway, I defer to @JimFuller-RedHat when it comes to DB stuff like that.

JimFuller-RedHat commented 3 months ago

As long as the ORM produces something like the following sql:

ALTER TABLE your_table ADD CONSTRAINT constraint_name UNIQUE (your_column);

that adds a unique constraint on the column ... we should be good.

Agree with @ctron eg. would reccommend to avoid explicitly exclusive locking of the table ... this can cause all sorts of surprising performance issues in read/write scenarios - pg, by default, handles locking at various levels and should just 'do the right thing' with the defined unique constraint.

bobmcwhirter commented 3 months ago

Wrong solution.