[SERVER-70935] Fix data race in SBE plan cache key calculation related to IndexCatalogEntry minimum visible snapshot Created: 28/Oct/22  Updated: 29/Oct/23  Resolved: 31/Oct/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: David Storch
Resolution: Fixed Votes: 0
Labels: tsan
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
is related to SERVER-65083 Thread seeing different set of indice... Closed
is related to SERVER-70607 Index build commit not following copy... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.1, v6.0
Sprint: QE 2022-10-31
Participants:
Linked BF Score: 12

 Description   

Each SBE plan cache key incorporates a Timestamp defined as the commit timestamp of the most recently constructed index visible to the reader. This is necessary to deal with some subtle concurrency problems for the SBE plan cache which I won't explain here, but you can see this comment or SERVER-65083 for details.

The code which calculates the SBE plan cache key Timestamp has a data race detected by TSAN. It traverses all indexes, both ready ones and in-progress index builds, and calls getMinimumVisibleSnapshot() on each IndexCatalogEntry. In the case of lock-free reads, this can race with another thread that is setting the value of the minimum visible snapshot on the same object.

The data race is possible due to a flaw in the catalog's implementation of lock-free reads. As noted in SERVER-70607, the IndexCatalogEntry should follow copy-on-write semantics for the commit timestamp. Until SERVER-70607 is fixed, we can work around the problem. gregory.noma@mongodb.com suggested a workaround in which the SBE plan cache's timestamp calculation simply never considers in-progress index builds. The task for this ticket is to implement the workaround.



 Comments   
Comment by Githook User [ 31/Oct/22 ]

Author:

{'name': 'David Storch', 'email': 'david.storch@mongodb.com', 'username': 'dstorch'}

Message: SERVER-70935 avoid data race in IndexCatalogEntry during SBE plan cache key computation
Branch: master
https://github.com/mongodb/mongo/commit/e83c4e60c56650c69f4b47558c16a6bb60aee20f

Generated at Thu Feb 08 06:17:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.