Move _make_instance_list call outside of DB transaction context
The _make_instance_list method is used to make an InstanceList object
out of database dict-like instance objects. It's possible while making
the list that the various _from_db_object methods that are called might
do their own database writes.
Currently, we're calling _make_instance_list nested inside of a 'reader'
database transaction context and we hit the error:
TypeError: Can't upgrade a READER transaction to a WRITER
mid-transaction
during the _make_instance_list call if anything tries to do a database
write. The scenario encountered was after an upgrade to Pike, older
service records without UUIDs were attempted to be updated with UUIDs
upon access, and that access happened to be during an instance list,
so it failed when trying to write the service UUID while nested inside
the 'reader' database transaction context.
This simply moves the _make_instance_list method call out from the
@db.select_db_reader_mode decorated _get_by_filters_impl method to the
get_by_filters method to remove the nesting.
Closes-Bug: #1746509
Change-Id: Ifadf408802cc15eb9769d2dc1fc920426bb7fc20
(cherry picked from commit b1ed92c7af01a9ac7e122a541ce1bdb9be0524c4)
(cherry picked from commit 22b2a8e4645e15990a0f130a8866746497c5b5ee)
Reviewed: https:/ /review. openstack. org/555923 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=9a6310ddc4e c2eeef39a51dd5a 2fa86ae9c4b972
Committed: https:/
Submitter: Zuul
Branch: stable/pike
commit 9a6310ddc4ec2ee ef39a51dd5a2fa8 6ae9c4b972
Author: melanie witt <email address hidden>
Date: Wed Mar 21 22:57:50 2018 +0000
Move _make_instance_list call outside of DB transaction context
The _make_instance_list method is used to make an InstanceList object
out of database dict-like instance objects. It's possible while making
the list that the various _from_db_object methods that are called might
do their own database writes.
Currently, we're calling _make_instance_list nested inside of a 'reader'
database transaction context and we hit the error:
TypeError: Can't upgrade a READER transaction to a WRITER transaction
mid-
during the _make_instance_list call if anything tries to do a database
write. The scenario encountered was after an upgrade to Pike, older
service records without UUIDs were attempted to be updated with UUIDs
upon access, and that access happened to be during an instance list,
so it failed when trying to write the service UUID while nested inside
the 'reader' database transaction context.
This simply moves the _make_instance_list method call out from the select_ db_reader_ mode decorated _get_by_ filters_ impl method to the
@db.
get_by_filters method to remove the nesting.
Closes-Bug: #1746509
Change-Id: Ifadf408802cc15 eb9769d2dc1fc92 0426bb7fc20 c7e122a541ce1bd b9be0524c4) 90a0f130a886674 6497c5b5ee)
(cherry picked from commit b1ed92c7af01a9a
(cherry picked from commit 22b2a8e4645e159