[ovs-dev] [PATCH] ovn-northd: Recalculate db mappings if the txn returns TXN_ERROR
Numan Siddique
nusiddiq at redhat.com
Sun Dec 13 14:16:52 UTC 2015
Fixes the issue
Reported-at: http://openvswitch.org/pipermail/discuss/2015-November/019443.html
Signed-off-by: Numan Siddique <nusiddiq at redhat.com>
---
lib/ovsdb-idl.c | 1 +
lib/ovsdb-idl.h | 1 +
ovn/northd/ovn-northd.c | 21 ++++++++++++++++++++-
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 0d02ae8..2e536c9 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -3209,6 +3209,7 @@ ovsdb_idl_loop_commit_and_wait(struct ovsdb_idl_loop *loop)
ovsdb_idl_txn_destroy(txn);
loop->committing_txn = NULL;
}
+ loop->last_commit_status = status;
}
ovsdb_idl_wait(loop->idl);
diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h
index 4c66ae0..5f7f2fc 100644
--- a/lib/ovsdb-idl.h
+++ b/lib/ovsdb-idl.h
@@ -266,6 +266,7 @@ struct ovsdb_idl_loop {
unsigned int precommit_seqno;
struct ovsdb_idl_txn *open_txn;
+ enum ovsdb_idl_txn_status last_commit_status;
};
#define OVSDB_IDL_LOOP_INITIALIZER(IDL) { .idl = (IDL) }
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 270b116..be4d6a8 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -1912,6 +1912,8 @@ main(int argc, char *argv[])
/* Main loop. */
exiting = false;
+ bool ovnnb_changes_pending = false;
+ bool ovnsb_changes_pending = false;
while (!exiting) {
struct northd_context ctx = {
.ovnnb_idl = ovnnb_idl_loop.idl,
@@ -1922,11 +1924,28 @@ main(int argc, char *argv[])
if (ovnnb_seqno != ovsdb_idl_get_seqno(ctx.ovnnb_idl)) {
ovnnb_seqno = ovsdb_idl_get_seqno(ctx.ovnnb_idl);
- ovnnb_db_run(&ctx);
+ ovnnb_changes_pending = true;
}
if (ovnsb_seqno != ovsdb_idl_get_seqno(ctx.ovnsb_idl)) {
ovnsb_seqno = ovsdb_idl_get_seqno(ctx.ovnsb_idl);
+ ovnsb_changes_pending = true;
+ }
+
+ /*
+ * We need to recalculate the mappings to the OVN-sb db
+ * - If the OVN-nb db has changed or
+ * - If the previous update to the OVN-sb is not yet completed.
+ */
+ if (ovnnb_changes_pending ||
+ ovnsb_idl_loop.last_commit_status == TXN_ERROR) {
+ ovnnb_db_run(&ctx);
+ ovnnb_changes_pending = false;
+ }
+
+ if (ovnsb_changes_pending ||
+ ovnnb_idl_loop.last_commit_status == TXN_ERROR) {
ovnsb_db_run(&ctx);
+ ovnsb_changes_pending = false;
}
unixctl_server_run(unixctl);
--
2.5.0
More information about the dev
mailing list