Database transactions can fail with "TypeError: Can't upgrade a READER transaction to a WRITER mid-transaction" because of scatter_gather_cells
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
High
|
melanie witt | ||
Ocata |
Confirmed
|
Undecided
|
Unassigned | ||
Pike |
Fix Committed
|
High
|
Matt Riedemann |
Bug Description
I found this while working on a change to improve the usage of the CellDatabases test fixture by defaulting to the 'cell0' database instead of the 'cell1' database.
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_
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
because the in-scope transaction context might be in the middle of a
read when a concurrent green thread tries to do a write.
I saw this happen in the test:
nova.tests.
where a parallel read of instances during a quota check accessed the cell's database transaction context manager at the same time as an instance.save() in the compute/api, causing the instance.save() to fail with "TypeError: Can't upgrade a READER transaction to a WRITER mid-transaction."
Changed in nova: | |
importance: | Undecided → High |
Fix proposed to branch: master /review. openstack. org/510691
Review: https:/