惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
B
Blog RSS Feed
美团技术团队
博客园 - 【当耐特】
C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
Vercel News
Vercel News
P
Proofpoint News Feed
IT之家
IT之家
I
InfoQ
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I ran `go test -race` after 3 months. It found 8 things.
BaoDev Studi · 2026-05-18 · via DEV Community

BaoDev Studio

8 race conditions. That's what three months of "I'll add -race later" bought me.

The codebase is a Go backend for a freelance studio automation tool. Around 4,000 lines of application code, a handful of goroutines managing job queues, email polling, and an agent dispatch loop. Perfectly ordinary stuff. I had been telling myself -race was "too slow for CI." It runs in 11s for a 4k-line service.testing I was wrong.

What the detector actually outputs

When youtipsprogramming hit a real data race, the output looks like this:

==================
WARNING: DATA RACE
Read at 0x00c0001b4030 by goroutine 18:
  github.com/baodev/flos/internal/dispatch.(*Router).getHandler()
      /home/runner/work/flos/internal/dispatch/router.go:94 +0x6c

Previous write at 0x00c0001b4030 by goroutine 7:
  github.com/baodev/flos/internal/dispatch.(*Router).Register()
      /home/runner/work/flos/internal/dispatch/router.go:61 +0x84

Goroutine 18 (running) created at:
  github.com/baodev/flos/internal/dispatch.(*Router).Start()
      /home/runner/work/flos/internal/dispatch/router.go:112 +0x1e0
==================

Enter fullscreen mode Exit fullscreen mode

File and line numbers, both goroutines, the moment of creation. It tells you exactly where to look.

The representative case

The most embarrassing one: a map[string]HandlerFunc being read by worker goroutines while a registration goroutine could still be writing to it. Classic. The map wasn't behind a mutex because I "registered everything at startup." Except one code path registered a handler lazily on first use.

 type Router struct {
-    handlers map[string]HandlerFunc
+    handlers map[string]HandlerFunc
+    mu       sync.RWMutex
 }

 func (r *Router) Register(name string, fn HandlerFunc) {
+    r.mu.Lock()
+    defer r.mu.Unlock()
     r.handlers[name] = fn
 }

 func (r *Router) getHandler(name string) HandlerFunc {
+    r.mu.RLock()
+    defer r.mu.RUnlock()
     return r.handlers[name]
 }

Enter fullscreen mode Exit fullscreen mode

12 lines changed. Bug had been live since the initial commit in February.

Adding it to CI is one line

If you're on GitHub Actions and not already running this, add it to your test job:

- name: Test with race detector
  run: go test -race -count=1 -timeout=120s ./...

Enter fullscreen mode Exit fullscreen mode

Or if you run tests via a Makefile:

test-race:
    go test -race -count=1 -timeout=120s ./...

Enter fullscreen mode Exit fullscreen mode

The -count=1 disables the test result cache so every CI run actually executes. Without it, Go can return cached results even on -race, which defeats the point.

What the other 7 were

I won't detail all of them. Mostly they were the same pattern: shared state accessed from spawned goroutines, written once somewhere "safe" and read everywhere else, with no synchronization because the write "always finished first." The race detector disagreed with that assumption on 7 separate occasions.

Two of them were in test helpers, not production code. Still real races — test helpers spin goroutines too, and a flaky test that fails once every 40 runs is its own kind of tax.

The honest accounting

Three months of technical debt on a four-person equivalent codebase (it's mostly me and agents). Eight findings in 11 seconds of wall time. One of those findings was in the agent dispatch path that runs on every job — meaning every job that completed without incident was getting lucky with goroutine scheduling.

That's the uncomfortable part about race conditions: they don't fail loudly. They fail intermittently, or they corrupt state silently, or they don't fail at all on your machine because your CPU happens to schedule goroutines in a forgiving order.

The race detector doesn't care about your scheduler's mood.

Running it weekly now. Should have been in CI from day one — -race exists precisely because humans are bad at reasoning about concurrent memory access under load.