#5023 Fix mongo mailbox query performance NEEDS ENSURE_INDEX, SCRIPT

v1.0.0
closed
General
Cory Johns
2015-08-20
2012-10-01
No

These queries are consistently very slow:

{u'active': True,
 u'desc': u'conn',
 u'lockType': u'read',
 u'ns': u'pyforge.mailbox',
 u'numYields': 2481,
 u'op': u'query',
 u'opid': -5041171,
 u'query': {u'queue': {u'$ne': []}, u'type': u'direct'},
 u'secs_running': 10,
 u'threadId': u'0x670df940',
 u'waitingForLock': False}

Mon Oct  1 16:43:53 [conn4012152] query pyforge.mailbox query: { queue: { $ne: {} }, type: "direct" } nscanned:1343637 nreturned:3 reslen:1135 24720ms

A previous attempt was made to fix this query, but it actually made things worse when run with production-sized data and load. It was reverted in [e3fd1b]. I wonder if we may need an additional field so that we can do indexed queries on it properly.

Discussion

  • Dave Brondsema

    Dave Brondsema - 2012-10-01
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -12,6 +12,8 @@
      u'secs_running': 10,
      u'threadId': u'0x670df940',
      u'waitingForLock': False}
    +
    +Mon Oct  1 16:43:53 [conn4012152] query pyforge.mailbox query: { queue: { $ne: {} }, type: "direct" } nscanned:1343637 nreturned:3 reslen:1135 24720ms
     ~~~~
    
     A previous attempt was made to fix this query, but it actually made things worse when run with production-sized data and load.  It was reverted in [e3fd1b].  I wonder if we may need an additional field so that we can do indexed queries on it properly.
    
     
  • Cory Johns - 2012-10-01

    Why are we querying all mboxes w/ empty queues, only to do a follow-up find_and_modify for each matching mbox, when we could just use a while find_and_modify which would allow mongo to short-circuit after finding only a single match each iteration?

     
  • Cory Johns - 2012-10-01

    The response on there is probably less relevant since we expect the number of empty queues to vastly out-number the ones with items in the queue, and we want to process everything with a non-empty queue anyway. Still, I think the suggestion of moving processed items into an "archive" collection makes sense and would give us the best performance.

     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03
    • status: open --> in-progress
    • assigned_to: Dave Brondsema
     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03

    We don't have a construct for doing while find_and_modify do we? The find_and_modify method only works on a single document.

     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03

    allura:db/5023

    • check that email notifications go out properly
    • check for any 'queue' usage that might've been missed
     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03
    • summary: Fix mongo mailbox query performance --> Fix mongo mailbox query performance NEEDS ENSURE_INDEX
    • status: in-progress --> code-review
    • qa: Cory Johns
     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03
    • summary: Fix mongo mailbox query performance NEEDS ENSURE_INDEX --> Fix mongo mailbox query performance NEEDS ENSURE_INDEX, SCRIPT
     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03

    Post-push, need to run: allurapaste script /var/local/config/production.ini ../scripts/migrations/029-set-mailbox-queue_empty.py

     
  • Cory Johns - 2012-10-03
    • summary: Fix mongo mailbox query performance NEEDS ENSURE_INDEX, SCRIPT --> Fix mongo mailbox query performance NEEDS ENSURE_INDEX
    • status: code-review --> validation
     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03
    • summary: Fix mongo mailbox query performance NEEDS ENSURE_INDEX --> Fix mongo mailbox query performance NEEDS ENSURE_INDEX, SCRIPT
     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03
    • status: validation --> code-review
     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03

    More elegant query on db/5023 now

     
  • Dave Brondsema

    Dave Brondsema - 2012-10-03

    test

     
  • Cory Johns - 2012-10-03
    • status: code-review --> validation
     
  • Dave Brondsema

    Dave Brondsema - 2012-10-05
    • size: --> 1
     
  • Dave Brondsema

    Dave Brondsema - 2012-10-08
    • status: validation --> closed
     

Log in to post a comment.