From e1582e39a1ba7f620e9cea7e5c531dc03e881ced Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Fri, 21 Aug 2020 13:48:52 -0500 Subject: [PATCH] Don't directly access the in-memory DB for NB_Global row Directly accessing the in-memory OVSDB via 'tables' outside of a Command object isn't safe. For example, if we lose connection to the OVSDB and reconnect, the in-memory copy will be replaced by the Connection thread. If we get a call to get_agents() that is handled by the main thread and we look up the value from there, the value we expect may be missing. The dependent patch in ovsdbapp adds some locking to help with this some API commands like lookup() that are heavily used and with ReadOnlyCommands which also aren't processed like normal Command objects inside the connection thread. There will be many more changes in the ml2/ovn code similar to this one, as we directly access the in-memory copy a lot. Depends-On: https://review.opendev.org/#/c/745746/ Change-Id: I328391c88af1ef2f6b1af3787c63d8591fb317b5 Closes-Bug: #1888878 --- .../plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py index de82aa729ab..785227a62e4 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py @@ -166,7 +166,8 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend): @property def nb_global(self): - return next(iter(self.tables['NB_Global'].rows.values())) + return next(iter(self.db_list_rows('NB_Global').execute( + check_error=True))) def create_transaction(self, check_error=False, log_errors=True, bump_nb_cfg=False):