Project

Profile

Help

Issue #3018

closed

mongo 3.4 warning over the use of aggregates

Added by mihai.ibanescu@gmail.com over 6 years ago. Updated almost 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
2.10.3
Platform Release:
2.14.1
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Easy Fix, Pulp 2
Sprint:
Quarter:

Description

After moving to Mongo 3.4, we started seeing these warnings in the Mongo logs:

########################
2017-08-21T07:03:34.521-0400 W COMMAND [conn330]

Use of the aggregate command without the 'cursor' option is deprecated. See http://dochub.mongodb.org/core/aggregate-without-cursor-deprecation.

We have isolated the problem, and here is the proposed fix:

--- pulp/server/controllers/repository.py.orig    2017-09-15 11:15:16.915548622 -0400
+++ pulp/server/controllers/repository.py    2017-09-15 11:22:25.754073661 -0400
@@ -301,11 +301,11 @@
     pipeline = [
         {'$match': {'repo_id': repository.repo_id}},
         {'$group': {'_id': '$unit_type_id', 'sum': {'$sum': 1}}}]
-    q = db.command('aggregate', 'repo_content_units', pipeline=pipeline)
+    q = db.repo_content_units.aggregate(pipeline=pipeline)

     # Flip this into the form that we need
     counts = {}
-    for result in q['result']:
+    for result in q:
         counts[result['_id']] = result['sum']

     repository.content_unit_counts = counts

I believe pymongo is setting useCursor=True when dealing with aggregates in a collection, but not if invoked as a command.

Added by mihai.ibanescu@gmail.com over 6 years ago

Revision d17f8d80 | View on GitHub

Silence aggregation warning with mongo 3.4 and newer.

closes #3018

Actions #1

Updated by mihai.ibanescu@gmail.com over 6 years ago

  • Status changed from NEW to MODIFIED
Actions #2

Updated by pcreech over 6 years ago

  • Platform Release set to 2.14.1
Actions #3

Updated by pcreech over 6 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Actions #5

Updated by bmbouter almost 5 years ago

  • Tags Pulp 2 added
Actions #6

Updated by bmbouter almost 4 years ago

  • Category deleted (14)

We are removing the 'API' category per open floor discussion June 16, 2020.

Also available in: Atom PDF