code
Apr 02, 2026CODE-011This distributed lock implementation has a subtle race condition that can cause two processes to hold the lock simultaneously. Find the bug and fix it. ```python import redis import time import uuid class DistributedLock: def __init__(self, redis_client, lock_name, timeout=10): self.redis = redis_client self.lock_name = f"lock:{lock_name}" self.timeout = timeout self.token = str(uuid.uuid4()) def acquire(self): while True: if self.redis.setnx(self.lock_name, self.token): self.redis.expire(self.lock_name, self.timeout) return True time.sleep(0.1) def release(self): if self.redis.get(self.lock_name) == self.token: self.redis.delete(self.lock_name) ``` Explain why this is dangerous in production and provide a correct implementation.
Winner
Claude Sonnet 4.6
openrouter
9.44
WINNER SCORE
matrix avg: 8.59
10×10 Judgment Matrix · 84 judgments
OPEN DATA
| Judge ↓ / Respondent → | GPT-5.4 | Claude Opus 4.6 | Gemini 3.1 Pro | Claude Sonnet 4.6 | Grok 4.20 | DeepSeek V4 | GPT-OSS-120B | Gemini 3 | MiniMax M2.5 | MiMo-V2-Flash |
|---|---|---|---|---|---|---|---|---|---|---|
| GPT-5.4 | — | 8.4 | 1.6 | 8.8 | 9.0 | 6.0 | 7.5 | 8.6 | 6.8 | 8.6 |
| Claude Opus 4.6 | 10.0 | — | 2.5 | 9.6 | 9.3 | 9.0 | 9.2 | 9.6 | 8.8 | 9.2 |
| Gemini 3.1 Pro | 8.1 | 8.8 | — | 10.0 | 9.3 | 5.9 | 8.1 | 10.0 | 7.8 | 9.3 |
| Claude Sonnet 4.6 | 9.8 | 9.8 | 4.3 | — | 8.8 | 8.2 | 9.0 | 8.8 | 9.0 | 8.8 |
| Grok 4.20 | 9.0 | 9.0 | 5.7 | 9.0 | — | 8.8 | 8.7 | 8.6 | 8.8 | 8.6 |
| DeepSeek V4 | 9.6 | 9.8 | 8.6 | 9.6 | 9.8 | — | 10.0 | 9.6 | 9.6 | 9.6 |
| GPT-OSS-120B | 8.8 | 8.8 | 3.4 | 8.8 | · | 8.0 | — | 8.6 | · | 8.6 |
| Gemini 3 | 10.0 | 10.0 | 8.1 | 10.0 | · | 9.8 | 9.6 | — | 10.0 | 10.0 |
| MiniMax M2.5 | 10.0 | 9.4 | 2.5 | 9.8 | 8.8 | 7.8 | 8.6 | 8.8 | — | 8.4 |
| MiMo-V2-Flash | · | 9.3 | 8.8 | 9.3 | 9.2 | · | 8.8 | · | 8.6 | — |