---
title: "Making race condition tests deterministic with Concurrent::CyclicBarrier and seam"
url: https://daily.dev/posts/making-race-condition-tests-deterministic-with-concurrent-cyclicbarrier-and-seam-mrundkise
source_url: https://blog.arkency.com/making-race-condition-tests-deterministic-with-cyclicbarrier-and-seam/
type: article
source: "arkency"
published: 2025-11-24T07:43:36.281Z
updated: 2025-11-24T07:43:58.004Z
tags: ["testing", "ruby", "rails"]
reading_time: 5
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

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

**[arkency](https://daily.dev/sources/arkency)** · 5 min read · 0 upvotes · 0 comments

## Summary

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.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.arkency.com/making-race-condition-tests-deterministic-with-cyclicbarrier-and-seam/>

## Similar posts on daily.dev

- [Ruby Concurrency: What Actually Happens](https://daily.dev/posts/ruby-concurrency-what-actually-happens-45gp61hdi) · RUBYLAND · 0 upvotes · 0 comments
- [Ruby Concurrency Beyond Fibers: Threads, Ractors, and True Parallelism](https://daily.dev/posts/ruby-concurrency-beyond-fibers-threads-ractors-and-true-parallelism-wi0gwu4mk) · Saeloun · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#ruby](https://daily.dev/tags/ruby), [#rails](https://daily.dev/tags/rails)

[View this post on daily.dev](https://daily.dev/posts/making-race-condition-tests-deterministic-with-concurrent-cyclicbarrier-and-seam-mrundkise)
