1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

Remove LACOUNT and LACCESSOR and migrate the records immediately.

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)
This commit is contained in:
Ronnie Sahlberg 2010-11-29 13:07:59 +11:00
parent 0aa2282c9c
commit b57bd0f896
7 changed files with 16 additions and 34 deletions

View 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, int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx, 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_call_info *c;
struct ctdb_registered_call *fn; 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; return -1;
} }
if (header->laccessor != caller) { /* we need to force the record to be written out if this was a remote access */
header->lacount = 0; if (c->new_data == NULL) {
}
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) {
c->new_data = &c->record_data; 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->call) = *call;
state->ctdb_db = ctdb_db; 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; return state;
} }

View File

@ -65,7 +65,6 @@ static void ltdb_initial_header(struct ctdb_db_context *ctdb_db,
ZERO_STRUCTP(header); ZERO_STRUCTP(header);
/* initial dmaster is the lmaster */ /* initial dmaster is the lmaster */
header->dmaster = ctdb_lmaster(ctdb_db->ctdb, &key); header->dmaster = ctdb_lmaster(ctdb_db->ctdb, &key);
header->laccessor = header->dmaster;
} }

View 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); 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 tell ctdb what address to listen on, in transport specific format
*/ */

View File

@ -82,7 +82,6 @@ struct ctdb_tunable {
uint32_t traverse_timeout; uint32_t traverse_timeout;
uint32_t keepalive_interval; uint32_t keepalive_interval;
uint32_t keepalive_limit; uint32_t keepalive_limit;
uint32_t max_lacount;
uint32_t recover_timeout; uint32_t recover_timeout;
uint32_t recover_interval; uint32_t recover_interval;
uint32_t election_timeout; 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); struct ctdb_ltdb_header *header);
int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call, 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, struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx,
uint32_t caller); TDB_DATA *data);
#define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__) #define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)

View File

@ -479,8 +479,8 @@ enum ctdb_trans2_commit_error {
struct ctdb_ltdb_header { struct ctdb_ltdb_header {
uint64_t rsn; uint64_t rsn;
uint32_t dmaster; uint32_t dmaster;
uint32_t laccessor; uint32_t reserved1;
uint32_t lacount; uint32_t reserved2;
}; };

View File

@ -297,7 +297,7 @@ static void ctdb_become_dmaster(struct ctdb_db_context *ctdb_db,
return; 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); ret = ctdb_ltdb_unlock(ctdb_db, state->call->key);
if (ret != 0) { 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); CTDB_UPDATE_STAT(ctdb, max_hop_count, c->hopcount);
/* if this nodes has done enough consecutive calls on the same record /* Try if possible to migrate the record off to the caller node.
then give them the record * From the clients perspective a fetch of the data is just as
or if the node requested an immediate migration * expensive as a migration.
*/ */
if ( c->hdr.srcnode != ctdb->pnn && if (c->hdr.srcnode != ctdb->pnn) {
((header.laccessor == c->hdr.srcnode
&& header.lacount >= ctdb->tunable.max_lacount)
|| (c->flags & CTDB_IMMEDIATE_MIGRATION)) ) {
if (ctdb_db->transaction_active) { if (ctdb_db->transaction_active) {
DEBUG(DEBUG_INFO, (__location__ " refusing migration" DEBUG(DEBUG_INFO, (__location__ " refusing migration"
" of key %s while transaction is active\n", " 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); ret = ctdb_ltdb_unlock(ctdb_db, call->key);
if (ret != 0) { 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->call) = *call;
state->ctdb_db = ctdb_db; 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); event_add_timed(ctdb->ev, state, timeval_zero(), call_local_trigger, state);

View File

@ -30,7 +30,6 @@ static const struct {
{ "TraverseTimeout", 20, offsetof(struct ctdb_tunable, traverse_timeout) }, { "TraverseTimeout", 20, offsetof(struct ctdb_tunable, traverse_timeout) },
{ "KeepaliveInterval", 5, offsetof(struct ctdb_tunable, keepalive_interval) }, { "KeepaliveInterval", 5, offsetof(struct ctdb_tunable, keepalive_interval) },
{ "KeepaliveLimit", 5, offsetof(struct ctdb_tunable, keepalive_limit) }, { "KeepaliveLimit", 5, offsetof(struct ctdb_tunable, keepalive_limit) },
{ "MaxLACount", 7, offsetof(struct ctdb_tunable, max_lacount) },
{ "RecoverTimeout", 20, offsetof(struct ctdb_tunable, recover_timeout) }, { "RecoverTimeout", 20, offsetof(struct ctdb_tunable, recover_timeout) },
{ "RecoverInterval", 1, offsetof(struct ctdb_tunable, recover_interval) }, { "RecoverInterval", 1, offsetof(struct ctdb_tunable, recover_interval) },
{ "ElectionTimeout", 3, offsetof(struct ctdb_tunable, election_timeout) }, { "ElectionTimeout", 3, offsetof(struct ctdb_tunable, election_timeout) },