Log inBook a Demo
BuildSeniorBackendAuto-graded

Fix a lock that lets two workers in

Ownership, expiry and exclusive access have to be reasoned about together so two workers never act at the same moment.Two workers ran the nightly billing job at the same time and double-charged a batch of customers. The lock meant to guarantee a single runner does not hold: it never expires a dead holder's lease, it admits a second owner while the first still has it, and anyone can release anyone else's lock. Build a proper lease-based lock — bounded TTL so a crashed holder cannot block forever, and ownership tokens so only the real holder can release.
45 min
python

You're done when

  • While the lock is held, another caller is refused.
  • The lease expires after its TTL, so a holder that dies does not block the lock forever.
  • A release presenting the wrong token is rejected rather than freeing someone else's lock.
  • After an expiry-driven takeover, ownership is recorded correctly — the new holder owns it and the old one cannot release it.

What it measures

Distributed data processingBuilding mutual exclusion that survives a participant vanishing mid-hold, which is the case that actually happens.
Resilience engineeringUsing a bounded lease plus ownership tokens so neither a crash nor a confused caller can corrupt the lock.
Reasoning about concurrencySeeing the windows where two holders could overlap, and closing them rather than narrowing them.

Your environment

Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards

Start this lab

45 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo