[SERVER-44577] Ensure WiredTiger cursors have started a transaction before reading data Created: 12/Nov/19 Updated: 29/Oct/23 Resolved: 07/Apr/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Storage |
| Affects Version/s: | 4.2.0, 4.4.0 |
| Fix Version/s: | 4.2.7, 4.4.0-rc1, 4.7.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Suganthi Mani | Assignee: | Louis Williams |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | groomed | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Backport Requested: |
v4.4, v4.2
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sprint: | Execution Team 2020-01-13, Execution Team 2020-01-27, Execution Team 2020-04-06, Execution Team 2020-04-20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Linked BF Score: | 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
Collection scan phase of hybrid index build can encounter a prepare conflict. In order to avoid 3 way dead lock mentioned in Modifying the repro script of Consider, I have inserted 3 documents into collection A before index build start. Then, Taking a closer look at step#3 -5, we see the below sequence.
Problems because of the behavior Thinking about the safety/correctness of the reads and writes performed inside an implicit WT transaction after sequence #5, we see that the implicit transaction will be opened with the default isolation level = read-committed as opposed to WT transaction opened by MongoDB layer in snapshot isolation level. So, is it possible to end up writing the index key for a document (say doc X) twice? One from the code path - read the docX during collection scan and insert index keys; and other from the side write table drain code path. If so, I think, we can hit problem like in 3) Should we need to audit our codebase to see if we have the same behavior (i.e.) read/write outside a transaction (read-committed isolation) and is it safe to do it? |
| Comments |
| Comment by Githook User [ 16/Apr/20 ] |
|
Author: {'name': 'Louis Williams', 'email': 'louis.williams@mongodb.com', 'username': 'louiswilliams'}Message: (cherry picked from commit 34c8bef2ebbe355aef0439a5b85313db1c2f242d)
(cherry picked from commit 4e23322e27b6372e7c747a68a3f657f16211b540)
(cherry picked from commit e9379fcee79456d3795b598ccad91a0694007d0e) |
| Comment by Githook User [ 16/Apr/20 ] |
|
Author: {'name': 'Louis Williams', 'email': 'louis.williams@mongodb.com', 'username': 'louiswilliams'}Message: (cherry picked from commit 4e23322e27b6372e7c747a68a3f657f16211b540) |
| Comment by Githook User [ 16/Apr/20 ] |
|
Author: {'name': 'Louis Williams', 'email': 'louis.williams@mongodb.com', 'username': 'louiswilliams'}Message: |
| Comment by Githook User [ 10/Apr/20 ] |
|
Author: {'name': 'Louis Williams', 'email': 'louis.williams@mongodb.com', 'username': 'louiswilliams'}Message: (cherry picked from commit 34c8bef2ebbe355aef0439a5b85313db1c2f242d) |
| Comment by Githook User [ 07/Apr/20 ] |
|
Author: {'name': 'Louis Williams', 'email': 'louis.williams@mongodb.com', 'username': 'louiswilliams'}Message: |
| Comment by Suganthi Mani [ 14/Nov/19 ] |
|
Just a quick correction, the isolation level of reads and writes performed inside an implicit WT transaction after sequence #5, will still be have the snapshot isolation level and NOT as read-committed isolation. Because when we release the resources of a WT transaction on commit, we set the transaction's isolation level to be session's isolation level (= snapshot isolation level). So, I feel, there won't be any data corruption/correctness issue. |
| Comment by Louis Williams [ 12/Nov/19 ] |
|
Funilly enough, I filed this same bug in There's no reason we couldn't encounter this problem in other parts of the code, so I also filed |
| Comment by Eric Milkie [ 12/Nov/19 ] |
|
I don't see how you could get index data corruption (#2) here. |