Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14737

Initial sync uses background index building

    • Fully Compatible
    • ALL
    • Hide
      1. Start with a 3-node replica-set, populate a database with a couple million records (exact number doesn't matter)
      2. Create a custom index specifying background:true
      3. Wait for index build completion
      4. Kill one node and delete content of dbpath
      5. Restart dead node, observe initial sync, node uses background index build for the custom index added at step 2, but also still waits for it to complete.
      Show
      Start with a 3-node replica-set, populate a database with a couple million records (exact number doesn't matter) Create a custom index specifying background:true Wait for index build completion Kill one node and delete content of dbpath Restart dead node, observe initial sync, node uses background index build for the custom index added at step 2, but also still waits for it to complete.

      When a node is performing initial sync in 2.6.3 it will build indexes using the method specified by the original index build command even though the node does not become a viable SECONDARY until the index builds are complete.

      Eg.

      2014-07-31T13:22:29.077+1000 [rsSync] replSet initial sync clone all databases
      2014-07-31T13:22:29.089+1000 [rsSync] replSet initial sync cloning db: test
      ...
      2014-07-31T13:22:36.059+1000 [rsSync] build index on: test.ts properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "test.ts" }
      2014-07-31T13:22:36.059+1000 [rsSync] 	 building index using bulk method
      2014-07-31T13:22:42.870+1000 [rsSync] build index done.  scanned 2000000 total records. 6.81 secs
      2014-07-31T13:22:43.030+1000 [rsSync] replSet initial sync cloning db: admin
      2014-07-31T13:22:43.045+1000 [rsSync] replSet initial sync data copy, starting syncup
      2014-07-31T13:22:43.045+1000 [rsSync] oplog sync 1 of 3
      2014-07-31T13:22:43.382+1000 [rsSync] oplog sync 2 of 3
      2014-07-31T13:22:43.382+1000 [rsSync] replSet initial sync building indexes
      2014-07-31T13:22:43.382+1000 [rsSync] replSet initial sync cloning indexes for : test
      2014-07-31T13:22:43.384+1000 [rsSync] build index on: test.ts properties: { v: 1, key: { server: 1.0, cpu: 1.0, ts: 1.0 }, name: "server_1_cpu_1_ts_1", ns: "test.ts", background: true }
      2014-07-31T13:22:43.384+1000 [rsSync] 	 building index in background
      2014-07-31T13:22:43.878+1000 [rsBackgroundSync] replSet syncing to: localhost:27118
      2014-07-31T13:22:43.879+1000 [rsBackgroundSync] replset setting syncSourceFeedback to localhost:27118
      2014-07-31T13:22:46.000+1000 [rsSync] 		Index Build(background): 390700/2000000	19%
      2014-07-31T13:22:49.000+1000 [rsSync] 		Index Build(background): 808100/2000000	40%
      ...
      

      I would expect the node to either build indexes using the foreground process or allow the node to enter SECONDARY status.

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            andrew.ryder@mongodb.com Andrew Ryder (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: