Skip to content

streamcache: Unlock waiters after cache keys have been pruned

Patrick Steinhardt requested to merge pks-streamcache-fix-flaky-test into master

When creating a new cache entry the writer is running in a Goroutine to populate the cache file. After it has ran we then unlock any waiters which have been waiting for the writer to finish. If the writer failed, we also remove its respective cache key from the cache so that it's not used by anything else anymore.

The current order is that we first unblock waiters and then delete the key. This is creating a race in our tests when checking whether we try to reuse the failed cache entry because the cache key still exists for a brief period after the original failing writer has exited.

Fix this flake by only unblocking waiters after the cache key has been removed. This also feels like the right thing to do outside of this flaky test: it's inconsistent to treat the write as finished but failed, but to still have the cache entry around at that point in time.

Merge request reports

Loading