apache / kvrocks

Apache Kvrocks is a distributed key value NoSQL database that uses RocksDB as storage engine and is compatible with Redis protocol.
https://kvrocks.apache.org/
Apache License 2.0
3.53k stars 464 forks source link

[BUG] dbsize return wrong value #275

Closed hellower closed 3 years ago

hellower commented 3 years ago

##################

redis

################## 127.0.0.1:6379> keys * 1) "a" 2) "tntchecker" 3) "b" 127.0.0.1:6379> dbsize <========== keys count (integer) 3 127.0.0.1:6379> info keyspace -# Keyspace db0:keys=3,expires=0,avg_ttl=0 <======== keys=3

##################

kvrocks

################## 127.0.0.1:6666> keys * 1) "a" 2) "tntchecker" 3) "b" 127.0.0.1:6666> dbsize <========== keys count (integer) 0 <======= always return 0!! 127.0.0.1:6666> info keyspace -# Keyspace -# Last scan db time: Thu Jan 1 00:00:00 1970 db0:keys=0,expires=0,avg_ttl=0,expired=0 <===== keys 0 sequence:38283437 used_db_size:603247462 max_db_size:0 used_percent: 0% disk_capacity:322110992384 used_disk_size:161157144576 used_disk_percent: 50%

git-hulk commented 3 years ago

Thanks for your report, it's not a bug actually, the kvrocks key-values were stored in disk, and find out expired keys was impossible unless we can scan it. So we MUST execute the dbsize scan command to async scan the DB for finding out the key number.

hellower commented 3 years ago

Thanks! and Thank you for nice KVROCKS open source.

ShooterIT commented 3 years ago

Also welcome you to join in improving kvrocks 😄