Fixed UNIQUE constraint errors when creating multiple issues in parallel. Root cause: The previous two-step approach used INSERT OR IGNORE to pre-initialize counters, followed by an UPSERT to increment. Multiple concurrent transactions could all execute the INSERT OR IGNORE with the same initial value, causing them to generate duplicate IDs. Solution: Replaced with a single atomic UPSERT that: 1. Initializes counter from MAX(existing IDs) if needed 2. Updates counter to MAX(current, max existing) + 1 on conflict 3. Returns the final incremented value This ensures counters are correctly initialized from existing issues (fixing lazy init tests) while preventing race conditions through the BEGIN IMMEDIATE transaction serialization. Tested with 10 parallel processes - all succeeded with unique IDs. Also added comprehensive profiling test suite for import performance investigation (bd-199). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
24 KiB
24 KiB