db/sqlachemy/session.py resets the mysql session type on every operation

Bug #1288444 reported by Doug Hellmann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Fix Released
Medium
Roman Podoliaka

Bug Description

The callback to set the session type for mysql (http://git.openstack.org/cgit/openstack/oslo-incubator/tree/openstack/common/db/sqlalchemy/session.py#n524) is registered for the "checkout" event (http://git.openstack.org/cgit/openstack/oslo-incubator/tree/openstack/common/db/sqlalchemy/session.py#n635) which causes it to run every time a connection is retrieved from the pool. That means when a connection is reused, we update the session type.

Is that necessary? How expensive is it? Can we do it one time per connection, or one time per session?

See also https://bugs.launchpad.net/oslo/+bug/1288443

Tags: db
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo-incubator (master)

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

Changed in oslo:
assignee: nobody → Ben Nemec (bnemec)
status: New → In Progress
Revision history for this message
Roman Podoliaka (rpodolyaka) wrote :

So yeah, currently it is executed once per session (and effectively once per database transaction). But MySQL 'session' variables have a client connection scope, so it's indeed not necessary to set sql_mode variable every time we start a new transaction. Though, I don't think it's any expensive.

Changed in oslo:
importance: Undecided → Medium
Changed in oslo:
assignee: Ben Nemec (bnemec) → Roman Podoliaka (rpodolyaka)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/78628
Committed: https://git.openstack.org/cgit/openstack/oslo-incubator/commit/?id=d1988b96266cf275fdb2c2cee01adc46797004fb
Submitter: Jenkins
Branch: master

commit d1988b96266cf275fdb2c2cee01adc46797004fb
Author: Ben Nemec <email address hidden>
Date: Wed Mar 12 16:01:26 2014 +0000

    Set sql_mode callback on connect instead of checkout

    There's no need to set the sql_mode on every checkout of a
    connection - once when the connection is created is sufficient.

    Change-Id: If34db31d9646c9a75d591e556a7abcc0bf8a7ab1
    Closes-Bug: #1288444

Changed in oslo:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in oslo:
milestone: none → icehouse-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in oslo:
milestone: icehouse-rc1 → 2014.1
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.