tejaslodayadd commented on code in PR #3269:
URL: https://github.com/apache/kvrocks/pull/3269#discussion_r2558027489
##########
src/storage/compact_filter.cc:
##########
@@ -154,6 +155,27 @@ bool SubKeyFilter::Filter([[maybe_unused]] int level,
const Slice &key, const Sl
return expired;
}
+ // Check for hash field expiration
+ if (metadata.Type() == kRedisHash) {
+ // First check if metadata (key-level) is expired
+ if (IsMetadataExpired(ikey, metadata)) {
+ return true;
+ }
+ // Then check per-field expiration
+ // Use lazy deletion with 5 minute buffer similar to metadata expiration
+ uint64_t lazy_expired_ts = util::GetTimeStampMS() - 300000;
+ HashFieldValue field_value;
+ if (!HashFieldValue::Decode(value.ToString(), &field_value)) {
+ // Failed to decode, keep the field
+ return false;
+ }
+ // Check if field has expiration and if it's expired (with lazy delete
buffer)
+ if (field_value.expire > 0 && field_value.expire <= lazy_expired_ts) {
+ return true;
+ }
+ return false;
+ }
Review Comment:
The key logic for hash field expiration cleanup during compaction -- when
the metadata type is `kRedisHash`, the filter:
- First checks if the entire key is expired (key-level expiration)
- Then decodes the field value using `HashFieldValue::Decode()`
- Checks if the field has a non-zero expiration timestamp
- Uses a **5-minute lazy delete buffer** (`util::GetTimeStampMS() -
300000`) to avoid race conditions between the HEXPIRE command and compaction
(same pattern used for key-level expiration)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]