Skip to content

fix: use atomic INSERT ON CONFLICT for topic creation - #99

Merged
RobertLD merged 1 commit into
mainfrom
fix/issue-77-topics-race
Mar 1, 2026
Merged

RobertLD merged 1 commit into
mainfrom
fix/issue-77-topics-race

Conversation

@RobertLD

@RobertLD RobertLD commented Mar 1, 2026

Copy link
Copy Markdown
Owner

Closes #77

Changes

  • Added migration 4: UNIQUE index on topics.name column
  • Refactored createTopic() to use INSERT ... ON CONFLICT(name) DO NOTHING instead of separate SELECT-then-INSERT
  • On duplicate name, returns the existing topic instead of throwing
  • Updated schema version test and topics duplicate test

- Add migration 4: UNIQUE index on topics.name
- Refactor createTopic() to use INSERT ON CONFLICT(name) DO NOTHING
- Return existing topic on duplicate instead of throwing
- Update schema and topics tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@RobertLD
RobertLD merged commit 5430f7b into main Mar 1, 2026
7 checks passed
@RobertLD
RobertLD deleted the fix/issue-77-topics-race branch March 1, 2026 02:52
This was referenced Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: topics check-then-insert race condition

1 participant