mirror of
https://github.com/redis/redis.git
synced 2026-04-21 03:01:35 -04:00
HFE - Fix statistic to count also lazy expired and rename INFO params (#13372)
* INFO command : rename `hashes_with_expiry_fields` to `subexpiry` * INFO command : rename `expired_hash_fields` to `expired_subkeys` * Fix statistic of `expired_subkeys` to count also lazy expired * Remove TODOs comments leftover in TCL * Fix potential flaky test of rdb load of hash-field-expiration
This commit is contained in:
@@ -2524,7 +2524,7 @@ void resetServerStats(void) {
|
||||
server.stat_numcommands = 0;
|
||||
server.stat_numconnections = 0;
|
||||
server.stat_expiredkeys = 0;
|
||||
server.stat_expired_hash_fields = 0;
|
||||
server.stat_expired_subkeys = 0;
|
||||
server.stat_expired_stale_perc = 0;
|
||||
server.stat_expired_time_cap_reached_count = 0;
|
||||
server.stat_expire_cycle_time_used = 0;
|
||||
@@ -5877,7 +5877,7 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
|
||||
"sync_full:%lld\r\n", server.stat_sync_full,
|
||||
"sync_partial_ok:%lld\r\n", server.stat_sync_partial_ok,
|
||||
"sync_partial_err:%lld\r\n", server.stat_sync_partial_err,
|
||||
"expired_hash_fields:%lld\r\n", server.stat_expired_hash_fields,
|
||||
"expired_subkeys:%lld\r\n", server.stat_expired_subkeys,
|
||||
"expired_keys:%lld\r\n", server.stat_expiredkeys,
|
||||
"expired_stale_perc:%.2f\r\n", server.stat_expired_stale_perc*100,
|
||||
"expired_time_cap_reached_count:%lld\r\n", server.stat_expired_time_cap_reached_count,
|
||||
@@ -6124,7 +6124,7 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
|
||||
|
||||
if (keys || vkeys) {
|
||||
info = sdscatprintf(info,
|
||||
"db%d:keys=%lld,expires=%lld,avg_ttl=%lld,hashes_with_expiry_fields=%lld\r\n",
|
||||
"db%d:keys=%lld,expires=%lld,avg_ttl=%lld,subexpiry=%lld\r\n",
|
||||
j, keys, vkeys, server.db[j].avg_ttl, hexpires);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1651,7 +1651,7 @@ struct redisServer {
|
||||
long long stat_numcommands; /* Number of processed commands */
|
||||
long long stat_numconnections; /* Number of connections received */
|
||||
long long stat_expiredkeys; /* Number of expired keys */
|
||||
long long stat_expired_hash_fields; /* Number of expired hash-fields */
|
||||
long long stat_expired_subkeys; /* Number of expired subkeys (Currently only hash-fields) */
|
||||
double stat_expired_stale_perc; /* Percentage of keys probably expired */
|
||||
long long stat_expired_time_cap_reached_count; /* Early expire cycle stops.*/
|
||||
long long stat_expire_cycle_time_used; /* Cumulative microseconds used. */
|
||||
|
||||
@@ -414,6 +414,7 @@ void listpackExExpire(redisDb *db, robj *o, ExpireInfo *info) {
|
||||
break;
|
||||
|
||||
propagateHashFieldDeletion(db, ((listpackEx *) o->ptr)->key, (char *)((fref) ? fref : intbuf), flen);
|
||||
server.stat_expired_subkeys++;
|
||||
|
||||
ptr = lpNext(lpt->lp, ptr);
|
||||
|
||||
@@ -545,6 +546,7 @@ SetExRes hashTypeSetExpiryListpack(HashTypeSetEx *ex, sds field,
|
||||
if (unlikely(checkAlreadyExpired(expireAt))) {
|
||||
propagateHashFieldDeletion(ex->db, ex->key->ptr, field, sdslen(field));
|
||||
hashTypeDelete(ex->hashObj, field, 1);
|
||||
server.stat_expired_subkeys++;
|
||||
ex->fieldDeleted++;
|
||||
return HSETEX_DELETED;
|
||||
}
|
||||
@@ -758,6 +760,7 @@ GetFieldRes hashTypeGetValue(redisDb *db, robj *o, sds field, unsigned char **vs
|
||||
/* delete the field and propagate the deletion */
|
||||
serverAssert(hashTypeDelete(o, field, 1) == 1);
|
||||
propagateHashFieldDeletion(db, key, field, sdslen(field));
|
||||
server.stat_expired_subkeys++;
|
||||
|
||||
/* If the field is the last one in the hash, then the hash will be deleted */
|
||||
res = GETF_EXPIRED;
|
||||
@@ -1042,6 +1045,7 @@ SetExRes hashTypeSetExpiryHT(HashTypeSetEx *exInfo, sds field, uint64_t expireAt
|
||||
/* replicas should not initiate deletion of fields */
|
||||
propagateHashFieldDeletion(exInfo->db, exInfo->key->ptr, field, sdslen(field));
|
||||
hashTypeDelete(exInfo->hashObj, field, 1);
|
||||
server.stat_expired_subkeys++;
|
||||
exInfo->fieldDeleted++;
|
||||
return HSETEX_DELETED;
|
||||
}
|
||||
@@ -1833,7 +1837,6 @@ static uint64_t hashTypeExpire(robj *o, ExpireCtx *expireCtx, int updateGlobalHF
|
||||
.itemsExpired = 0};
|
||||
|
||||
listpackExExpire(db, o, &info);
|
||||
server.stat_expired_hash_fields += info.itemsExpired;
|
||||
keystr = ((listpackEx*)o->ptr)->key;
|
||||
} else {
|
||||
serverAssert(o->encoding == OBJ_ENCODING_HT);
|
||||
@@ -2887,7 +2890,7 @@ static ExpireAction onFieldExpire(eItem item, void *ctx) {
|
||||
dictExpireMetadata *dictExpireMeta = (dictExpireMetadata *) dictMetadata(d);
|
||||
propagateHashFieldDeletion(expCtx->db, dictExpireMeta->key, hf, hfieldlen(hf));
|
||||
serverAssert(hashTypeDelete(expCtx->hashObj, hf, 0) == 1);
|
||||
server.stat_expired_hash_fields++;
|
||||
server.stat_expired_subkeys++;
|
||||
return ACT_REMOVE_EXP_ITEM;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user