From 9b3c946f485309cdf50f7fb1622707b5373e33f3 Mon Sep 17 00:00:00 2001 From: Hemal Shah Date: Wed, 19 Oct 2022 19:17:13 -0700 Subject: 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 --- proto_text.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'proto_text.c') 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; -- cgit v1.2.1