aboutsummaryrefslogtreecommitdiff
path: root/lib/ovsdb-idl.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-10-31 09:15:14 -0700
committerBen Pfaff <blp@nicira.com>2011-10-31 09:15:14 -0700
commit4fdfe5ccf84c473ad98300cb9050889b033768df (patch)
treebbcc14d86d13f93aba2aa33ebbc497994b293162 /lib/ovsdb-idl.h
parent848e88098fec85336b89c0c652c1d91577c87b11 (diff)
ovsdb-idl: Prevent occasional hang when multiple database clients race.
When a client of the IDL tries to commit a read-modify-write transaction but the database has changed in the meantime, the IDL tells its client to wait for the IDL to change and then try the transaction again by returning TXN_TRY_AGAIN. The "wait for the IDL to change" part is important because there's no point in retrying the transaction before the IDL has received the database updates (the transaction would fail in the same way all over again). However, the logic was incomplete: the database update can be received *before* the reply to the transaction RPC (I think that in the current ovsdb-server implementation this will always happen, in fact). When this happens, the right thing to do is to retry the transaction immediately; if we wait, then we're waiting for an additional change to the database that may never come, causing an indefinite hang. This commit therefore breaks the "try again" IDL commit status code into two, one that means "try again immediately" and another that means "wait for a change then try again". When an update is processed after a transaction is committed but before the reply is received, the "try again now" tells the IDL client not to wait for another database change before retrying its transaction. Bug #5980. Reported-by: Ram Jothikumar <rjothikumar@nicira.com> Reproduced-by: Alex Yip <alex@nicira.com>
Diffstat (limited to 'lib/ovsdb-idl.h')
-rw-r--r--lib/ovsdb-idl.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h
index e7ae6f1d..320a1efc 100644
--- a/lib/ovsdb-idl.h
+++ b/lib/ovsdb-idl.h
@@ -120,9 +120,11 @@ enum ovsdb_idl_txn_status {
TXN_INCOMPLETE, /* Commit in progress, please wait. */
TXN_ABORTED, /* ovsdb_idl_txn_abort() called. */
TXN_SUCCESS, /* Commit successful. */
- TXN_TRY_AGAIN, /* Commit failed because a "verify" operation
+ TXN_AGAIN_WAIT, /* Commit failed because a "verify" operation
* reported an inconsistency, due to a network
- * problem, or other transient failure. */
+ * problem, or other transient failure. Wait
+ * for a change, then try again. */
+ TXN_AGAIN_NOW, /* Same as above but try again immediately. */
TXN_NOT_LOCKED, /* Server hasn't given us the lock yet. */
TXN_ERROR /* Commit failed due to a hard error. */
};