DCP doesn’t differentiate between delete/expiry – both come down the wire to dcp consumer (eventing) as opcode 0x58 (DCP_DELETION). Like differentiating b/w create & update (MB-26905) , we would need dcp producer to implement differentiation b/w expiry & delete as well. Delete caused due to Expiry and 'normal' Delete should also be captured separately.
Sample dump from a test(run by Abhishek Singh ):
Created doc (DCP_MUTATION – opcode 0x57) with 10 sec expiry
Around 10 sec, got DCP_DELETION opcode instead of expected DCP_EXPIRATION (for this I made expiry pager to run every 1s instead of default 3600s)
Eventing won’t be able to expose OnExpiry handler without DCP producer(KV-Engine) side changes. Because of above DCP behavior, if user creates doc timer to notify on expiry – they will also get call to their OnDelete handler as well when expiry pager runs.
This is an issue as Delete and Expiry are two very different operations with vary different business implications.
From a consumer's(example: Eventing) perspective, it is very important that we provide a mechanism so that customers have OnDelete and OnExpiry handler. As of now, the only way possible is to create a Timer on the document few minutes before expiry. Though this might sound like a possible option, it has 2 consequences:
1. Timer's execution is not guaranteed at the specified time if the load on the system is high & the nodes are under provisioned.
2. Requires a metadata bucket(future collection) wherein the information is stored - this requires that Sizing be more considerate if there is non-trivial amount of documents and their respective timers.