From df37f2a8102995800f6bdc3fc2238f8d9a744bf3 Mon Sep 17 00:00:00 2001 From: Joseph Crosland Date: Tue, 5 Jul 2022 11:40:52 -0700 Subject: [PATCH] updates: Use the tx's methods to record updater's status (#647) This change makes sure all calls to modify the updater_status table go through the transaction's connection instead of attempting to acquire another one. Signed-off-by: crozzy --- internal/vulnstore/postgres/recordupdatetime.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/vulnstore/postgres/recordupdatetime.go b/internal/vulnstore/postgres/recordupdatetime.go index 72d8f761d..2af9f4582 100644 --- a/internal/vulnstore/postgres/recordupdatetime.go +++ b/internal/vulnstore/postgres/recordupdatetime.go @@ -72,7 +72,7 @@ func recordUpdaterStatus(ctx context.Context, pool *pgxpool.Pool, updaterName st zlog.Debug(ctx). Str("updater", updaterName). Msg("recording successful update") - _, err := pool.Exec(ctx, upsertSuccessfulUpdate, updaterName, updateTime, fingerprint) + _, err := tx.Exec(ctx, upsertSuccessfulUpdate, updaterName, updateTime, fingerprint) if err != nil { return fmt.Errorf("failed to upsert successful updater status: %w", err) } @@ -80,7 +80,7 @@ func recordUpdaterStatus(ctx context.Context, pool *pgxpool.Pool, updaterName st zlog.Debug(ctx). Str("updater", updaterName). Msg("recording failed update") - if err := pool.QueryRow(ctx, upsertFailedUpdate, updaterName, updateTime, fingerprint, updaterError.Error()).Scan(&returnedUpdaterName); err != nil { + if err := tx.QueryRow(ctx, upsertFailedUpdate, updaterName, updateTime, fingerprint, updaterError.Error()).Scan(&returnedUpdaterName); err != nil { return fmt.Errorf("failed to upsert failed updater status: %w", err) } } @@ -117,7 +117,7 @@ func recordUpdaterSetStatus(ctx context.Context, pool *pgxpool.Pool, updaterSet } defer tx.Rollback(ctx) - tag, err := pool.Exec(ctx, update, updateTime, updaterSet) + tag, err := tx.Exec(ctx, update, updateTime, updaterSet) if err != nil { return fmt.Errorf("failed to update updater statuses for updater set %s: %w", updaterSet, err) }