[ovs-dev] [dev master 2/3] bridge: Make ovs-vswitchd run again if status_txn commit fails.

Alex Wang alexw at nicira.com
Mon Jun 2 05:04:29 UTC 2014


This commit adds logic that checks the return value of status_txn
transaction and runs the update again if the transaction fails.

Signed-off-by: Alex Wang <alexw at nicira.com>
---
 vswitchd/bridge.c |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 994e1c9..835de0f 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -173,8 +173,13 @@ static uint64_t connectivity_seqno = LLONG_MIN;
  * update if the previous transaction status is 'TXN_INCOMPLETE'.
  *
  * 'statux_txn' is NULL if there is no ongoing status update.
+ *
+ * If the previous database transaction was incomplete or failed (is not
+ * 'TXN_SUCCESS' or 'TXN_UNCHANGED'), 'status_txn_try_again' is set to true,
+ * which will cause the main thread wake up soon and retry the status update.
  */
 static struct ovsdb_idl_txn *status_txn;
+static bool status_txn_try_again;
 
 /* When the status update transaction returns 'TXN_INCOMPLETE', should register a
  * timeout in 'STATUS_CHECK_AGAIN_MSEC' to check again. */
@@ -2423,7 +2428,7 @@ bridge_run(void)
 
         /* Check the need to update status. */
         seq = seq_read(connectivity_seq_get());
-        if (seq != connectivity_seqno) {
+        if (seq != connectivity_seqno || status_txn_try_again) {
             connectivity_seqno = seq;
             status_txn = ovsdb_idl_txn_create(idl);
             HMAP_FOR_EACH (br, node, &all_bridges) {
@@ -2453,6 +2458,14 @@ bridge_run(void)
             ovsdb_idl_txn_destroy(status_txn);
             status_txn = NULL;
         }
+
+        /* Sets the 'status_txn_try_again' if the transaction fails or
+         * is still incomplete. */
+        if (status == TXN_SUCCESS || status == TXN_UNCOMMITTED) {
+            status_txn_try_again = false;
+        } else {
+            status_txn_try_again = true;
+        }
     }
 
     run_system_stats();
@@ -2486,11 +2499,11 @@ bridge_wait(void)
         poll_timer_wait_until(stats_timer);
     }
 
-    /* If the status database transaction is 'TXN_INCOMPLETE' in this run,
-     * register a timeout in 'STATUS_CHECK_AGAIN_MSEC'.  Else, wait on the
-     * global connectivity sequence number.  Note, this also helps batch
-     * multiple status changes into one transaction. */
-    if (status_txn) {
+    /* If the status update to database needs to be run again (transaction
+     * fails or incomplete), registers a timeout in 'STATUS_CHECK_AGAIN_MSEC'.
+     * Else, waits on the global connectivity sequence number.  Note, this also
+     * helps batch multiple status changes into one transaction. */
+    if (status_txn_try_again) {
         poll_timer_wait_until(time_msec() + STATUS_CHECK_AGAIN_MSEC);
     } else {
         seq_wait(connectivity_seq_get(), connectivity_seqno);
-- 
1.7.9.5




More information about the dev mailing list