fix(storage): use strict INSERT for batch issue creation (GH#956)

Add insertIssuesStrict function that uses plain INSERT instead of
INSERT OR IGNORE. Update bulkInsertIssues and transactional CreateIssues
to use the strict variant.

This fixes a race condition where INSERT OR IGNORE could silently skip
duplicate insertions, but the code would still attempt to record events
for those "inserted" issues, causing FOREIGN KEY constraint failures.

The strict INSERT will now fail explicitly if a duplicate is encountered,
which should never happen since checkForExistingIDs runs first within
the same transaction.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
garnet
2026-01-12 19:41:34 -08:00
committed by Steve Yegge
parent b3a77eb32d
commit e8a4474788
3 changed files with 73 additions and 6 deletions

View File

@@ -87,9 +87,10 @@ func (s *SQLiteStorage) generateBatchIDs(ctx context.Context, conn *sql.Conn, is
return nil
}
// bulkInsertIssues delegates to insertIssues helper
// bulkInsertIssues delegates to insertIssuesStrict helper for fresh issue creation.
// GH#956: Using strict insert prevents FK constraint errors from silent INSERT OR IGNORE failures.
func bulkInsertIssues(ctx context.Context, conn *sql.Conn, issues []*types.Issue) error {
return insertIssues(ctx, conn, issues)
return insertIssuesStrict(ctx, conn, issues)
}
// bulkRecordEvents delegates to recordCreatedEvents helper