sunspot_index_queue icon indicating copy to clipboard operation
sunspot_index_queue copied to clipboard

Performance issue with long queue.

Open heaven opened this issue 12 years ago • 1 comments

Hi, found that if queue contains a lot of records (in my case ≈250000 items) indexing works incredibly slow. This line cause the troubles:

doc = collection.find_and_modify(:update => {"$set" => {:run_at => Time.now.utc + queue.retry_interval, :error => nil, :lock => lock}}, :query => conditions, :limit => queue.batch_size, :sort => [[:priority, Mongo::DESCENDING], [:run_at, Mongo::ASCENDING]])

It's in Sunspot::IndexQueue::Entry::MongoImpl#next_batch!.

Now it updates each doc separately, think things could be improved if we will set :run_at for the whole batch of records instead of setting it individually for each record.

heaven avatar Aug 04 '12 20:08 heaven

Also cause this warning:

Mon Aug  6 08:41:04 [conn13] warning: ClientCursor::yield can't unlock b/c of recursive lock ns:
crm_production.sunspot_index_queue_entries top: {
  opid: 1305,
  active: true,
  lockType: "write",
  waitingForLock: false,
  secs_running: 3,
  op: "query",
  ns: "crm_production",

  query: {
    findandmodify: "sunspot_index_queue_entries",
    update: {
      $set: {
        run_at: new Date(1344242520464),
        error: null,
        lock: 914414234
      }
    },

    query: {
      run_at: {
        $lte: new Date(1344242434611)
      }
    },

    limit: 100,
    sort: { priority: -1, run_at: 1 }
  },

  client: "67.214.219.87:49452",
  desc: "conn",
  threadId: "0x7f38b41be700",
  connectionId: 13,
  numYields: 0 
}

Log grow extremely fast, even log rotating doesn't always help.

heaven avatar Aug 06 '12 08:08 heaven