Revert "Make fetch_locked more scalable"
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 15 Dec 2009 03:26:28 +0000 (14:26 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 15 Dec 2009 03:26:28 +0000 (14:26 +1100)
This reverts commit 5736e17c139c9a8049e235429aeae0c6c9d0e93d.

include/ctdb_private.h
server/ctdb_call.c
server/ctdb_control.c
server/ctdb_daemon.c
server/ctdb_recover.c
server/ctdb_recoverd.c
server/ctdb_tunables.c

index d49e05143d86d9caf0aded2521df14c29e3374f3..b6c4b2fa1af34b277fa21eb8785715bdc4ba5fda 100644 (file)
@@ -95,7 +95,6 @@ struct ctdb_tunable {
        uint32_t traverse_timeout;
        uint32_t keepalive_interval;
        uint32_t keepalive_limit;
-       uint32_t holdback_cleanup_interval;
        uint32_t max_lacount;
        uint32_t recover_timeout;
        uint32_t recover_interval;
@@ -396,7 +395,6 @@ struct ctdb_context {
        uint32_t recovery_mode;
        TALLOC_CTX *tickle_update_context;
        TALLOC_CTX *keepalive_ctx;
-       struct timed_event *holdback_cleanup_te;
        struct ctdb_tunable tunable;
        enum ctdb_freeze_mode freeze_mode[NUM_DB_PRIORITIES+1];
        struct ctdb_freeze_handle *freeze_handles[NUM_DB_PRIORITIES+1];
@@ -478,17 +476,6 @@ struct ctdb_db_context {
        struct ctdb_traverse_local_handle *traverse;
        bool transaction_active;
        struct ctdb_vacuum_handle *vacuum_handle;
-
-       /*
-        * The keys to hold back until CTDB_CONTROL_GOTIT is being
-        * sent by a client having forced a migration to us.
-        */
-       uint8_t **holdback_keys;
-
-       /*
-        * The CTDB_REQ_CALLs held back according to "holdback_keys"
-        */
-       struct ctdb_req_header **held_back;
 };
 
 
@@ -638,7 +625,6 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_CLEAR_LOG               = 118,
                    CTDB_CONTROL_TRANS3_COMMIT           = 119,
                    CTDB_CONTROL_GET_DB_SEQNUM           = 120,
-                   CTDB_CONTROL_GOTIT                   = 121,
 };     
 
 /*
@@ -1182,11 +1168,6 @@ struct ctdb_control_wipe_database {
        uint32_t transaction_id;
 };
 
-struct ctdb_control_gotit {
-       uint32_t db_id;
-       uint8_t key[1];
-};
-
 /*
   state of a in-progress ctdb call in client
 */
@@ -1255,10 +1236,6 @@ void ctdb_start_keepalive(struct ctdb_context *ctdb);
 void ctdb_stop_keepalive(struct ctdb_context *ctdb);
 int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA data, bool *async_reply);
 
-void ctdb_start_holdback_cleanup(struct ctdb_context *ctdb);
-void ctdb_stop_holdback_cleanup(struct ctdb_context *ctdb);
-int32_t ctdb_control_gotit(struct ctdb_context *ctdb, TDB_DATA indata);
-
 
 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
 void ctdb_call_resend_all(struct ctdb_context *ctdb);
index 443e6d2d3e832f74a10bb9af2459eedd7b214436..82c1304e07591ff7eb7a7c645bed01d500254142 100644 (file)
@@ -231,30 +231,6 @@ static void ctdb_call_send_dmaster(struct ctdb_db_context *ctdb_db,
        talloc_free(r);
 }
 
-static void ctdb_hold_back_key(struct ctdb_db_context *db, TDB_DATA key)
-{
-       size_t num_keys;
-       uint8_t **tmp;
-
-       DEBUG(DEBUG_INFO, ("Holding back key %08x\n", ctdb_hash(&key)));
-
-       num_keys = talloc_array_length(db->holdback_keys);
-       tmp = talloc_realloc(db, db->holdback_keys, uint8_t *, num_keys+1);
-       if (tmp == NULL) {
-               DEBUG(DEBUG_ERR, ("talloc_realloc failed\n"));
-               return;
-       }
-       db->holdback_keys = tmp;
-
-       db->holdback_keys[num_keys] = (uint8_t *)talloc_memdup(
-               db->holdback_keys, key.dptr, key.dsize);
-       if (db->holdback_keys[num_keys] == NULL) {
-               DEBUG(DEBUG_ERR, ("talloc_memdup failed\n"));
-               db->holdback_keys = talloc_realloc(db, db->holdback_keys,
-                                                  uint8_t *, num_keys);
-       }
-}
-
 /*
   called when a CTDB_REPLY_DMASTER packet comes in, or when the lmaster
   gets a CTDB_REQUEST_DMASTER for itself. We become the dmaster.
@@ -298,8 +274,6 @@ static void ctdb_become_dmaster(struct ctdb_db_context *ctdb_db,
                return;
        }
 
-       ctdb_hold_back_key(ctdb_db, key);
-
        ctdb_call_local(ctdb_db, state->call, &header, state, &data, ctdb->pnn);
 
        ctdb_ltdb_unlock(ctdb_db, state->call->key);
@@ -394,47 +368,6 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
        }
 }
 
-/*
- * Did we just pull the dmaster of the record for a client fetch_lock,
- * so should we hold it back a while and thus give our client the
- * chance to do its own tdb_lock?
- */
-
-static bool ctdb_held_back(struct ctdb_db_context *db, TDB_DATA key,
-                          struct ctdb_req_header *hdr)
-{
-       int i;
-       size_t num_keys = talloc_array_length(db->holdback_keys);
-       size_t num_hdrs;
-       struct ctdb_req_header **tmp;
-
-       for (i=0; i<num_keys; i++) {
-               uint8_t *hold_key = db->holdback_keys[i];
-               size_t keylength = talloc_array_length(hold_key);
-
-               if ((keylength == key.dsize)
-                   && (memcmp(hold_key, key.dptr, keylength) == 0)) {
-                       break;
-               }
-       }
-       if (i == num_keys) {
-               return false;
-       }
-       DEBUG(DEBUG_DEBUG, ("holding back record %08x after migration\n",
-                           ctdb_hash(&key)));
-
-       num_hdrs = talloc_array_length(db->held_back);
-
-       tmp = talloc_realloc(db, db->held_back, struct ctdb_req_header *,
-                            num_hdrs + 1);
-       if (tmp == NULL) {
-               DEBUG(DEBUG_ERR, (__location__ "talloc_realloc failed\n"));
-               return false;
-       }
-       db->held_back = tmp;
-       db->held_back[num_hdrs] = talloc_move(db->held_back, &hdr);
-       return true;
-}
 
 /*
   called when a CTDB_REQ_CALL packet comes in
@@ -500,13 +433,6 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                ctdb->statistics.max_hop_count = c->hopcount;
        }
 
-       if ((c->flags & CTDB_IMMEDIATE_MIGRATION)
-           && (ctdb_held_back(ctdb_db, call->key, hdr))) {
-               talloc_free(data.dptr);
-               ctdb_ltdb_unlock(ctdb_db, call->key);
-               return;
-       }
-
        /* 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
@@ -866,112 +792,3 @@ void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode)
 
        talloc_free(r);
 }
-
-static void ctdb_holdback_cleanup(struct event_context *ev,
-                                 struct timed_event *te,
-                                 struct timeval t, void *private_data)
-{
-       struct ctdb_context *ctdb = talloc_get_type(private_data,
-                                                   struct ctdb_context);
-        struct ctdb_db_context *ctdb_db;
-
-       DEBUG(DEBUG_INFO, ("running ctdb_holdback_cleanup\n"));
-
-       if (te != ctdb->holdback_cleanup_te) {
-               ctdb_fatal(ctdb, "te != ctdb->holdback_cleanup_te");
-       }
-
-        for (ctdb_db=ctdb->db_list; ctdb_db; ctdb_db=ctdb_db->next) {
-               size_t i, num_heldback;
-
-               talloc_free(ctdb_db->holdback_keys);
-               ctdb_db->holdback_keys = NULL;
-
-               num_heldback = talloc_array_length(ctdb_db->held_back);
-               for (i=0; i<num_heldback; i++) {
-                       ctdb_queue_packet(ctdb, ctdb_db->held_back[i]);
-               }
-               talloc_free(ctdb_db->held_back);
-               ctdb_db->held_back = NULL;
-        }
-
-       ctdb->holdback_cleanup_te = event_add_timed(
-               ctdb->ev, ctdb, timeval_current_ofs(
-                       0, ctdb->tunable.holdback_cleanup_interval * 1000),
-               ctdb_holdback_cleanup, ctdb);
-}
-
-void ctdb_start_holdback_cleanup(struct ctdb_context *ctdb)
-{
-       ctdb->holdback_cleanup_te = event_add_timed(
-               ctdb->ev, ctdb, timeval_current_ofs(
-                       0, ctdb->tunable.holdback_cleanup_interval * 1000),
-               ctdb_holdback_cleanup, ctdb);
-
-       CTDB_NO_MEMORY_FATAL(ctdb, ctdb->holdback_cleanup_te);
-
-       DEBUG(DEBUG_NOTICE,("Holdback cleanup has been started\n"));
-}
-
-void ctdb_stop_holdback_cleanup(struct ctdb_context *ctdb)
-{
-       talloc_free(ctdb->holdback_cleanup_te);
-       ctdb->holdback_cleanup_te = NULL;
-}
-
-int32_t ctdb_control_gotit(struct ctdb_context *ctdb, TDB_DATA indata)
-{
-       struct ctdb_control_gotit *c =
-               (struct ctdb_control_gotit *)indata.dptr;
-       struct ctdb_db_context *db;
-       size_t i, num_keys, num_heldback;
-       TDB_DATA key;
-
-       if (indata.dsize < sizeof(struct ctdb_control_gotit)) {
-               DEBUG(DEBUG_ERR, (__location__ "Invalid data size %d\n",
-                                 (int)indata.dsize));
-               return -1;
-       }
-       db = find_ctdb_db(ctdb, c->db_id);
-       if (db == NULL) {
-               DEBUG(DEBUG_ERR, ("Unknown db_id 0x%x in ctdb_reply_dmaster\n",
-                                 (int)c->db_id));
-               return -1;
-       }
-
-       key.dptr = c->key;
-       key.dsize = indata.dsize - offsetof(struct ctdb_control_gotit, key);
-
-       num_keys = talloc_array_length(db->holdback_keys);
-       for (i=0; i<num_keys; i++) {
-               uint8_t *hold_key = db->holdback_keys[i];
-               size_t keylength = talloc_array_length(hold_key);
-
-               if ((keylength == key.dsize)
-                   && (memcmp(hold_key, key.dptr, keylength) == 0)) {
-                       break;
-               }
-       }
-       if (i == num_keys) {
-               /*
-                * ctdb_holdback_cleanup has kicked in. This is okay,
-                * we will just potentially have to retry.
-                */
-               return 0;
-       }
-
-       talloc_free(db->holdback_keys[i]);
-       if (i < num_keys-1) {
-               db->holdback_keys[i] = db->holdback_keys[num_keys-1];
-       }
-       db->holdback_keys = talloc_realloc(db, db->holdback_keys, uint8_t *,
-                                          num_keys-1);
-
-       num_heldback = talloc_array_length(db->held_back);
-       for (i=0; i<num_heldback; i++) {
-               ctdb_queue_packet(ctdb, db->held_back[i]);
-       }
-       talloc_free(db->held_back);
-       db->held_back = NULL;
-       return 0;
-}
index 2b703e73151cb63a637b871b8501d75d6433ee34..3382fae39aac964481068c369021b3588dc13437 100644 (file)
@@ -281,7 +281,6 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
        case CTDB_CONTROL_SHUTDOWN:
                ctdb_stop_recoverd(ctdb);
                ctdb_stop_keepalive(ctdb);
-               ctdb_stop_holdback_cleanup(ctdb);
                ctdb_stop_monitoring(ctdb);
                ctdb_release_all_ips(ctdb);
                if (ctdb->methods != NULL) {
@@ -561,9 +560,6 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                CHECK_CONTROL_DATA_SIZE(sizeof(uint64_t));
                return ctdb_control_get_db_seqnum(ctdb, indata, outdata);
 
-       case CTDB_CONTROL_GOTIT:
-               return ctdb_control_gotit(ctdb, indata);
-
        default:
                DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
                return -1;
index c0e96168b584d9500ef9baba691910995b55d5f5..9ade55aca86bc66ef1cca45c44402c2081b6dd16 100644 (file)
@@ -75,9 +75,6 @@ static void ctdb_start_transport(struct ctdb_context *ctdb)
        /* start periodic update of tcp tickle lists */
                ctdb_start_tcp_tickle_update(ctdb);
 
-       /* start periodic cleanup of holdback cleanup */
-       ctdb_start_holdback_cleanup(ctdb);
-
        /* start listening for recovery daemon pings */
        ctdb_control_recd_ping(ctdb);
 }
index fcf3488cb67d71cda41f56af9e3af072ceac23f7..8568e8bbe07e59984f8255ab0dd9b31f6b7aa4c6 100644 (file)
@@ -1158,7 +1158,6 @@ static void ctdb_recd_ping_timeout(struct event_context *ev, struct timed_event
 
        ctdb_stop_recoverd(ctdb);
        ctdb_stop_keepalive(ctdb);
-       ctdb_stop_holdback_cleanup(ctdb);
        ctdb_stop_monitoring(ctdb);
        ctdb_release_all_ips(ctdb);
        if (ctdb->methods != NULL) {
index 3ae0db49785a5eaf19469af188492fe9f55f53d3..3e596da9ecad9d88c8aa99184e4c94dac10a7720 100644 (file)
@@ -3296,7 +3296,6 @@ static void ctdb_check_recd(struct event_context *ev, struct timed_event *te,
 
                ctdb_stop_recoverd(ctdb);
                ctdb_stop_keepalive(ctdb);
-               ctdb_stop_holdback_cleanup(ctdb);
                ctdb_stop_monitoring(ctdb);
                ctdb_release_all_ips(ctdb);
                if (ctdb->methods != NULL) {
index c0b45c7815af9e3bdecc8fe46fbaf8030d6c26c9..872260384bdb1663eda9835ce85466d425caec96 100644 (file)
@@ -30,8 +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) },
-       { "HoldbackCleanupInterval", 1000,
-         offsetof(struct ctdb_tunable, holdback_cleanup_interval) },
        { "MaxLACount",           7,  offsetof(struct ctdb_tunable, max_lacount) },
        { "RecoverTimeout",      20,  offsetof(struct ctdb_tunable, recover_timeout) },
        { "RecoverInterval",      1,  offsetof(struct ctdb_tunable, recover_interval) },