During testing of the implementation of cooperative multitasking
in the ovsdb-server we noticed that the very first yield being
called in the jsonrpc-server always fired.

This indicates that the operations being after/before storage run
is taking too long as it currently is.

Moving the storage run section to the top of the main loop lead
to successful results using less yield calls as documented in the
commit message of the next commit in this series.

Signed-off-by: Frode Nordahl <[email protected]>
---
 ovsdb/ovsdb-server.c | 56 +++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 4d29043f4..e1d4b1125 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -195,6 +195,34 @@ main_loop(struct server_config *config,
     ssl_error = NULL;
     remotes_error = NULL;
     while (!*exiting) {
+        SHASH_FOR_EACH_SAFE (node, all_dbs) {
+            struct db *db = node->data;
+
+            ovsdb_storage_run(db->db->storage);
+            read_db(config, db);
+            /* Run triggers after storage_run and read_db to make sure new raft
+             * updates are utilized in current iteration. */
+            if (ovsdb_trigger_run(db->db, time_msec())) {
+                /* The message below is currently the only reason to disconnect
+                 * all clients. */
+                ovsdb_jsonrpc_server_reconnect(
+                    jsonrpc, false,
+                    xasprintf("committed %s database schema conversion",
+                              db->db->name));
+            }
+            if (ovsdb_storage_is_dead(db->db->storage)) {
+                VLOG_INFO("%s: removing database because storage disconnected "
+                          "permanently", node->name);
+                remove_db(config, node,
+                          xasprintf("removing database %s because storage "
+                                    "disconnected permanently", node->name));
+            } else if (!ovsdb_snapshot_in_progress(db->db)
+                       && (ovsdb_storage_should_snapshot(db->db->storage) ||
+                           ovsdb_snapshot_ready(db->db))) {
+                log_and_free_error(ovsdb_snapshot(db->db, trim_memory));
+            }
+        }
+
         memory_run();
         if (memory_should_report()) {
             struct simap usage;
@@ -221,6 +249,7 @@ main_loop(struct server_config *config,
             reconfigure_remotes(jsonrpc, all_dbs, remotes),
             &remotes_error);
         report_error_if_changed(reconfigure_ssl(all_dbs), &ssl_error);
+
         ovsdb_jsonrpc_server_run(jsonrpc);
 
         if (*is_backup) {
@@ -233,33 +262,6 @@ main_loop(struct server_config *config,
 
         ovsdb_relay_run();
 
-        SHASH_FOR_EACH_SAFE (node, all_dbs) {
-            struct db *db = node->data;
-
-            ovsdb_storage_run(db->db->storage);
-            read_db(config, db);
-            /* Run triggers after storage_run and read_db to make sure new raft
-             * updates are utilized in current iteration. */
-            if (ovsdb_trigger_run(db->db, time_msec())) {
-                /* The message below is currently the only reason to disconnect
-                 * all clients. */
-                ovsdb_jsonrpc_server_reconnect(
-                    jsonrpc, false,
-                    xasprintf("committed %s database schema conversion",
-                              db->db->name));
-            }
-            if (ovsdb_storage_is_dead(db->db->storage)) {
-                VLOG_INFO("%s: removing database because storage disconnected "
-                          "permanently", node->name);
-                remove_db(config, node,
-                          xasprintf("removing database %s because storage "
-                                    "disconnected permanently", node->name));
-            } else if (!ovsdb_snapshot_in_progress(db->db)
-                       && (ovsdb_storage_should_snapshot(db->db->storage) ||
-                           ovsdb_snapshot_ready(db->db))) {
-                log_and_free_error(ovsdb_snapshot(db->db, trim_memory));
-            }
-        }
         if (run_process) {
             process_run();
             if (process_exited(run_process)) {
-- 
2.34.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to