Message ID | 20211013161314.2641664-1-twilson@redhat.com |
---|---|
State | Accepted |
Commit | db25a995618b931d88e592089624cc81e5c70602 |
Headers | show |
Series | [ovs-dev,branch-2.14] python: idl: Avoid sending transactions when the DB is not synced up. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
On Wed, Oct 13, 2021 at 11:13 AM Terry Wilson <twilson@redhat.com> wrote: > > This ports the C IDL change f50714b to the Python IDL: > > Until now the code here would happily try to send transactions to the > database server even if the database connection was not in the correct > state. In some cases this could lead to strange behavior, such as sending > a database transaction for a database that the IDL had just learned did not > exist on the server. > > Signed-off-by: Terry Wilson <twilson@redhat.com> > (cherry picked from commit 34fbdc41084c16f855efa9c56086b03644408b7d) > --- > python/ovs/db/idl.py | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py > index 4cf79cf94..5a17cbd00 100644 > --- a/python/ovs/db/idl.py > +++ b/python/ovs/db/idl.py > @@ -101,6 +101,7 @@ class Idl(object): > IDL_S_SERVER_MONITOR_REQUESTED = 2 > IDL_S_DATA_MONITOR_REQUESTED = 3 > IDL_S_DATA_MONITOR_COND_REQUESTED = 4 > + IDL_S_MONITORING = 5 > > def __init__(self, remote, schema_helper, probe_interval=None, > leader_only=True): > @@ -294,6 +295,7 @@ class Idl(object): > else: > assert self.state == self.IDL_S_DATA_MONITOR_REQUESTED > self.__parse_update(msg.result, OVSDB_UPDATE) > + self.state = self.IDL_S_MONITORING > > except error.Error as e: > vlog.err("%s: parse error in received schema: %s" > @@ -1468,6 +1470,11 @@ class Transaction(object): > if self != self.idl.txn: > return self._status > > + if self.idl.state != Idl.IDL_S_MONITORING: > + self._status = Transaction.TRY_AGAIN > + self.__disassemble() > + return self._status > + > # If we need a lock but don't have it, give up quickly. > if self.idl.lock_name and not self.idl.has_lock: > self._status = Transaction.NOT_LOCKED > -- > 2.31.1 > This should also apply cleanly/pass tests for 2.13. Thanks!
On 10/13/21 18:16, Terry Wilson wrote: > On Wed, Oct 13, 2021 at 11:13 AM Terry Wilson <twilson@redhat.com> wrote: >> >> This ports the C IDL change f50714b to the Python IDL: >> >> Until now the code here would happily try to send transactions to the >> database server even if the database connection was not in the correct >> state. In some cases this could lead to strange behavior, such as sending >> a database transaction for a database that the IDL had just learned did not >> exist on the server. >> >> Signed-off-by: Terry Wilson <twilson@redhat.com> >> (cherry picked from commit 34fbdc41084c16f855efa9c56086b03644408b7d) >> --- >> python/ovs/db/idl.py | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py >> index 4cf79cf94..5a17cbd00 100644 >> --- a/python/ovs/db/idl.py >> +++ b/python/ovs/db/idl.py >> @@ -101,6 +101,7 @@ class Idl(object): >> IDL_S_SERVER_MONITOR_REQUESTED = 2 >> IDL_S_DATA_MONITOR_REQUESTED = 3 >> IDL_S_DATA_MONITOR_COND_REQUESTED = 4 >> + IDL_S_MONITORING = 5 >> >> def __init__(self, remote, schema_helper, probe_interval=None, >> leader_only=True): >> @@ -294,6 +295,7 @@ class Idl(object): >> else: >> assert self.state == self.IDL_S_DATA_MONITOR_REQUESTED >> self.__parse_update(msg.result, OVSDB_UPDATE) >> + self.state = self.IDL_S_MONITORING >> >> except error.Error as e: >> vlog.err("%s: parse error in received schema: %s" >> @@ -1468,6 +1470,11 @@ class Transaction(object): >> if self != self.idl.txn: >> return self._status >> >> + if self.idl.state != Idl.IDL_S_MONITORING: >> + self._status = Transaction.TRY_AGAIN >> + self.__disassemble() >> + return self._status >> + >> # If we need a lock but don't have it, give up quickly. >> if self.idl.lock_name and not self.idl.has_lock: >> self._status = Transaction.NOT_LOCKED >> -- >> 2.31.1 >> > > This should also apply cleanly/pass tests for 2.13. Thanks! Thanks for the backport! Applied to 2.14 and 2.13. Best regards, Ilya Maximets.
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py index 4cf79cf94..5a17cbd00 100644 --- a/python/ovs/db/idl.py +++ b/python/ovs/db/idl.py @@ -101,6 +101,7 @@ class Idl(object): IDL_S_SERVER_MONITOR_REQUESTED = 2 IDL_S_DATA_MONITOR_REQUESTED = 3 IDL_S_DATA_MONITOR_COND_REQUESTED = 4 + IDL_S_MONITORING = 5 def __init__(self, remote, schema_helper, probe_interval=None, leader_only=True): @@ -294,6 +295,7 @@ class Idl(object): else: assert self.state == self.IDL_S_DATA_MONITOR_REQUESTED self.__parse_update(msg.result, OVSDB_UPDATE) + self.state = self.IDL_S_MONITORING except error.Error as e: vlog.err("%s: parse error in received schema: %s" @@ -1468,6 +1470,11 @@ class Transaction(object): if self != self.idl.txn: return self._status + if self.idl.state != Idl.IDL_S_MONITORING: + self._status = Transaction.TRY_AGAIN + self.__disassemble() + return self._status + # If we need a lock but don't have it, give up quickly. if self.idl.lock_name and not self.idl.has_lock: self._status = Transaction.NOT_LOCKED
This ports the C IDL change f50714b to the Python IDL: Until now the code here would happily try to send transactions to the database server even if the database connection was not in the correct state. In some cases this could lead to strange behavior, such as sending a database transaction for a database that the IDL had just learned did not exist on the server. Signed-off-by: Terry Wilson <twilson@redhat.com> (cherry picked from commit 34fbdc41084c16f855efa9c56086b03644408b7d) --- python/ovs/db/idl.py | 7 +++++++ 1 file changed, 7 insertions(+)