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

Motor takes 100% CPU when deleting cursor object

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: 0.2
    • Fix Version/s: 0.2.1
    • Component/s: None
    • Labels:
      None
    • # Replies:
      3
    • Last comment by Customer:
      true

      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

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                4 years, 29 weeks, 3 days ago
                Date of 1st Reply: