You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "jonasmao (via GitHub)" <gi...@apache.org> on 2025/07/24 13:42:08 UTC
[I] [hash] will need delete the hash major key when HDel delete all of the hash fields? [kvrocks]
jonasmao opened a new issue, #3074:
URL: https://github.com/apache/kvrocks/issues/3074
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/kvrocks/issues) and found no similar issues.
### Version
v2.12.1
### Minimal reproduce step
find the code:
``rocksdb::Status Hash::Delete(engine::Context &ctx, const Slice &user_key, const std::vector<Slice> &fields,
uint64_t *deleted_cnt) {
*deleted_cnt = 0;
std::string ns_key = AppendNamespacePrefix(user_key);
...
HashMetadata metadata(false);
...
s = GetMetadata(ctx, ns_key, &metadata);
if (!s.ok()) return s.IsNotFound() ? rocksdb::Status::OK() : s;
...
if (*deleted_cnt == 0) {
return rocksdb::Status::OK();
}
**metadata.size -= *deleted_cnt; // if the size = 0, we just update the hash metadata**
std::string bytes;
metadata.Encode(&bytes);
s = batch->Put(metadata_cf_handle_, ns_key, bytes);
if (!s.ok()) return s;
return storage_->Write(ctx, storage_->DefaultWriteOptions(), batch->GetWriteBatch());
}``
### What did you expect to see?
just like redis hash hdel
### What did you see instead?
as hash is not a emptyableType
`bool Metadata::IsSingleKVType() const { return Type() == kRedisString || Type() == kRedisJson; }
bool Metadata::IsEmptyableType() const {
return IsSingleKVType() || Type() == kRedisStream || Type() == kRedisBloomFilter || Type() == kRedisHyperLogLog ||
Type() == kRedisTDigest;
}`
### Anything Else?
_No response_
### Are you willing to submit a PR?
- [x] I'm willing to submit a PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [hash] will need delete the hash major key when HDel delete all of the hash fields? [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice closed issue #3074: [hash] will need delete the hash major key when HDel delete all of the hash fields?
URL: https://github.com/apache/kvrocks/issues/3074
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [hash] will need delete the hash major key when HDel delete all of the hash fields? [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on issue #3074:
URL: https://github.com/apache/kvrocks/issues/3074#issuecomment-3116277287
https://github.com/apache/kvrocks/blob/cc82eead4784d6143eb6315e03e0359d3b3e0d91/src/storage/redis_metadata.cc#L322-L325
You can check here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [hash] will need delete the hash major key when HDel delete all of the hash fields? [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on issue #3074:
URL: https://github.com/apache/kvrocks/issues/3074#issuecomment-3113819666
It will be recycled in compaction so here we don't need to manually delete it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [hash] will need delete the hash major key when HDel delete all of the hash fields? [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on issue #3074:
URL: https://github.com/apache/kvrocks/issues/3074#issuecomment-3116284477
Feel free to reopen.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [hash] will need delete the hash major key when HDel delete all of the hash fields? [kvrocks]
Posted by "jonasmao (via GitHub)" <gi...@apache.org>.
jonasmao commented on issue #3074:
URL: https://github.com/apache/kvrocks/issues/3074#issuecomment-3116221934
> It will be recycled in compaction so here we don't need to manually delete it.
metadata cf filter have no condition (size==0) to recycle ?other places ?
```
bool MetadataFilter::Filter([[maybe_unused]] int level, const Slice &key, const Slice &value,
[[maybe_unused]] std::string *new_value, [[maybe_unused]] bool *modified) const {
Metadata metadata(kRedisNone, false);
rocksdb::Status s = metadata.Decode(value);
auto [ns, user_key] = ExtractNamespaceKey(key, stor_->IsSlotIdEncoded());
if (!s.ok()) {
LOG(WARNING) << "[compact_filter/metadata] Failed to decode,"
<< ", namespace: " << ns << ", key: " << user_key << ", err: " << s.ToString();
return false;
}
DLOG(INFO) << "[compact_filter/metadata] "
<< "namespace: " << ns << ", key: " << user_key
<< ", result: " << (metadata.Expired() ? "deleted" : "reserved");
return metadata.Expired();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [hash] will need delete the hash major key when HDel delete all of the hash fields? [kvrocks]
Posted by "jonasmao (via GitHub)" <gi...@apache.org>.
jonasmao commented on issue #3074:
URL: https://github.com/apache/kvrocks/issues/3074#issuecomment-3116711641
> [kvrocks/src/storage/redis_metadata.cc](https://github.com/apache/kvrocks/blob/cc82eead4784d6143eb6315e03e0359d3b3e0d91/src/storage/redis_metadata.cc#L322-L325)
>
> Lines 322 to 325 in [cc82eea](/apache/kvrocks/commit/cc82eead4784d6143eb6315e03e0359d3b3e0d91)
>
> bool Metadata::ExpireAt(uint64_t expired_ts) const {
> if (!IsEmptyableType() && size == 0) {
> return true;
> }
> You can check here.
get! this make the other redis type like string can also set the key(size==0)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org