Skip to content

Commit 6ba8127

Browse files
fix: dedup release jobs
1 parent 6cc0aa0 commit 6ba8127

File tree

1 file changed

+9
-1
lines changed
  • apps/workspace-engine/pkg/db

1 file changed

+9
-1
lines changed

apps/workspace-engine/pkg/db/jobs.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,15 @@ const RELEASE_JOB_INSERT_QUERY = `
141141
`
142142

143143
func writeReleaseJob(ctx context.Context, releaseId string, jobId string, tx pgx.Tx) error {
144-
_, err := tx.Exec(ctx, RELEASE_JOB_INSERT_QUERY, releaseId, jobId)
144+
var exists bool
145+
err := tx.QueryRow(ctx, RELEASE_JOB_CHECK_QUERY, releaseId, jobId).Scan(&exists)
146+
if err != nil {
147+
return err
148+
}
149+
if exists {
150+
return nil
151+
}
152+
_, err = tx.Exec(ctx, RELEASE_JOB_INSERT_QUERY, releaseId, jobId)
145153
return err
146154
}
147155

0 commit comments

Comments
 (0)