[SERVER-23807] Updates should always throw WriteConflictException on unindexing Created: 19/Apr/16  Updated: 02/Aug/18  Resolved: 21/Apr/16

Status: Closed
Project: Core Server
Component/s: Index Maintenance, WiredTiger
Affects Version/s: 3.2.5, 3.3.4
Fix Version/s: 3.0.12, 3.2.6, 3.3.5

Type: Task Priority: Critical - P2
Reporter: Kyle Suarez Assignee: Kyle Suarez
Resolution: Done Votes: 1
Labels: code-only
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-22970 Background index build produces an in... Closed
Related
is related to SERVER-18844 Reacquire the snapshot after commit/a... Closed
Backwards Compatibility: Fully Compatible
Backport Completed:
Sprint: Integration 13 (04/22/16)
Participants:

 Description   

During an index build, the collection is locked in mode IX. Consider a background index build occurring with concurrent updates. Then, the following race scenario could occur:

1. Both the updater and the index builder read the same document.
2. To perform the update, the updater unindexes the document's old value.
3. Because the document has yet to be indexed, the WiredTiger returns WT_NOTFOUND. No WCE is generated.
4. The update proceeds to index the new value.
5. The indexer in the background, unaware of any WCEs, indexes the value it has read. The result is that the index has one too many keys.

We can fix this by having the update path trigger a write conflict exception even in the "no-op" case when unindexing returns WT_NOTFOUND.

(An alternative is to simply lock the collection in X mode during an index build, but this will probably have a large impact on performance.)



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

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'ksuarz@gmail.com'}

Message: SERVER-23807 index build must X-lock collection

Index builds must lock the collection with an X lock, rather than an IX lock, to
prevent a race with concurrent updates.
Branch: v3.0
https://github.com/mongodb/mongo/commit/dc729bf1e79318b17bcb02550ce7a0a51b814d72

Comment by Githook User [ 21/Apr/16 ]

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'ksuarz@gmail.com'}

Message: SERVER-22970 fix update race with background index build

There are two distinct fixes that must be done together:

Comment by Githook User [ 21/Apr/16 ]

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'ksuarz@gmail.com'}

Message: SERVER-22970 fix update race with background index build

There are two distinct fixes that must be done together:

Generated at Thu Feb 08 04:04:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.