ozontech / ozontech/seq-db

TOCTOU Bug in Circuit Breaker

Open
#37 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
131
Forks
16
Avg merge
2d 4h
Merged PRs (30d)
11

Description

In each test we create circuit breaker:

func New(name string, config Config) *CircuitBreaker {
	breaker := manager.GetCircuit(name)
	if breaker != nil {
		return &CircuitBreaker{
			Circuit: breaker,
		}
	}
	/* ... */
	breaker = manager.MustCreateCircuit(name, /* ... */)
}

Here we have a TOCTOU bug, which sometimes causes test to flap:

--- FAIL: TestColdStoreIntegration (21.99s)
    --- FAIL: TestColdStoreIntegration/TestAgg (0.01s)
        manager.go:69: test panicked: circuit with that name already exists

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at manager.go:69 and trace the New function and the manager circuit lookup and creation calls shown in the issue. Run TestColdStoreIntegration/TestAgg to reproduce the panic, then verify that concurrent circuit creation no longer reports that the circuit already exists and the test stops flapping.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.