[SERVER-70944] Make accessing hashes stored in FieldPath thread-safe Created: 28/Oct/22 Updated: 29/Oct/23 Resolved: 02/Nov/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: | Irina Yatsenko (Inactive) | Assignee: | Irina Yatsenko (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Backwards Compatibility: | Fully Compatible | ||||
| Operating System: | ALL | ||||
| Sprint: | QE 2022-10-31, QE 2022-11-14 | ||||
| Participants: | |||||
| Linked BF Score: | 23 | ||||
| Description |
|
TSAN found a data race accessing lazily computed FieldPath::_fieldHash (see BF-26622) during updates that might share collection validators. |
| Comments |
| Comment by Githook User [ 02/Nov/22 ] |
|
Author: {'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}Message: |
| Comment by Irina Yatsenko (Inactive) [ 28/Oct/22 ] |
|
T40 (conn7) Executed first and installed a validator for the collection with something like: db.runCommand({collMod: "ff", validator: {$expr: {$gt: ["$stars", 0]}}}) (the actual command in the test has a more complicated expression)
abridged stack: mongo::FieldPath::FieldPath mongo::ExpressionFieldPath::ExpressionFieldPath mongo::ExpressionFieldPath::parse mongo::ExprMatchExpression::ExprMatchExpression mongo::MatchExpressionParser::parse mongo::CollectionImpl::parseValidator mongo::processCollModCommand
After the validator is installed into the collection, it's shared across client connections, so updates from different threads access the same FieldPath object when checking the schema. T69 (conn 35) / T67 (conn33) UpdateStage::doWork -> … -> ExpressionFieldPath::evaluatePath - accesses the hash and might lazily compute it, thus creating the race between readers/writers |