From: Andrew Tridgell Date: Tue, 17 Apr 2007 06:54:03 +0000 (+1000) Subject: start using ctdb_ltdb_lock_fetch_requeue() X-Git-Tag: tevent-0.9.20~348^2~2897 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eba2a4b88c2b011c06b9d92f8e88541797711421;p=thirdparty%2Fsamba.git start using ctdb_ltdb_lock_fetch_requeue() (This used to be ctdb commit f89ab3a06b4677f56c92768c3a8ae5ec9f5abbc2) --- diff --git a/ctdb/common/ctdb_call.c b/ctdb/common/ctdb_call.c index 9e125810002..4b7deb1fd7b 100644 --- a/ctdb/common/ctdb_call.c +++ b/ctdb/common/ctdb_call.c @@ -270,11 +270,15 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr we don't need to update the record header now */ if (c->dmaster != ctdb->vnn) { /* fetch the current record */ - ret = ctdb_ltdb_fetch(ctdb_db, key, &header, hdr, &data2); - if (ret != 0) { + ret = ctdb_ltdb_lock_fetch_requeue(ctdb_db, key, &header, hdr, &data2); + if (ret == -1) { ctdb_fatal(ctdb, "ctdb_req_dmaster failed to fetch record"); return; } + if (ret == -2) { + printf("deferring ctdb_request_dmaster\n"); + return; + } /* its a protocol error if the sending node is not the current dmaster */ if (header.dmaster != hdr->srcnode) { @@ -283,7 +287,9 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr } header.dmaster = c->dmaster; - if (ctdb_ltdb_store(ctdb_db, key, &header, data) != 0) { + ret = ctdb_ltdb_store(ctdb_db, key, &header, data); + ctdb_ltdb_unlock(ctdb_db, key); + if (ret != 0) { ctdb_fatal(ctdb, "ctdb_req_dmaster unable to update dmaster"); return; } @@ -345,17 +351,22 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) fetches the record data (if any), thus avoiding a 2nd fetch of the data if the call will be answered locally */ - ret = ctdb_ltdb_fetch(ctdb_db, call.key, &header, hdr, &data); - if (ret != 0) { + ret = ctdb_ltdb_lock_fetch_requeue(ctdb_db, call.key, &header, hdr, &data); + if (ret == -1) { ctdb_send_error(ctdb, hdr, ret, "ltdb fetch failed in ctdb_request_call"); return; } + if (ret == -2) { + printf("deferred ctdb_request_call\n"); + return; + } /* if we are not the dmaster, then send a redirect to the requesting node */ if (header.dmaster != ctdb->vnn) { ctdb_call_send_redirect(ctdb, c, &header); talloc_free(data.dptr); + ctdb_ltdb_unlock(ctdb_db, call.key); return; } @@ -368,11 +379,14 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) || c->flags&CTDB_IMMEDIATE_MIGRATION ) { ctdb_call_send_dmaster(ctdb_db, c, &header, &call.key, &data); talloc_free(data.dptr); + ctdb_ltdb_unlock(ctdb_db, call.key); return; } ctdb_call_local(ctdb_db, &call, &header, &data, c->hdr.srcnode); + ctdb_ltdb_unlock(ctdb_db, call.key); + len = offsetof(struct ctdb_reply_call, data) + call.reply_data.dsize; r = ctdb->methods->allocate_pkt(ctdb, len); CTDB_NO_MEMORY_FATAL(ctdb, r); diff --git a/ctdb/tests/fetch.sh b/ctdb/tests/fetch.sh index ba043e17c58..157934caa0a 100755 --- a/ctdb/tests/fetch.sh +++ b/ctdb/tests/fetch.sh @@ -7,3 +7,11 @@ bin/ctdb_fetch --nlist tests/nodes.txt --listen 127.0.0.2:9001 $* & bin/ctdb_fetch --nlist tests/nodes.txt --listen 127.0.0.1:9001 $* killall -q ctdb_fetch + +echo "Trying 4 nodes" +bin/ctdb_fetch --nlist tests/4nodes.txt --listen 127.0.0.4:9001 $* & +bin/ctdb_fetch --nlist tests/4nodes.txt --listen 127.0.0.3:9001 $* & +bin/ctdb_fetch --nlist tests/4nodes.txt --listen 127.0.0.2:9001 $* & +bin/ctdb_fetch --nlist tests/4nodes.txt --listen 127.0.0.1:9001 $* + +killall -q ctdb_fetch