Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid race when deduplicating frozen strings. Fixes #4970.
The logic here goes like this: * Attempt to lookup the dedup'ed string. * If found, return it. * Try to insert new dedup'ed string. * If nobody beat us to it, return it. * If someone beat us to it and the reference is still good, return it. * If someone beat us to it and the reference is vacated, atomically replace it or retrieve any updates that beat us. * Keep trying until we succeed in updating or get back a populated reference. Previously, there could be a race if two threads try to dedup the same string at the same time. Only one would get in the cache, but the n+1 threads might not return the already-cached value.