Comment 23 for bug 1746509

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/pike)

Reviewed: https://review.openstack.org/555923
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=9a6310ddc4ec2eeef39a51dd5a2fa86ae9c4b972
Submitter: Zuul
Branch: stable/pike

commit 9a6310ddc4ec2eeef39a51dd5a2fa86ae9c4b972
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
      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)