In the set_target_cell method, we synchronize access to the cached cell
database transaction context manager objects to prevent more than one
thread from using a cell's transaction context manager at the same
time.
In scatter_gather_cells, we're calling target_cell in such a way that
the lock is acquired and released BEFORE the green thread actually
accesses the database in the spawned function. So multiple threads can
access a cell's database transaction context manager and it's possible
for a database transaction to fail with the error:
TypeError: Can't upgrade a READER transaction to a WRITER mid-transaction
because the in-scope transaction context might be in the middle of a
read when a concurrent green thread tries to do a write.
Reviewed: https:/ /review. openstack. org/510691 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=3cc3cc453dc 16e22365bea597c 1be5bb0be57aeb
Committed: https:/
Submitter: Jenkins
Branch: master
commit 3cc3cc453dc16e2 2365bea597c1be5 bb0be57aeb
Author: melanie witt <email address hidden>
Date: Mon Oct 9 20:36:59 2017 +0000
Fix target_cell usage for scatter_ gather_ cells
In the set_target_cell method, we synchronize access to the cached cell
database transaction context manager objects to prevent more than one
thread from using a cell's transaction context manager at the same
time.
In scatter_ gather_ cells, we're calling target_cell in such a way that
the lock is acquired and released BEFORE the green thread actually
accesses the database in the spawned function. So multiple threads can
access a cell's database transaction context manager and it's possible
for a database transaction to fail with the error:
TypeError: Can't upgrade a READER transaction to a WRITER
mid- transaction
because the in-scope transaction context might be in the middle of a
read when a concurrent green thread tries to do a write.
Closes-Bug: #1722404
Change-Id: I07dd4d5aebdc82 e343ec2035dc94c 744e4754c96