Skip to content

brainhivenl/training-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Exercise: Fix the DNS Cache

A colleague wrote a concurrent DNS cache. It seems to work locally but behaves unpredictably in production — sometimes it resolves all domains, sometimes only a few, and occasionally it crashes entirely.

Your job is to find and fix all concurrency bugs.

Getting started

Run the program:

go run .

Run the tests:

go test -race -count=1 ./...

Rules

  • Do not change the test file
  • All tests must pass with -race
  • The program must always resolve all domains

Hints

  • There are 4 distinct concurrency issues in main.go
  • The race detector will help you find most of them
  • One of the bugs is subtle: it only shows up when an entry is read and removed by concurrent goroutines

Solution

A reference solution lives in solution/. Try the exercise first — peeking spoils it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages