Remove LACOUNT and LACCESSOR and migrate the records immediately.
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 29 Nov 2010 02:07:59 +0000 (13:07 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 17 Feb 2011 23:08:32 +0000 (10:08 +1100)
This concept didnt work out and it is really just as expensive as a full migration
anyway, without the benefit of caching the data for subsequence accesses.

Now, migrate the records immediately on first access.
This will be combined with a "cheap vacuum-lite" for special empty records to
prevent growth of databases.

Later extensions to mimic read-only behaviour of records will include proper shared read-only locking of database records, making the laccessor/lacount read-only access to the data obsolete anyway.

By removing this special case and handling of lacount laccessor makes the codapath where shared read-only locking will be be implemented simpler, and frees up space in the ctdb_ltdb header for use by vacuuming flags as well as read-only locking flags.

(This used to be ctdb commit 155dd1f4885fe142c6f8bd09430f65daf8a17e51)

ctdb/client/ctdb_client.c
ctdb/common/ctdb_ltdb.c
ctdb/include/ctdb_client.h
ctdb/include/ctdb_private.h
ctdb/include/ctdb_protocol.h
ctdb/server/ctdb_call.c
ctdb/server/ctdb_tunables.c

index 5a07a852a8170ddd7eded1afea0dbf82adc8f90c..99ff72d2b1c6d69dfe903d8e679dd696170acab6 100644 (file)
@@ -72,7 +72,7 @@ struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
 */
 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
                    struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx,
-                   TDB_DATA *data, uint32_t caller)
+                   TDB_DATA *data)
 {
        struct ctdb_call_info *c;
        struct ctdb_registered_call *fn;
@@ -105,15 +105,8 @@ int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
                return -1;
        }
 
-       if (header->laccessor != caller) {
-               header->lacount = 0;
-       }
-       header->laccessor = caller;
-       header->lacount++;
-
-       /* we need to force the record to be written out if this was a remote access,
-          so that the lacount is updated */
-       if (c->new_data == NULL && header->laccessor != ctdb->pnn) {
+       /* we need to force the record to be written out if this was a remote access */
+       if (c->new_data == NULL) {
                c->new_data = &c->record_data;
        }
 
@@ -368,7 +361,7 @@ static struct ctdb_client_call_state *ctdb_client_call_local_send(struct ctdb_db
        *(state->call) = *call;
        state->ctdb_db = ctdb_db;
 
-       ret = ctdb_call_local(ctdb_db, state->call, header, state, data, ctdb->pnn);
+       ret = ctdb_call_local(ctdb_db, state->call, header, state, data);
 
        return state;
 }
index 35723714d0c9c6b8e886cf6990c1e4825e569381..200cca41dc1c119fd866770607af463b8981f1a4 100644 (file)
@@ -65,7 +65,6 @@ static void ltdb_initial_header(struct ctdb_db_context *ctdb_db,
        ZERO_STRUCTP(header);
        /* initial dmaster is the lmaster */
        header->dmaster = ctdb_lmaster(ctdb_db->ctdb, &key);
-       header->laccessor = header->dmaster;
 }
 
 
index aa9b2c082397dc360b1ec91e5ff7b6e9441e7add..3dc115f0ccd441ba72793cef30e1cba376e22e9d 100644 (file)
@@ -76,11 +76,6 @@ int ctdb_set_tdb_dir_state(struct ctdb_context *ctdb, const char *dir);
 */
 void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags);
 
-/*
-  set max acess count before a dmaster migration
-*/
-void ctdb_set_max_lacount(struct ctdb_context *ctdb, unsigned count);
-
 /*
   tell ctdb what address to listen on, in transport specific format
 */
index c189a5ff6d1f0c8e4755e2e2d733b05be713b947..3f368704a2b8b87551059d979035c7840532d72e 100644 (file)
@@ -82,7 +82,6 @@ struct ctdb_tunable {
        uint32_t traverse_timeout;
        uint32_t keepalive_interval;
        uint32_t keepalive_limit;
-       uint32_t max_lacount;
        uint32_t recover_timeout;
        uint32_t recover_interval;
        uint32_t election_timeout;
@@ -776,8 +775,8 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd
                                                     struct ctdb_ltdb_header *header);
 
 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
