Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion internal/auth/store_postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,11 @@ func (s *PostgresStore) CreateAdminIfNone(ctx context.Context, user *User) (bool
// Rollback is a no-op after a successful Commit; on any earlier return
// it also releases the advisory lock. Matches the project convention
// (e.g. internal/config/store_postgres.go) for deferred rollback.
defer tx.Rollback(ctx) //nolint:errcheck
defer func() {
if rbErr := tx.Rollback(ctx); rbErr != nil {
_ = rbErr // rollback error intentionally discarded; Postgres logs rollback failures
}
}()

// Serialize against concurrent bootstrap calls and against the
// min-one-admin deferred trigger (see adminInvariantAdvisoryLockKey).
Expand Down
12 changes: 10 additions & 2 deletions internal/config/store_postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -2996,7 +2996,11 @@ func (s *PostgresStore) DeleteCloudAccount(ctx context.Context, id string) error
if err != nil {
return fmt.Errorf("failed to begin transaction: %w", err)
}
defer tx.Rollback(ctx) //nolint:errcheck
defer func() {
if rbErr := tx.Rollback(ctx); rbErr != nil {
_ = rbErr // rollback error intentionally discarded; Postgres logs rollback failures
}
}()

// Reset any linked approved registration first (explicit NULL so we don't
// rely on the FK's ON DELETE SET NULL behavior).
Expand Down Expand Up @@ -3304,7 +3308,11 @@ func (s *PostgresStore) SetPlanAccounts(ctx context.Context, planID string, acco
if err != nil {
return fmt.Errorf("failed to begin transaction: %w", err)
}
defer tx.Rollback(ctx) //nolint:errcheck
defer func() {
if rbErr := tx.Rollback(ctx); rbErr != nil {
_ = rbErr // rollback error intentionally discarded; Postgres logs rollback failures
}
}()

err = s.validatePlanAccountProvidersTx(ctx, tx, planID, accountIDs)
if err != nil {
Expand Down
12 changes: 10 additions & 2 deletions internal/config/store_postgres_recommendations.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ func (s *PostgresStore) ReplaceRecommendations(ctx context.Context, collectedAt
if err != nil {
return fmt.Errorf("failed to begin tx: %w", err)
}
defer tx.Rollback(ctx) //nolint:errcheck
defer func() {
if rbErr := tx.Rollback(ctx); rbErr != nil {
_ = rbErr // rollback error intentionally discarded; Postgres logs rollback failures
}
}()

if _, err := tx.Exec(ctx, `DELETE FROM recommendations`); err != nil {
return fmt.Errorf("failed to wipe recommendations: %w", err)
Expand Down Expand Up @@ -75,7 +79,11 @@ func (s *PostgresStore) UpsertRecommendations(ctx context.Context, collectedAt t
if err != nil {
return fmt.Errorf("failed to begin tx: %w", err)
}
defer tx.Rollback(ctx) //nolint:errcheck
defer func() {
if rbErr := tx.Rollback(ctx); rbErr != nil {
_ = rbErr // rollback error intentionally discarded; Postgres logs rollback failures
}
}()

if err := insertRecommendationsBatched(ctx, tx, collectedAt, recs, true); err != nil {
return err
Expand Down
Loading