Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-33

Motor takes 100% CPU when deleting cursor object

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Critical - P2
    • Resolution: Fixed
    • 0.2
    • 0.2.1
    • None
    • None

    Description

      MotorCursor and MotorCommandCursor objects implement a __del__ method that checks if the cursor is still alive on the server and, if so, calls self.close() to send an OP_KILLCURSORS message to the server.

      Starting with Motor 0.2, the coroutine implementation of self.close() changed such that it creates a new reference to the cursor object, rescuing it from garbage collection. If the cursor also has any documents in its buffer then its "alive" property is true. This created an infinite loop: each time the cursor began to delete itself, __del__ revived it.

      An application in this situation is still responsive, since each call to self.close() yields control to the IOLoop. However, it pegs a CPU core, and sends useless OP_KILLCURSORS messages to the server as fast as it can.

      The solution is to only call close() once. If self.closed is True, short-circuit.

      Attachments

        Activity

          People

            jesse@mongodb.com A. Jesse Jiryu Davis
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: