[SERVER-25841] Dropping an index while another index getting created in the same collection is blocking reads in secondary Created: 29/Aug/16  Updated: 28/May/20  Resolved: 29/Aug/16

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Replication
Affects Version/s: 2.6.11
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Manoj Vivek Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-21307 Replicated DDL (catalog) operation du... Closed
Operating System: ALL
Steps To Reproduce:

Run the following on a collection which large number of docs(to feel the blocking manually):

db.coll.ensureIndex({"field1":1,"field2" : 1},{"background" : true})
db.coll.dropIndex({"field1_1"},{"background" : true})   // assume index {"field1" : 1} is already present

Now once the ensureIndex is completed in primary dropIndex will run immediately.
While the ensureIndex is running in the secondary run any query it will be blocked till the ensureIndex and the dropIndex are replicated.

Participants:

 Description   

Dropping an index in primary while an index creation is replicating in the secondary is blocking all read and write operation on the database.

Logs from secondary:

2016-08-29T05:23:54.991+0000 [repl index builder 22] build index on: <ns> properties: { v: 1, key: { <keys> }, name: "<name>", ns: "<ns>", background: true }
2016-08-29T05:23:54.991+0000 [repl index builder 22]     building index in background
2016-08-29T05:23:55.001+0000 [repl writer worker 3] CMD: dropIndexes <ns>
2016-08-29T05:23:57.002+0000 [repl index builder 22]            Index Build(background): 242700/1705097 14%
2016-08-29T05:24:00.002+0000 [repl index builder 22]            Index Build(background): 559300/1705097 32%
2016-08-29T05:24:03.002+0000 [repl index builder 22]            Index Build(background): 855500/1705097 50%
2016-08-29T05:24:06.002+0000 [repl index builder 22]            Index Build(background): 1174800/1705097        68%
2016-08-29T05:24:09.002+0000 [repl index builder 22]            Index Build(background): 1447900/1705097        84%
2016-08-29T05:24:12.002+0000 [repl index builder 22]            Index Build(background): 1700900/1705097        99%
2016-08-29T05:24:12.050+0000 [repl index builder 22] build index done.  scanned 1705097 total records. 17.058 secs
2016-08-29T05:24:12.051+0000 [repl writer worker 3] CMD: dropIndexes <ns>



 Comments   
Comment by Ramon Fernandez Marina [ 29/Aug/16 ]

Thanks for reporting this issue vivek_jonam. Looks like one of our engineers already found it on SERVER-21307, so I'm going to mark this issue as a duplicate. Please watch SERVER-21307 for future updates.

Thanks,
Ramón.

Comment by Manoj Vivek [ 29/Aug/16 ]

Formatted Steps to reproduce:

  1. Run the following on a collection which large number of docs(to feel the blocking manually):

    db.coll.ensureIndex({"field1":1,"field2" : 1},{"background" : true})
    db.coll.dropIndex("field1_1")  // assume index {"field1" : 1} is already present

  2. Now once the ensureIndex is completed in primary dropIndex will run immediately. While the ensureIndex is running in the secondary run any query it will be blocked till the ensureIndex and the dropIndex are replicated.

    db.coll.findOne()
    //waits till the index operations are complete
    

This doesn't happen when the ensure and drop are on different collections.

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