test(replication): verify per-record expiresAt eviction across nodes#182
Open
kriszyp wants to merge 2 commits into
Open
test(replication): verify per-record expiresAt eviction across nodes#182kriszyp wants to merge 2 commits into
kriszyp wants to merge 2 commits into
Conversation
Adds two test cases to the replicationTopology integration suite: 1. v5→v5 multi-record batch TTL: writes 4 records in a single upsert (which the replication layer batches as one transaction) to a table with a 1-second expiration, then asserts all nodes evict every record after the TTL window. This exercises the fix for the batched-txn expiresAt propagation bug where only the first record's context was used for all subsequent records. 2. v4→v5 cross-version TTL: pre-creates a table on the v5 cluster with the same expiration as the v4 table (workaround for v4's table-copy encoding bug), writes records on the v4 node, waits for replication, then asserts eviction occurs on all v5 receivers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Reviewed; no blockers found. |
DavidCockerill
approved these changes
May 21, 2026
cb1kenobi
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
replicationTopologysuiteBackground
Field report: records arriving via cross-version replication from v4 peers don't evict on v5 receivers, even past their
expiresAtTimestamp. Local writes on the same v5 node evict correctly.Root causes found during investigation:
1. Harper core (v5) — batched transaction context bug (HarperFast/harper#639, #640)
In a multi-record replication batch, every event after the first is processed with the first event as
context. Theoptionsobject passed to_writeUpdatedidn't includeexpiresAt, and_writeUpdateonly read fromcontext, so subsequent records in a batch received no expiration.scheduleCleanup()was also only armed whencontext.expiresAtwas truthy, missing replicated writes.2. harperdb v4 — table copy encoding bug (harperdb/harperdb#3120)
When a new node joins a v4 cluster, the table copy path calls
createAuditEntrywithentry.metadataFlags & ~0xffasextendedType. This masksHAS_EXPIRATION(0x10, lower byte) without promoting it toHAS_EXPIRATION_EXTENDED_TYPE(0x1000), so the expiresAt float64 is never encoded into the binary payload. Receivers seeauditRecord.expiresAt === undefinedfor every table-copied record.Test design
v5→v5 test: Creates a 1-second TTL table on node 0, upserts 4 records in one batch (exercising the batched-txn path), waits for replication confirmation, then asserts all 4 records are gone from every node after TTL+buffer.
v4→v5 test: Pre-creates the table on the v5 cluster with the same
expirationvalue before connecting to the v4 node (workaround for the v4 table-copy encoding bug — the fallbackexpirationMs + Date.now()on the v5 receiver computes a freshexpiresAtat receipt time). Writes records on the v4 node, waits for replication, asserts eviction.Dependencies
Signed-off by Claude