]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
db_base_plugin_v2: Avoid creating another session
authorYAMAMOTO Takashi <yamamoto@midokura.com>
Fri, 3 Jul 2015 15:04:35 +0000 (00:04 +0900)
committerYAMAMOTO Takashi <yamamoto@midokura.com>
Mon, 10 Aug 2015 03:00:25 +0000 (03:00 +0000)
commitf084686fc61c39cd5034b3dbf92a6001b5a0c887
treefb19b04b3080a1ecf76fca452d17729094e4f751
parente0999554a49408b0fc435308c1cf071cbd9ff310
db_base_plugin_v2: Avoid creating another session

Instead of get_admin_context(), use context.elevated() to avoid
creating another DB session.

get_admin_context().session creates an independent DB session,
while ctx.elevated().session shares the original context's session.
Generally it's better to avoid using multiple DB sessions in
a single thread as it's a bad idea for various reasons:
- They can yield inconsistent views
- They can ends up with a deadlock

Change-Id: I5ef54cbabab552bad28a147254372b0cdc022832
neutron/db/db_base_plugin_v2.py