cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

workload/tpcc: fix N^2 row updates during long-duration reset

Open ajstorm opened this issue 3 weeks ago • 2 comments

Summary

  • Fixed a bug where the TPC-C reset worker goroutine was started once per worker instead of once total
  • With 10 workers per warehouse by default, a workload with W warehouses would spawn (10*W) goroutines, each updating all W rows every 24 hours
  • This change uses sync.Once to ensure only one reset worker is started, reducing the 24-hour reset from (10*W)*W to W row updates
  • For a 1,200 warehouse cluster, this reduces the reset from 14,400,000 row updates to 1,200 row updates

Test plan

  • Manual verification on a running cluster using curl http://localhost:33333/debug/pprof/goroutine?debug=2 | grep -c startResetValueWorker
    • Before fix: 2400 matches (1200 goroutines × 2 matches per stack)
    • After fix: should show 2 matches (1 goroutine × 2 matches per stack)

Informs: #124259

🤖 Generated with Claude Code

ajstorm avatar Dec 11 '25 16:12 ajstorm

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

blathers-crl[bot] avatar Dec 11 '25 16:12 blathers-crl[bot]

This change is Reviewable

cockroach-teamcity avatar Dec 11 '25 16:12 cockroach-teamcity