Skip to content

Port CRDT key expiry from akka-core #31721#2733

Open
pjfanning wants to merge 6 commits intoapache:mainfrom
pjfanning:copilot/fix-imports-for-pekko
Open

Port CRDT key expiry from akka-core #31721#2733
pjfanning wants to merge 6 commits intoapache:mainfrom
pjfanning:copilot/fix-imports-for-pekko

Conversation

@pjfanning
Copy link
Member

Ports the CRDT key expiry feature from akka/akka-core#31721 with imports updated for Pekko. Allows Replicator entries to be automatically removed (without tombstones) after a configurable period of inactivity.

part of #2730

Configuration

pekko.cluster.distributed-data.expire-keys-after-inactivity {
  "session-*" = 30 minutes
  "cache-key" = 5 minutes
}

Prefix wildcard (*) matching supported.

Changes

Classic API (distributed-data)

  • New Expired[A] subscribe response (alongside Changed/Deleted) sent to subscribers when a key is evicted
  • ReplicatorSettings gains expiryKeys: Map[KeyId, FiniteDuration] with backward-compat constructor, withExpiryKeys() Scala/Java API, and parseExpiry() helper
  • dataEntries extended from (DataEnvelope, Digest) to (DataEnvelope, Digest, Timestamp) to track last-used time per key
  • Timestamp updated on receiveGet, receiveUpdate, receiveDelete
  • cleanupExpired() runs on every gossip tick; expired entries removed and subscribers notified
  • Gossip protocol (Status/Gossip messages) now carries usedTimestamp so all replicas share expiry clock state — entries received via gossip that are already expired are discarded

Durable store

  • New Expire(keys: Set[KeyId]) message added to DurableStore protocol
  • LmdbDurableStore handles Expire via new dbDelete(keys) method

Serialization

  • ReplicatorMessages.proto: optional sint64 usedTimestamp = 3 added to Status.Entry and Gossip.Entry
  • Generated ReplicatorMessages.java updated accordingly (zero value = unset; backward-compatible)
  • ReplicatorMessageSerializer updated to read/write timestamps

Typed API (cluster-typed)

  • Expired[A] type alias added to scaladsl.Replicator
  • Expired[A] case class added to javadsl.Replicator
  • ReplicatorBehavior forwards classic Expired to Java API subscribers

Copilot AI and others added 6 commits March 15, 2026 23:59
Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
…ired now param

Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
@He-Pin
Copy link
Member

He-Pin commented Mar 16, 2026

Should we wait this on 3.17?

@pjfanning
Copy link
Member Author

March 16 (today) is ok - https://github.com/akka/akka-core/blob/v2.8.0/LICENSE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants