Permalink
Browse files

MB-6661: The delete packet returns a cas value

This is neccessary for clients to detect an update after a delete
when using the observe command.

Change-Id: Id965bc5ca51a3d4d80f7071939b208111a48a38a
Reviewed-on: http://review.couchbase.org/20856
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
  • Loading branch information...
1 parent 524945f commit 858731183b08cd6b72fa6e68c1fb4208cb87570d @mikewied mikewied committed with Peter Wansch Sep 14, 2012
View
@@ -3514,8 +3514,7 @@ static void process_bin_update(conn *c) {
if (c->cmd == PROTOCOL_BINARY_CMD_SET) {
/* @todo fix this for the ASYNC interface! */
settings.engine.v1->remove(settings.engine.v0, c, key, nkey,
- memcached_ntohll(req->message.header.request.cas),
- c->binary_header.request.vbucket);
+ &c->cas, c->binary_header.request.vbucket);
}
/* swallow the data line */
@@ -3628,8 +3627,6 @@ static void process_bin_flush(conn *c) {
}
static void process_bin_delete(conn *c) {
- protocol_binary_request_delete* req = binary_get_request(c);
-
char* key = binary_get_key(c);
size_t nkey = c->binary_header.request.keylen;
@@ -3653,8 +3650,7 @@ static void process_bin_delete(conn *c) {
stats_prefix_record_delete(key, nkey);
}
ret = settings.engine.v1->remove(settings.engine.v0, c, key, nkey,
- memcached_ntohll(req->message.header.request.cas),
- c->binary_header.request.vbucket);
+ &c->cas, c->binary_header.request.vbucket);
}
/* For some reason the SLAB_INCR tries to access this... */
@@ -4635,7 +4631,8 @@ static void process_update_command(conn *c, mc_extension_token_t *tokens, const
/* Avoid stale data persisting in cache because we failed alloc.
* Unacceptable for SET. Anywhere else too? */
if (store_op == OPERATION_SET) {
- settings.engine.v1->remove(settings.engine.v0, c, key, nkey, 0, 0);
+ uint64_t cas = 0;
+ settings.engine.v1->remove(settings.engine.v0, c, key, nkey, &cas, 0);
}
}
}
@@ -4751,8 +4748,9 @@ static char *process_delete_command(conn *c, mc_extension_token_t *tokens,
c->aiostat = ENGINE_SUCCESS;
c->ewouldblock = false;
if (ret == ENGINE_SUCCESS) {
+ uint64_t cas = 0;
ret = settings.engine.v1->remove(settings.engine.v0, c,
- key, nkey, 0, 0);
+ key, nkey, &cas, 0);
}
/* For some reason the SLAB_INCR tries to access this... */
@@ -32,7 +32,7 @@ static ENGINE_ERROR_CODE default_item_delete(ENGINE_HANDLE* handle,
const void* cookie,
const void* key,
const size_t nkey,
- uint64_t cas,
+ uint64_t* cas,
uint16_t vbucket);
static void default_item_release(ENGINE_HANDLE* handle, const void *cookie,
@@ -334,7 +334,7 @@ static ENGINE_ERROR_CODE default_item_delete(ENGINE_HANDLE* handle,
const void* cookie,
const void* key,
const size_t nkey,
- uint64_t cas,
+ uint64_t* cas,
uint16_t vbucket)
{
struct default_engine* engine = get_handle(handle);
@@ -345,7 +345,7 @@ static ENGINE_ERROR_CODE default_item_delete(ENGINE_HANDLE* handle,
return ENGINE_KEY_ENOENT;
}
- if (cas == 0 || cas == item_get_cas(it)) {
+ if (*cas == 0 || *cas == item_get_cas(it)) {
item_unlink(engine, it);
item_release(engine, it);
} else {
@@ -792,7 +792,7 @@ static ENGINE_ERROR_CODE default_tap_notify(ENGINE_HANDLE* handle,
return default_flush(handle, cookie, 0);
case TAP_DELETION:
- return default_item_delete(handle, cookie, key, nkey, cas, vbucket);
+ return default_item_delete(handle, cookie, key, nkey, &cas, vbucket);
case TAP_MUTATION:
it = engine->server.cookie->get_engine_specific(cookie);
@@ -32,7 +32,7 @@ extern "C" {
const void* cookie,
const void* key,
const size_t nkey,
- uint64_t cas,
+ uint64_t* cas,
uint16_t vbucket);
static void item_release(ENGINE_HANDLE* handle, const void *cookie,
@@ -903,10 +903,10 @@ static ENGINE_ERROR_CODE item_delete(ENGINE_HANDLE* handle,
const void* cookie,
const void* key,
const size_t nkey,
- uint64_t cas,
+ uint64_t* cas,
uint16_t vbucket)
{
- return getHandle(handle).itemDelete(cookie, key, nkey, cas, vbucket);
+ return getHandle(handle).itemDelete(cookie, key, nkey, *cas, vbucket);
}
static void item_release(ENGINE_HANDLE* handle, const void *cookie, item* it)
@@ -256,7 +256,7 @@ extern "C" {
const void* cookie,
const void* key,
const size_t nkey,
- uint64_t cas,
+ uint64_t* cas,
uint16_t vbucket);
/**
@@ -102,7 +102,7 @@ static ENGINE_ERROR_CODE mock_remove(ENGINE_HANDLE* handle,
const void* cookie,
const void* key,
const size_t nkey,
- uint64_t cas,
+ uint64_t* cas,
uint16_t vbucket)
{
struct mock_engine *me = get_handle(handle);
@@ -270,7 +270,7 @@ static enum test_result remove_test(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {
uint64_t cas = 0;
assert(h1->allocate(h, NULL, &test_item, key, strlen(key), 1,0, 0) == ENGINE_SUCCESS);
assert(h1->store(h, NULL, test_item, &cas, OPERATION_SET,0) == ENGINE_SUCCESS);
- assert(h1->remove(h, NULL, key, strlen(key), cas, 0) == ENGINE_SUCCESS);
+ assert(h1->remove(h, NULL, key, strlen(key), &cas, 0) == ENGINE_SUCCESS);
item *check_item = test_item;
assert(h1->get(h, NULL, &check_item, key, strlen(key), 0) == ENGINE_KEY_ENOENT);
assert(check_item == NULL);

0 comments on commit 8587311

Please sign in to comment.