Skip to main content

Point Reads and Published Heads

Reading one key by name is the most common Kahuna operation. For a key that is in memory and doesn't have a pending change, Kahuna can serve the latest value from a published in-memory record. The read doesn't wait in the mailbox of the key's actor behind other work. The result is lower latency for frequently read keys, with the same consistency as the normal path. It is on by default, and you don't need to do anything. This page explains when the fast path applies and how to diagnose it.

This is an optimization of the existing leader-confirmed read path. It doesn't authorize follower reads or bypass transaction registration. It also doesn't provide a new consistency mode.

Read Flow​

A routed get resolves the current partition and confirms local leadership before reading. A transaction-scoped get also registers its operation on the coordinator and completes that registration with the observed value or absence. A forwarded batch read resolves each key again on arrival; a hosting follower cannot serve its local copy on the sender's assurance. Exhausting the forwarding budget returns MustRetry. A stale local answer isn't returned.

After confirmation, the read tries an immutable PublishedHead belonging to the key's actor. The record contains the value and its metadata: revision, expiry, modification timestamp, state. It also shows whether MVCC state exists. Entry setters retract the record before mutations; the actor publishes a new record at the end of its turn before replying. A concurrent retraction after a read has accepted a live record represents a concurrent write; it does not turn that accepted observation into a later read of the replacement.

Eligibility and Fallback​

The published path applies only to latest point gets. These reads don't request a revision or a fixed read timestamp, and they aren't in an enclosing actor turn. The read goes to the actor when one of these guards fails.

  • No resident live-value record, or the record has been retracted (including tombstone paths).
  • The actor has a prefix lock.
  • A newer committed head is pending for this key on the actor mailbox.
  • For persistent keys, the unflushed-write overlay has a newer head, or a durable prepared intent exists.
  • The head has expired and needs the actor's expiry handling.
  • A transaction-scoped read encounters a key with existing MVCC state, including a pin or staged write.

The replicator notes per-key pending applies before advancing the applied frontier (the newest replicated log entry the node has applied to memory). This prevents a leadership confirmation from making an older published record appear current while its replacement is queued. Other cases continue through the actor path, for example cache misses and historical reads. Durable intent visibility and expiry handling also use the actor path, and so does read-your-staged-write behavior.

A published transactional read sends a RecordReadPin control message before the session's next request for that key. The actor creates the same MVCC observation the ordinary read path would create. Subsequent operations therefore validate against the revision actually read; published reads do not turn per-key pins into a shared snapshot. See Transaction Reads and Locks.

Configuration and Cache Lifetime​

The path is enabled by default. Set --disable-published-head-reads on the server, or PublishedHeadReads = false in KahunaConfiguration or EmbeddedKahunaOptions, to send gets through the actor for diagnosis. Disabling it also stops actors publishing records.

Published reads update the record's usage timestamp. The collector folds that timestamp into entry recency before it judges a key cold. This means that keys read only through this path aren't treated as idle by mistake. Records remain resident cache state. They aren't additional persistent copies. Ephemeral eviction loses the value as usual, and persistent cache misses reload through the backend.

Stage Metrics​

kahuna.kv.read.stage is a millisecond histogram on the Kahuna meter. Its tags have different meanings at different stages.

stageMeasurementAdditional tags
registerRegister a transaction-scoped operation on its coordinator.None
confirmConfirm leadership and application coverage before a local get.lease=hit for synchronous confirmation; lease=miss for an asynchronous answer, including an applied-frontier wait or a read-index round (a quorum check that this node is the leader before it serves the read).
actorObtain the value through a published record or actor mailbox.path=published or path=actor.
completeFold a transaction-scoped read observation into its working set.None
totalFull get measured by the read facade.path=registered for session reads, path=direct otherwise.

Samples use the serving node's elapsed-time clock and include waits in each measured step. They are not client network latency. Registration and completion are absent for direct reads; work forwarded elsewhere is measured where it is served, with coordinator registration/completion measured on their calling path. Compare stages to locate a wait. Don't add unrelated percentiles together. The dashboard includes this histogram in its curated metrics.

Four tests cover these behaviors: TestPublishedHeadReads, TestPublishedHeadTable, TestKeyValueReadStageMetrics, TestForwardedBatchReadLeadership. They test guard fallbacks and pins. They also test publication and retraction, and forwarding on lagging followers.