s3: Use tdb_transaction_start_nonblock in gencache_stabilize
authorVolker Lendecke <vl@samba.org>
Fri, 26 Mar 2010 12:18:52 +0000 (13:18 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 28 Mar 2010 13:25:15 +0000 (15:25 +0200)
This avoids the thundering herd problem when 5000 smbds exit simultaneously
because the network went down.

source3/lib/gencache.c

index 9a4cbc2cd7c049c62ab09f8a98a2a5ad5579cbf2..a78e60a15315efe302cd86b772c6e49365350d17 100644 (file)
@@ -416,8 +416,17 @@ bool gencache_stabilize(void)
                return false;
        }
 
-       res = tdb_transaction_start(cache);
+       res = tdb_transaction_start_nonblock(cache);
        if (res == -1) {
+
+               if (tdb_error(cache) == TDB_ERR_NOLOCK) {
+                       /*
+                        * Someone else already does the stabilize,
+                        * this does not have to be done twice
+                        */
+                       return true;
+               }
+
                DEBUG(10, ("Could not start transaction on gencache.tdb: "
                           "%s\n", tdb_errorstr(cache)));
                return false;