API server should not create a new database handle on each request

Bug #1178845 reported by Doug Hellmann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Medium
Julien Danjou

Bug Description

In the DBHook we call get_engine() for each request. We should only do that *one time* and save the result, then reuse that reference on other requests. Otherwise we're doing extra work to scan the plugins and create new database handles.

https://github.com/openstack/ceilometer/blob/master/ceilometer/api/hooks.py#L41

Tags: effort-s
Changed in ceilometer:
assignee: nobody → Doug Hellmann (doug-hellmann)
milestone: none → havana-2
tags: added: effort-s
Revision history for this message
xingzhou (xingzhou) wrote :

@Doug, will the fix only keep one database Connection object? I'm glad to see if there is only one Connection object that API server is using, this will also help to fix https://bugs.launchpad.net/ceilometer/+bug/1188649

Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

No, these bugs are not related as far as I can tell. The problem reported in this bug is that we scan the plugins for every web request. We really only need to do that on startup. We can also, I think, use the same database connection object for all requests, but we will need to test that part more carefully. The other bug has to do with the way the mongo driver connects, and having it support mongo clusters.

Julien Danjou (jdanjou)
Changed in ceilometer:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
xingzhou (xingzhou) wrote :

To @jd__ and @Doug, for comment #2, will we cache the connection object in impl_mongodb.py in the patch of this defect? if not, I would like to open one new defect and upload a patch

Revision history for this message
Julien Danjou (jdanjou) wrote :

xingzhou: I already have a workaround for that in https://review.openstack.org/#/c/33290/ FWIW

Revision history for this message
xingzhou (xingzhou) wrote :

thanks @jd__, that patch solves my problem

Changed in ceilometer:
assignee: Doug Hellmann (doug-hellmann) → nobody
milestone: havana-2 → havana-3
Julien Danjou (jdanjou)
Changed in ceilometer:
assignee: nobody → Julien Danjou (jdanjou)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

Fix proposed to branch: master
Review: https://review.openstack.org/36849

Changed in ceilometer:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/36849
Committed: http://github.com/openstack/ceilometer/commit/1c3c6a65142500b44e0c286887b2332de1994e8b
Submitter: Jenkins
Branch: master

commit 1c3c6a65142500b44e0c286887b2332de1994e8b
Author: Julien Danjou <email address hidden>
Date: Tue Jul 16 17:51:30 2013 +0200

    api: build the storage connection once and for all

    Fixes: bug#1178845

    Change-Id: Ic0c639224ba87c3e11f3e1eeba4915e3c8ba0e88

Changed in ceilometer:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in ceilometer:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: havana-3 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.