-                   struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx, TDB_DATA *data,
-                   uint32_t caller);
+                   struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx,
+                   TDB_DATA *data);
 
 #define ctdb_reqid_find(ctdb, reqid, type)     (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
 
index baf1790e0b4b5b40388916ba1c3a5eb3d9fb8fa4..199a1bbfe569076f9ca88d3dd753ff60328d5a6d 100644 (file)
@@ -479,8 +479,8 @@ enum ctdb_trans2_commit_error {
 struct ctdb_ltdb_header {
        uint64_t rsn;
        uint32_t dmaster;
-       uint32_t laccessor;
-       uint32_t lacount;
+       uint32_t reserved1;
+       uint32_t reserved2;
 };
 
 
index c5f7e7d43041bb88d810009e2b1dbe0953208de9..d6c08666a6c28fc22403f3745dc48853daf1eeaa 100644 (file)
@@ -297,7 +297,7 @@ static void ctdb_become_dmaster(struct ctdb_db_context *ctdb_db,
                return;
        }
 
-       ctdb_call_local(ctdb_db, state->call, &header, state, &data, ctdb->pnn);
+       ctdb_call_local(ctdb_db, state->call, &header, state, &data);
 
        ret = ctdb_ltdb_unlock(ctdb_db, state->call->key);
        if (ret != 0) {
@@ -465,14 +465,11 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 
        CTDB_UPDATE_STAT(ctdb, max_hop_count, c->hopcount);
 
-       /* if this nodes has done enough consecutive calls on the same record
-          then give them the record
-          or if the node requested an immediate migration
-       */
-       if ( c->hdr.srcnode != ctdb->pnn &&
-            ((header.laccessor == c->hdr.srcnode
-              && header.lacount >= ctdb->tunable.max_lacount)
-             || (c->flags & CTDB_IMMEDIATE_MIGRATION)) ) {
+       /* Try if possible to migrate the record off to the caller node.
+        * From the clients perspective a fetch of the data is just as 
+        * expensive as a migration.
+        */
+       if (c->hdr.srcnode != ctdb->pnn) {
                if (ctdb_db->transaction_active) {
                        DEBUG(DEBUG_INFO, (__location__ " refusing migration"
                              " of key %s while transaction is active\n",
@@ -491,7 +488,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                }
        }
 
-       ctdb_call_local(ctdb_db, call, &header, hdr, &data, c->hdr.srcnode);
+       ctdb_call_local(ctdb_db, call, &header, hdr, &data);
 
        ret = ctdb_ltdb_unlock(ctdb_db, call->key);
        if (ret != 0) {
@@ -707,7 +704,7 @@ struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
        *(state->call) = *call;
        state->ctdb_db = ctdb_db;
 
-       ret = ctdb_call_local(ctdb_db, state->call, header, state, data, ctdb->pnn);
+       ret = ctdb_call_local(ctdb_db, state->call, header, state, data);
 
        event_add_timed(ctdb->ev, state, timeval_zero(), call_local_trigger, state);
 
index 47694b7e597d7a66c1e3f35faeec21017fb21c4a..4cd1b457206e474d5bc42673a894d3b1d071ebbf 100644 (file)
@@ -30,7 +30,6 @@ static const struct {
        { "TraverseTimeout",     20, offsetof(struct ctdb_tunable, traverse_timeout) },
        { "KeepaliveInterval",    5,  offsetof(struct ctdb_tunable, keepalive_interval) },
        { "KeepaliveLimit",       5,  offsetof(struct ctdb_tunable, keepalive_limit) },
-       { "MaxLACount",           7,  offsetof(struct ctdb_tunable, max_lacount) },
        { "RecoverTimeout",      20,  offsetof(struct ctdb_tunable, recover_timeout) },
        { "RecoverInterval",      1,  offsetof(struct ctdb_tunable, recover_interval) },
        { "ElectionTimeout",      3,  offsetof(struct ctdb_tunable, election_timeout) },