idl: Gracefully handle destroying a transaction before receiving its reply.
authorBen Pfaff <blp@nicira.com>
Fri, 15 Jan 2010 23:22:54 +0000 (15:22 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 15 Jan 2010 23:35:38 +0000 (15:35 -0800)
If ovsdb_idl_txn_destroy() is called to destroy a transaction before its
reply has been received from the database server, then until now we would
drop the connection to the database when the reply actually arrived,
because we would have no record of that transaction ID any longer.

Notably, ovs-vswitchd does this: it "fires and forgets" database
transactions.  (Really, it should not do that, but that's a bigger commit.)

This commit fixes the problem by not dropping the database connection in
such a case.

This fixes an observed problem such that sometimes ovs-vsctl took a long
time to complete, which was because ovs-vswitchd was dropping its
connection to the database and backing off.

lib/ovsdb-idl.c

index a4407a57d44ace17f0a4ee199a5dab0eac73d01d..4f547330cf1464708cc232bb020a42602520cba8 100644 (file)
@@ -266,10 +266,12 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
                    && ovsdb_idl_txn_process_reply(idl, msg)) {
             /* ovsdb_idl_txn_process_reply() did everything needful. */
         } else {
-            VLOG_WARN("%s: received unexpected %s message",
-                      jsonrpc_session_get_name(idl->session),
-                      jsonrpc_msg_type_to_string(msg->type));
-            jsonrpc_session_force_reconnect(idl->session);
+            /* This can happen if ovsdb_idl_txn_destroy() is called to destroy
+             * a transaction before we receive the reply, so keep the log level
+             * low. */
+            VLOG_DBG("%s: received unexpected %s message",
+                     jsonrpc_session_get_name(idl->session),
+                     jsonrpc_msg_type_to_string(msg->type));
         }
         if (reply) {
             jsonrpc_session_send(idl->session, reply);