[SERVER-35780] `renameCollection` across databases incorrectly timestamps metadata for secondary index builds Created: 25/Jun/18  Updated: 29/Oct/23  Resolved: 31/Jul/18

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 4.0.3, 4.1.2

Type: Bug Priority: Major - P3
Reporter: Daniel Gottlieb (Inactive) Assignee: Maria van Keulen
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-38745 MigrationDestinationManager assigns i... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0
Sprint: Storage NYC 2018-07-30, Storage NYC 2018-08-13
Participants:
Linked BF Score: 50

 Description   

Renaming collections across databases is not a simple rename, but rather a process of:

  1. Creating a temp collection on the destination database + _id index.
  2. Build secondary indexes on the temp collection.
  3. Insert documents to the temp collection.
  4. Rename the temp collection to the desired destination.

Copying the index definitions over uses a single MultiIndexBlock. All of the indexes are generated with `ready: false` writes in one WUOW and a single timestamp from a noop oplog entry. However, committing the `ready: true` writes has the following sequence (for demonstration, suppose two secondary indexes, A and B):

  1. Begin WT transaction.
  2. Set index A to ready.
  3. Set index B to ready.
  4. Write oplog entry creating A.
  5. Set timestamp 1.
  6. Write oplog entry creating B.
  7. Set timestamp 2.
  8. Commit WT transaction.

In this case, both `ready: true` writes are given timestamp 2. Rolling back inbetween these times will see both indexes as `ready: false`, but replication recovery will only rebuild index B.

This is an analogous bug to SERVER-35070.

This ticket should consider adding the following invariant right before here:

        invariant(_indexes.size() == 1 || onCreateFn);



 Comments   
Comment by Githook User [ 07/Sep/18 ]

Author:

{'name': 'Maria van Keulen', 'email': 'maria@mongodb.com', 'username': 'mvankeulen94'}

Message: SERVER-35780 Timestamp multiple index builds during rename

(cherry picked from commit 57d12da516328ddc2102d8f71f9c4ebccb6b349d)
Branch: v4.0
https://github.com/mongodb/mongo/commit/e631a9531fbc3d80945a72d15ae0ac83c76d51af

Comment by Githook User [ 31/Jul/18 ]

Author:

{'name': 'Maria van Keulen', 'email': 'maria@mongodb.com', 'username': 'mvankeulen94'}

Message: SERVER-35780 Timestamp multiple index builds during rename
Branch: master
https://github.com/mongodb/mongo/commit/57d12da516328ddc2102d8f71f9c4ebccb6b349d

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