[SERVER-47654] ReadThroughCache with cacheSize = 0 has weak guarantees in the presence of single consumer Created: 20/Apr/20  Updated: 29/Oct/23  Resolved: 21/Apr/20

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 4.4.0-rc2, 4.7.0

Type: Bug Priority: Major - P3
Reporter: Kaloian Manassiev Assignee: Kaloian Manassiev
Resolution: Fixed Votes: 0
Labels: PM-1645-Milestone-2
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4
Sprint: Sharding 2020-05-04
Participants:
Linked BF Score: 0

 Description   

ReadThroughCache of size 0 provides the guarantee that as long as a ValueHandle returned by ReadThroughCache::acquireAsync is kept in scope, subsequent calls to acquireAsync will keep returning it and won't result in a lookup. However, as soon as that ValueHandle leaves scope, the subsequent invocation of acquireAsync should look it up again.

This guarantee is broken a bit, which is demonstrated by a single-threaded unit-test. Even though the ValueHandle from the current iteration goes out of scope and is destroyed at the end of this loop, since this value comes from the setting of a SharedSemiFuture, it is possible that there is still leftover reference on the ValueHandle somewhere throughout the SharedSemiFuture infrastructure, which would keep it alive.

This is not necessarily terrible from the point of view of the contract of ReadThroughCache of size zero, but makes it difficult to write tests, so we should fix it.



 Comments   
Comment by Githook User [ 21/Apr/20 ]

Author:

{'name': 'Kaloian Manassiev', 'email': 'kaloian.manassiev@mongodb.com', 'username': 'kaloianm'}

Message: SERVER-47654 Strengthen the guarantees of ReadThroughCache with cacheSize = 0

(cherry picked from commit 79cfaa04168ce3994b5499f45fd728ebccbef0bb)
Branch: v4.4
https://github.com/mongodb/mongo/commit/2649dba43f0971f508e86716fc444b06d2ca01d3

Comment by Githook User [ 21/Apr/20 ]

Author:

{'name': 'Kaloian Manassiev', 'email': 'kaloian.manassiev@mongodb.com', 'username': 'kaloianm'}

Message: SERVER-47654 Strengthen the guarantees of ReadThroughCache with cacheSize = 0
Branch: master
https://github.com/mongodb/mongo/commit/79cfaa04168ce3994b5499f45fd728ebccbef0bb

Generated at Thu Feb 08 05:14:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.