ovsdb-idl: Prevent occasional hang when multiple database clients race.
authorBen Pfaff <blp@nicira.com>
Mon, 31 Oct 2011 16:15:14 +0000 (09:15 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 31 Oct 2011 16:48:02 +0000 (09:48 -0700)
commitc34377e246867b8d81fc6ae7f945186db2e58d04
tree41680c21c7119cf993e3095cbc46aa5ab7f7e1f3
parentce01b7362980a02753f8ff5a8072d37909ec4907
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>
lib/ovsdb-idl.c
lib/ovsdb-idl.h
python/ovs/db/idl.py
tests/ovsdb-idl.at
utilities/ovs-vsctl.c