Hide Forgot
Description of problem: Creating a consumer in Katello causes the duplicate key error below. It may have something to do with creating two consumers in rapid succession. from IRC: <linear> hmmm [12:57] <linear> jweiss: actually this bug came from registering a consumer [12:58] <linear> which is odd [12:59] <linear> I wonder if we hit a race condition here <linear> This is what the code looks like [13:00] <linear> permission = self.permission(resource) <linear> if permission is None: <linear> permission = self.create(resource) <linear> and it's exploding the the create <linear> so it asks the db got the permission doc, doesn't get one, tries to create one, and gets a duplicate key error <linear> I'll look into mongo and see if they have an atomic equivalent of that operation [13:01] <linear> in the meantime, jweiss, would you file a bug? Version-Release number of selected component (if applicable): pulp-0.0.237-4.fc14.noarch How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info: 2011-10-12 12:17:19,566 11267:140401121941248: pulp.server.webservices.controllers.decorators:ERROR: decorators:52 Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/decorators.py", line 48, in report_error return method(self, *args, **kwargs) File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/decorators.py", line 127, in _auth_decorator value = method(self, *args, **kwargs) File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/consumers.py", line 104, in POST add_user_to_role(consumer_users_role, user['login']) File "/usr/lib/python2.7/site-packages/pulp/server/auth/authorization.py", line 398, in add_user_to_role _permission_api.grant(resource, user, operations) File "/usr/lib/python2.7/site-packages/pulp/server/api/permission.py", line 102, in grant permission = self._get_or_create(resource) File "/usr/lib/python2.7/site-packages/pulp/server/api/permission.py", line 79, in _get_or_create permission = self.create(resource) File "/usr/lib/python2.7/site-packages/pulp/server/api/permission.py", line 36, in create self.collection.insert(permission, safe=True) File "/usr/lib/python2.7/site-packages/pulp/server/db/connection.py", line 80, in retry return method(*args, **kwargs) File "/usr/lib64/python2.7/site-packages/pymongo/collection.py", line 270, in insert check_keys, safe, kwargs), safe) File "/usr/lib64/python2.7/site-packages/pymongo/connection.py", line 642, in _send_message return self.__check_response_to_last_error(response) File "/usr/lib64/python2.7/site-packages/pymongo/connection.py", line 611, in __check_response_to_last_error raise DuplicateKeyError(error["err"]) DuplicateKeyError: E11000 duplicate key error index: pulp_database.permissions.$resource_-1 dup key: { : "/consumers/" } 2011-10-12 12:17:19,696 11267:140401130333952: gofer.rmi.policy:INFO: policy:236 sent (391df21b-2e6c-4f77-9f84-029ef8edb150): { "classname": "Consumer", "kws": {}, "args": [], "method": "unregistered" }
Added a try/except block around create and then passed back the find results
build 0.242-2
This is actually a very difficult bug to reproduce as it was a timing issue. Basically you want a clean install of pulp (no permissions granted, no consumers) and then simultaneously create two consumer and see if you get the error. Unfortunately, no error is not indicative of no bug. You'll have to hammer the server with the following: 1. fresh install 2. create 2 consumers from two different shells, threads, or clients 3. repeat (preferable dozens or even hundreds of times)
verified [root@pulpf15-client ~]# rpm -q pulp-consumer pulp-consumer-0.0.255-1.fc15.noarch I have tried the consumer register /unregister over 100 times without getting the error.
Pulp v1.0 is released Closed Current Release.