Explicitly provide a DB context when executing a DB transaction

Bug #1933321 reported by Rodolfo Alonso
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
New
Wishlist
Unassigned

Bug Description

Currently, when Neutron executes DB transaction, if there is no active session (or session at all), ``neutron_lib.context.Context`` creates a default writer session [1].

That's a safeguard for the code written in Neutron but an inefficient way to access to the DB. Reader context allows, for example, the ASYNC_READER mode:
"""
This state indicates that the transaction is a read-only and is
safe to use on an asynchronously updated slave database.
"""

That is supposed to be less blocking than a writer context.

When the ``neutron_lib.context.Context.session`` property is removed, if a transaction is not correctly executed inside a context (reader or writer), the transaction fails.

This bug is just a tracker for all the patches needed to decorate all the DB transactions.

[1]https://github.com/openstack/neutron-lib/blob/c2879ec1739d1425bcc762d4b6584ee241f995ca/neutron_lib/context.py#L157-L161
[2]https://review.opendev.org/c/openstack/neutron-lib/+/791978/4/neutron_lib/context.py#b142

Tags: db
Changed in neutron:
importance: Undecided → Wishlist
Akihiro Motoki (amotoki)
tags: added: db
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.