summaryrefslogtreecommitdiff
path: root/proto_text.c
diff options
context:
space:
mode:
authorHemal Shah <hemal@stripe.com>2022-10-19 19:17:13 -0700
committerdormando <dormando@rydia.net>2023-03-15 17:16:36 -0700
commit9b3c946f485309cdf50f7fb1622707b5373e33f3 (patch)
tree50442521e1d2912caddfe0266f5223b0f4b48fb3 /proto_text.c
parentc04701654413719d4abd7645c6d7b3fba4255e85 (diff)
downloadmemcached-9b3c946f485309cdf50f7fb1622707b5373e33f3.tar.gz
log: Add a new watcher to watch for deletions.
`watch deletions`: would log all keys which are deleted using either `delete` or `md` command. The log line would contain the command used, the key, the clsid and size of the deleted item. Items which result in delete miss or are marked as stale wouldn't show up in the logs
Diffstat (limited to 'proto_text.c')
-rw-r--r--proto_text.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/proto_text.c b/proto_text.c
index 1f69ddc..58fd227 100644
--- a/proto_text.c
+++ b/proto_text.c
@@ -1684,6 +1684,7 @@ static void process_mdelete_command(conn *c, token_t *tokens, const size_t ntoke
c->thread->stats.slab_stats[ITEM_clsid(it)].delete_hits++;
pthread_mutex_unlock(&c->thread->stats.mutex);
+ LOGGER_LOG(NULL, LOG_DELETIONS, LOGGER_DELETIONS, it, LOG_TYPE_META_DELETE);
do_item_unlink(it, hv);
STORAGE_delete(c->thread->storage, it);
if (c->noreply)
@@ -2176,7 +2177,7 @@ static void process_delete_command(conn *c, token_t *tokens, const size_t ntoken
pthread_mutex_lock(&c->thread->stats.mutex);
c->thread->stats.slab_stats[ITEM_clsid(it)].delete_hits++;
pthread_mutex_unlock(&c->thread->stats.mutex);
-
+ LOGGER_LOG(NULL, LOG_DELETIONS, LOGGER_DELETIONS, it, LOG_TYPE_DELETE);
do_item_unlink(it, hv);
STORAGE_delete(c->thread->storage, it);
do_item_remove(it); /* release our reference */
@@ -2322,6 +2323,8 @@ static void process_watch_command(conn *c, token_t *tokens, const size_t ntokens
f |= LOG_PROXYEVENTS;
} else if ((strcmp(tokens[x].value, "proxyuser") == 0)) {
f |= LOG_PROXYUSER;
+ } else if ((strcmp(tokens[x].value, "deletions") == 0)) {
+ f |= LOG_DELETIONS;
} else {
out_string(c, "ERROR");
return;