{
  "id": 5829997,
  "title": "The Map Dropped a Key When Two Expiry Times Matched",
  "url": "https://urgent.news/2026/09/05/the-map-dropped-a-key-when-two-expiry-times-matched",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-05T20:05:28.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/datacpp_3670/the-map-dropped-a-key-when-two-expiry-times-matched-1lfo"
  },
  "original_language": "en",
  "account": "A C++ map can drop a live cache entry when two entries share the same expiry time. One key vanished without any exceptions or log messages. The issue lies in the comparator used to order the map. Initially, it was assumed that expiry values would never collide. However, when two entries had the same expiry second, the comparator failed to distinguish between them, treating distinct ids as equivalent. This led to the second insert being dropped or the tree going \"sick\" without a crash. The root cause is that std::map requires a strict weak ordering, and comp(x, x) must be false. When equal expiry is used with this comparator, distinct ids become equivalent, causing the bug. The fix is to use a total order on identity and use expiry only as data.",
  "summary": "A C++ map can drop a live cache entry. One <= in a comparator is enough. I forced a timestamp tie and watched a key vanish. Would you have caught that in review? This is a debugging retrospective. It is not a product tour. The artifact is a comparator audit you can run locally. The symptom I reconstructed a small TTL cache. Insert looked fine. Lookup looked fine. Unit tests stayed green. Then two…",
  "key_points": [
    "C++ map drops live cache entry when two entries share expiry time",
    "Comparator fails to distinguish between distinct ids with same expiry",
    "Fix requires total order on identity, using expiry only as data"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}