Add retry on case of sqlite3.InterfaceError on FT

After a thorough review of the issue, it looks like that the problem
does not originate from the base code of ovn-octavia-provider or
neutron. Other projects are also experiencing this problem,
indicating that it likely stems from a different source or set of
libraries [1].

To minimize the need for extensive rechecks on future patches, this
patch introduces a retry mechanism, utilizing tenacity, to the
affected methods.

Once the root cause of the problem '(sqlite3.InterfaceError) Cursor
needed to be reset because of commit/rollback and can no longer be
fetched from,' is identified and resolved, this patch should be
reverted.

[1] https://opensearch.logs.openstack.org/_dashboards/app/discover/?security_tenant=global#/?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-30d,to:now))&_a=(columns:!(_source),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:'94869730-aea8-11ec-9e6a-83741af3fdcd',key:build_status,negate:!f,params:(query:FAILURE),type:phrase),query:(match_phrase:(build_status:FAILURE)))),index:'94869730-aea8-11ec-9e6a-83741af3fdcd',interval:auto,query:(language:kuery,query:'message:%22Cursor%20needed%20to%20be%20reset%20because%20of%20commit%2F%22'),sort:!())

Related-Bug: #2020195
Change-Id: Ia7a9b5230f9cf56de8278b736022240a780130d6
This commit is contained in:
Fernando Royo 2023-05-19 13:15:02 +02:00
parent 52ceb9a937
commit 0285967056

View File

@ -21,11 +21,14 @@ from neutron_lib.plugins import directory
from octavia_lib.api.drivers import data_models as octavia_data_model
from octavia_lib.api.drivers import driver_lib
from octavia_lib.common import constants as o_constants
from oslo_db import exception as odb_exc
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from ovsdbapp.schema.ovn_northbound import impl_idl as nb_idl_ovn
from ovsdbapp.schema.ovn_southbound import impl_idl as sb_idl_ovn
import tenacity
# NOTE(mjozefcz): We need base neutron functionals because we need
# mechanism driver and l3 plugin.
from neutron.tests.functional import base
@ -259,6 +262,11 @@ class TestOvnOctaviaBase(base.TestOVNFunctionalBase,
return lb_uuid in ls_lbs
return False
@tenacity.retry(
retry=tenacity.retry_if_exception_type(odb_exc.DBError),
wait=tenacity.wait_exponential(),
stop=tenacity.stop_after_attempt(3),
reraise=True)
def _create_router(self, name, gw_info=None):
router = {'router':
{'name': name,
@ -269,6 +277,11 @@ class TestOvnOctaviaBase(base.TestOVNFunctionalBase,
router = self.l3_plugin.create_router(self.context, router)
return router['id']
@tenacity.retry(
retry=tenacity.retry_if_exception_type(odb_exc.DBError),
wait=tenacity.wait_exponential(),
stop=tenacity.stop_after_attempt(3),
reraise=True)
def _create_net(self, name, cidr, router_id=None):
n1 = self._make_network(self.fmt, name, True)
res = self._create_subnet(self.fmt, n1['network']['id'],