From 20a4437a078309864db9a0fad8a0f4c81b6059a4 Mon Sep 17 00:00:00 2001 From: ldelossa Date: Thu, 4 Feb 2021 18:15:51 -0500 Subject: [PATCH] vulnstore: fix gc live lock the previous query took an absurd amount of time to complete. updated with a more performant query. Signed-off-by: ldelossa --- cmd/libvulnhttp/main.go | 4 ++++ internal/vulnstore/postgres/store.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/libvulnhttp/main.go b/cmd/libvulnhttp/main.go index 20b2f18dc..e87d8b06c 100644 --- a/cmd/libvulnhttp/main.go +++ b/cmd/libvulnhttp/main.go @@ -6,6 +6,7 @@ import ( "net/http" "os" "strings" + "time" "github.com/crgimenes/goconfig" "github.com/quay/zlog" @@ -81,6 +82,9 @@ func confToLibvulnOpts(conf Config) *libvuln.Opts { Migrations: true, UpdaterSets: nil, DisableBackgroundUpdates: conf.DisableBackgroundUpdates, + UpdateInterval: 30 * time.Second, + UpdateWorkers: 10, + UpdateRetention: 10, } return opts diff --git a/internal/vulnstore/postgres/store.go b/internal/vulnstore/postgres/store.go index 9ede73319..9dd3ba340 100644 --- a/internal/vulnstore/postgres/store.go +++ b/internal/vulnstore/postgres/store.go @@ -105,7 +105,7 @@ WHERE array_length(ordered_ops.refs, 1) > $2; ` deleteVulns = ` -DELETE FROM vuln WHERE id NOT IN (SELECT vuln FROM uo_vuln); +DELETE FROM vuln WHERE NOT EXISTS (SELECT * FROM uo_vuln WHERE vuln.id = uo_vuln.vuln); ` )