RowEvents can be matched on a value, but that value can change before Event.run() is called
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ovsdbapp |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Row objects are inherently tied to the transaction processing of the Idl. This means that if you have a reference to a Row in one thread, and another thread starts a transaction that modifies that row, the Row can change w/o you knowing it. This is especially noticeable when using the RowEventHandler. It is possible for a Row that is passed to notify() by the Idl class to change between being matched and the RowEvent.run() method being called.
For example a match function might do:
def match_fn(event, row, updates):
return 'my_key' in row.external_ids
def run(event, row, updates):
value = row.external_
and end up getting a KeyError because some transaction in the main thread has deleted the key, so you can no longer use that value to take the action that you were going to take in run().
Reviewed: https:/ /review. opendev. org/753824 /git.openstack. org/cgit/ openstack/ ovsdbapp/ commit/ ?id=dc09d6696fe 175e53c0c1e4a42 63d1a3e1513c9c
Committed: https:/
Submitter: Zuul
Branch: master
commit dc09d6696fe175e 53c0c1e4a4263d1 a3e1513c9c
Author: Terry Wilson <email address hidden>
Date: Wed Sep 23 18:46:53 2020 +0000
Avoid race condition with RowEvent handling
Row objects are inherently tied to the transaction processing of the Idl. dler. It is possible for a Row that is passed to notify() by
This means that if you have a reference to a Row in one thread, and
another thread starts a transaction that modifies that row, the Row can
change w/o you knowing it. This is especially noticeable when using the
RowEventHan
the Idl class to change between being matched and the RowEvent.run()
method being called.
This patch returns an immutable representation of the row by using the
same class that custom indexes use for searching. This should be safe
to pass to other threads.
Change-Id: Iff6e9fdfe032e1 c007e35fc7b0181 14e66acc895
Closes-Bug: #1896816