Skip to content

fix: eliminate version number race in CoursesService.update - #1119

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Chinonso-Peter:feat/unique-course-version-constraint
Jul 28, 2026
Merged

fix: eliminate version number race in CoursesService.update#1119
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Chinonso-Peter:feat/unique-course-version-constraint

Conversation

@Chinonso-Peter

Copy link
Copy Markdown
Contributor

Add unique composite constraint on (courseId, versionNumber) and compute the next version inside a transaction with SELECT ... FOR UPDATE to serialize concurrent edits.

  • Migration resolves existing duplicates and creates the unique index
  • Entity names the unique index for consistency across sync and migration
  • Service uses DataSource.transaction + pessimistic lock + retry on unique violation across update, rollbackToVersion, and create
  • Concurrency test validates sequential versions 2 and 3; retry test validates transparent recovery from unique violation

Closes #1009

Add unique composite constraint on (courseId, versionNumber) and
compute the next version inside a transaction with SELECT ... FOR UPDATE
to serialize concurrent edits.

- Migration: resolves existing duplicates and creates unique index
- Entity: names the unique index for consistency
- Service: uses DataSource.transaction + pessimistic lock + retry
  on unique violation across update, rollbackToVersion, and create
- Tests: concurrency test validates sequential versions 2 and 3;
  retry test validates transparent recovery from unique violation

Closes rinafcode#1009
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Chinonso-Peter Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chinonso-Peter

Copy link
Copy Markdown
Contributor Author

@RUKAYAT-CODER please review

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 068a4f1 into rinafcode:main Jul 28, 2026
3 checks passed
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.

Eliminate the version number race in CoursesService.update

2 participants