RowEvents can be matched on a value, but that value can change before Event.run() is called

Bug #1896816 reported by Terry Wilson
6
This bug affects 1 person
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_ids['my_key']

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().

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ovsdbapp (master)

Reviewed: https://review.opendev.org/753824
Committed: https://git.openstack.org/cgit/openstack/ovsdbapp/commit/?id=dc09d6696fe175e53c0c1e4a4263d1a3e1513c9c
Submitter: Zuul
Branch: master

commit dc09d6696fe175e53c0c1e4a4263d1a3e1513c9c
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.
    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.

    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: Iff6e9fdfe032e1c007e35fc7b018114e66acc895
    Closes-Bug: #1896816

Changed in ovsdbapp:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ovsdbapp (stable/victoria)

Fix proposed to branch: stable/victoria
Review: https://review.opendev.org/755855

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ovsdbapp (stable/ussuri)

Fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/755856

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ovsdbapp (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/755857

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

Reviewed: https://review.opendev.org/755855
Committed: https://git.openstack.org/cgit/openstack/ovsdbapp/commit/?id=87b747a7c8c1a3a9ae3d2b45778b02bde0463163
Submitter: Zuul
Branch: stable/victoria

commit 87b747a7c8c1a3a9ae3d2b45778b02bde0463163
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.
    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.

    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: Iff6e9fdfe032e1c007e35fc7b018114e66acc895
    Closes-Bug: #1896816
    (cherry picked from commit dc09d6696fe175e53c0c1e4a4263d1a3e1513c9c)

tags: added: in-stable-victoria
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ovsdbapp (stable/ussuri)

Reviewed: https://review.opendev.org/755856
Committed: https://git.openstack.org/cgit/openstack/ovsdbapp/commit/?id=218cf7cc0b7da4a64ff30cdeaf8bf1cbb8ec66a2
Submitter: Zuul
Branch: stable/ussuri

commit 218cf7cc0b7da4a64ff30cdeaf8bf1cbb8ec66a2
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.
    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.

    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.

    Conflicts:
        ovsdbapp/backend/ovs_idl/idlutils.py

    Change-Id: Iff6e9fdfe032e1c007e35fc7b018114e66acc895
    Closes-Bug: #1896816
    (cherry picked from commit dc09d6696fe175e53c0c1e4a4263d1a3e1513c9c)

tags: added: in-stable-ussuri
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ovsdbapp (stable/train)

Reviewed: https://review.opendev.org/755857
Committed: https://git.openstack.org/cgit/openstack/ovsdbapp/commit/?id=ae82ebf9829608ad158476f12dce02cef61c7ea6
Submitter: Zuul
Branch: stable/train

commit ae82ebf9829608ad158476f12dce02cef61c7ea6
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.
    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.

    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.

    Conflicts:
        ovsdbapp/backend/ovs_idl/idlutils.py

    Change-Id: Iff6e9fdfe032e1c007e35fc7b018114e66acc895
    Closes-Bug: #1896816
    (cherry picked from commit dc09d6696fe175e53c0c1e4a4263d1a3e1513c9c)
    (cherry picked from commit 218cf7cc0b7da4a64ff30cdeaf8bf1cbb8ec66a2)

tags: added: in-stable-train
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.