ovn-northd: Only run idl loop if something changed.
authorJoe Stringer <joe@ovn.org>
Fri, 4 Dec 2015 01:11:49 +0000 (17:11 -0800)
committerJustin Pettit <jpettit@ovn.org>
Fri, 4 Dec 2015 07:02:39 +0000 (23:02 -0800)
Before refactoring the main loop to reuse ovsdb_idl_loop_* functions, we
would use a sequence to see if anything changed in NB database to
compute and notify the SB database, and vice versa. This logic got
dropped with the refactor, causing a testsuite failure in the ovn-sbctl
test. Reintroduce the IDL sequence number checking.

Fixes: 331e7aefe1c6 ("ovn-northd: Refactor main loop to use ovsdb_idl_loop_*
functions")
Suggested-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Tested-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Ben Pfaff <blp@ovn.org>
ovn/northd/ovn-northd.c

index 01f289d..7f3a92e 100644 (file)
@@ -1799,6 +1799,7 @@ int
 main(int argc, char *argv[])
 {
     extern struct vlog_module VLM_reconnect;
+    unsigned int ovnnb_seqno, ovnsb_seqno;
     int res = EXIT_SUCCESS;
     struct unixctl_server *unixctl;
     int retval;
@@ -1868,6 +1869,9 @@ main(int argc, char *argv[])
     add_column_noalert(ovnsb_idl_loop.idl, &sbrec_port_binding_col_mac);
     ovsdb_idl_add_column(ovnsb_idl_loop.idl, &sbrec_port_binding_col_chassis);
 
+    ovnnb_seqno = ovsdb_idl_get_seqno(ovnnb_idl_loop.idl);
+    ovnsb_seqno = ovsdb_idl_get_seqno(ovnsb_idl_loop.idl);
+
     /* Main loop. */
     exiting = false;
     while (!exiting) {
@@ -1878,8 +1882,14 @@ main(int argc, char *argv[])
             .ovnsb_txn = ovsdb_idl_loop_run(&ovnsb_idl_loop),
         };
 
-        ovnnb_db_run(&ctx);
-        ovnsb_db_run(&ctx);
+        if (ovnnb_seqno != ovsdb_idl_get_seqno(ctx.ovnnb_idl)) {
+            ovnnb_seqno = ovsdb_idl_get_seqno(ctx.ovnnb_idl);
+            ovnnb_db_run(&ctx);
+        }
+        if (ovnsb_seqno != ovsdb_idl_get_seqno(ctx.ovnsb_idl)) {
+            ovnsb_seqno = ovsdb_idl_get_seqno(ctx.ovnsb_idl);
+            ovnsb_db_run(&ctx);
+        }
 
         unixctl_server_run(unixctl);
         unixctl_server_wait(unixctl);