ReadOnly: If record does not exist, upgrade to write-lock
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 28 Oct 2011 01:41:27 +0000 (12:41 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 28 Oct 2011 01:41:27 +0000 (12:41 +1100)
If we attempt a readonly lock request for a record that do not exist (yet)
in the local TDB, then upgrade the request to ask for a write lock and force a
request for migrate the record onto the local node.
This allows the "only request record on second local request for known contended records"
heuristics to try to avoid creating readonly delegations unless we have good reason to
assume it is a contended record.

libctdb/ctdb.c

index b555360e63635176aeebd8c78d77df57ede61186..099ceac0877523720885625940e8c05c9c10d4db 100644 (file)
@@ -806,6 +806,13 @@ static bool try_readrecordlock(struct ctdb_lock *lock, TDB_DATA *data)
                return true;
        }
 
+       /* we dont have the record locally,
+        * drop to writelock to force a migration
+        */
+       if (!hdr && lock->readonly) {
+               lock->readonly = false;
+       }
+
        tdb_chainunlock(lock->ctdb_db->tdb, lock->key);
        free(hdr);
        return NULL;