Skip to content

Fix enrollment rollback desync, OAuth link race, and cache lock#113

Merged
pambrose merged 1 commit into
masterfrom
fix-lows-batch
Jun 13, 2026
Merged

Fix enrollment rollback desync, OAuth link race, and cache lock#113
pambrose merged 1 commit into
masterfrom
fix-lows-batch

Conversation

@pambrose

Copy link
Copy Markdown
Contributor

Three low-severity correctness/concurrency fixes.

  • Upgrade to 1.5.10 #27 User.assignEnrolledClassCode only issues the UPDATE; the in-memory enrolledClassCode is assigned after the transaction commits in enrollInClass/withdrawFromClass, so a rollback no longer leaves the object out of sync with the database.
  • 1.16.0 #28 findOrCreateOAuthUser upserts the existing-user auto-link against the (provider, providerId) unique index, so concurrent first-login callbacks converge to one link/user instead of a duplicate-key exception. (The rarer new-user createOAuthUser race is left for the fuller transaction+email-lock fix.)
  • 1.17.0 #29 Challenge.functionInfo() uses double-checked get/putIfAbsent so the blocking network fetch + script eval no longer runs inside the ConcurrentHashMap bin lock.

Tests

New OAuthFindOrCreateRaceTest (20 concurrent callbacks → one link, verified RED against the old insert) and ChallengeFunctionInfoMemoTest (memoization preserved). Full suite green; lint + detekt clean.

🤖 Generated with Claude Code

- User: assignEnrolledClassCode only issues the UPDATE; the in-memory
  enrolledClassCode is assigned after the transaction commits in
  enrollInClass/withdrawFromClass, so a rollback no longer leaves the
  object out of sync with the database (#27).
- OAuthRoutes: upsert the existing-user auto-link against the
  (provider, providerId) unique index so concurrent first-login
  callbacks converge to one link/user instead of a duplicate-key
  exception. (The rarer new-user createOAuthUser race is left for the
  fuller transaction+email-lock fix.) (#28)
- Challenge: functionInfo() uses double-checked get/putIfAbsent so the
  blocking network fetch + script eval no longer runs inside the
  ConcurrentHashMap bin lock (#29).

Add tests: OAuth concurrent-callback convergence and functionInfo
memoization.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...n/kotlin/com/readingbat/dsl/challenge/Challenge.kt 11.76% 14 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@pambrose pambrose merged commit 8ca40d0 into master Jun 13, 2026
3 of 4 checks passed
@pambrose pambrose deleted the fix-lows-batch branch June 13, 2026 00:44
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.

1 participant