arkency
Read post

Making race condition tests deterministic with Concurrent::CyclicBarrier and seam

Demonstrates how to write deterministic tests for race conditions using Ruby's Concurrent::CyclicBarrier and the seam pattern from legacy code refactoring. Shows how to synchronize threads at specific points to reliably reproduce race conditions without modifying production code, using advisory locks as an example. The technique involves injecting a controlled projection that coordinates thread execution, making concurrent behavior testable and proving that concurrency protections like locks are actually necessary.

    #testing#ruby#rails
Nov 24, 2025•5m read time•From blog.arkency.com
Post cover image
Table of contents
The code we wanted to testThe insight: We have a seam. Lets use it.The solution: Exploit the seam to inject synchronizationOne more word about tested scenarioHow CyclicBarrier synchronizes threadsWhy this pattern worksThe proofThe takeaway
473 Impressions
arkency's image
arkency

Arkency Blog offers insights, tutorials, and updates on Ruby on Rails development, domain-driven des...

0 Followers

•

19 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard