[SERVER-56254] [SBE] ixscan's snapshot id slot should be updated during yield recovery Created: 21/Apr/21  Updated: 29/Oct/23  Resolved: 29/Apr/21

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

Type: Task Priority: Major - P3
Reporter: David Storch Assignee: Mihai Andrei
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Query Execution 2021-05-03
Participants:

 Description   

In SERVER-52907, we extended the SBE ixscan stage to have a slot for the snapshot id. The snapshot id slot is currently only reset during IndexScanStage::prepare().

When performing a fetch, the seek stage will consult the value of this slot in order to determine whether the index key may have survived a yield. If the snapshot id associated with the index key is not equal to the current snapshot id, then some expensive checks are performed in order to make sure that the document being fetched still matches the query predicate.

The problem is that the value of the ixscan's snapshot id slot is not updated during a yield. Imagine a long-running index scan plan which yields several times. This means that after the first yield, all index keys will be associated with a stale snapshot id, and the expensive validity checks involving index key generation will be performed unnecessarily. Index key generation is known to be expensive, so this is likely to be a performance problem.

In order to fix the performance problem, we should update the snapshot id held in the ixscan stage's snapshot id slot during yield recovery, i.e. during IndexScanStage::doRestoreState().



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

Author:

{'name': 'Mihai Andrei', 'email': 'mihai.andrei@10gen.com', 'username': 'mtandrei'}

Message: SERVER-56254 [SBE] ixscan's snapshot id slot should be updated during yield recovery
Branch: master
https://github.com/mongodb/mongo/commit/5891c05b1581624b0decf6663bd6b354161b2cb6

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