Race Conditions: When timing determines outcomes
The other day, my daughter asked me for a new toy. I said no. She replied, well Daddy will get it. Then she asked her dad to watch TV, he said no. She came running back to me. I hadn't heard their conversation, I said sure, one episode. She got a toy and TV time and neither parent was happy.
My daughter, the relentless tester that she is, has found a critical vulnerability in our household. She's learned that she can ask both her parents a question and get different outcomes.
A race condition is when a defect happens only because of specific timing. They're hard to reproduce because it's not tied to logic, it's a matter of happenstance, fate. Two threads are executing simultaneously, independently, and what you get depends on which one gets there first.
When my partner and I are in the same room, we're on the same page. But when we're not in a shared space, the outputs don't always match. Which makes for an inconsistent environment. And since my daughter pushes and looks for hacks to get what she wants whenever possible, we weren't setting things up for an ideal state.
I recognized it from the boundary testing — inconsistency breeds power struggles. If the boundary moves depending on who's asked and when, the boundary isn't real. The race condition was part of the problem. The fix required shared state. Communication between threads before responding.
Fixing it in the household is one thing. Her dad and I just need to be aligned on values. But the household version is the easy problem. The harder one is that I'm not always running on shared state with myself.
I'm recognizing now that I have multiple versions of myself. Mom Alison, Work Alison, Confident Alison, Stressed Alison. They all answer the same questions differently.
Work Alison says yes to TV because she's about to be in a meeting and the screen distraction means no interruptions. She can look more professional that way. But Weekend Alison says no, it's time to play with the plethora of toys that were begged for.
Given the same input, decisions have been made in my life that were a matter of timing. Convenience Alison ordered delivery regardless of Prudent Alison knowing the budget. Same inputs. Different outputs. Entirely dependent on timing.
Most of the time the stakes are low. A TV episode. A delivery order. The defect escapes but the damage is contained.
But sometimes Scared Alison is the one running the system when something important comes through.
After the layoff I needed a job. I'd had remote work since before the pandemic. I knew I never wanted to go back. But Scared Alison ran the next interview process. She had one goal: get a job to pay the bills. She expected to compromise given all the horror stories on LinkedIn of people out of work for over a year.
I took hybrid without a second thought. My first day was the first time Bailey and I had been apart for more than two hours. She cried when I left. After that she started wanting to sleep in my bed. She still does. Two years later, most nights she's in my bed or crying out for me to come to hers. Scared Alison made that call. Present Alison is still living in it.
The hard part about race conditions is they're not logical failures. You can't find them by reviewing the code. The logic was sound — take the job, pay the bills, keep the family stable, comfort your daughter. Scared Alison wasn't wrong. Given the inputs, she made a sound choice for survival. But even so, given a different thread, a different decision would have been made.
I'm getting better at noticing which version of myself is running before I respond. Not always. But more than before. Checking in before I answer something important, waiting some time to ask again and see if the answer changes. Noticing when it does and what state I was in. The fix for a race condition in software is a lock — something that makes the threads wait, coordinate, agree on a shared state before executing. I don't have a perfect lock. But I'm building one. And the cost of not having one is no longer abstract.
My daughter is still testing the system. She'll find the next vulnerability.
But I'll get more consistent with my outputs the more I prevent timing from being the problem.
Come test with me.
Bug Reports Tuesdays | Essays Saturdays
