Hash acquires a duplicate field → replica full-sync fails in a loop ("Duplicate hash fields detected") and primary stalls ("Stalled heartbeat() fiber") — v1.34.2
Describe the bug
A hash written only via HSET intermittently ends up containing a duplicate field. When the replica performs a full sync, the RDB loader rejects that hash and the sync fails and retries in a loop. During the loop the primary becomes unresponsive (Stalled heartbeat() fiber for an extended period), so clients get connection timeouts until the affected key expires on its own.
This is a Dragonfly→Dragonfly setup (no RESTORE, no external RDB import). The client uses plain HSET only, so the duplicate field appears to be created internally by the server.
Symptoms / logs (key name redacted)
On the replica during full sync:
rdb_load.cc:525] Duplicate hash fields detected for field ...
rdb_load.cc:2604] Could not load value for key '<hash-key>' in DB 0
common.cc:341] ReportError: Internal error when loading RDB file N: Error loading rdb format
replica.cc:268] Error syncing with <master>:<port> (phase: INITIAL_SYNC): dragonfly.rdbload:N Internal error when loading RDB file NOn the primary (concurrently, escalating):
engine_shard.cc:618] Stalled heartbeat() fiber for <N> seconds # observed climbing to ~1400sThe replica repeatedly re-attempts full sync (Started full sync → error → retry). The incident cleared only when the affected hash key expired via its TTL.
Workload characteristics
- Data structure: a single hash per rotating time-bucket key.
- Writes:
HSETonly (multiple field/value pairs per call). - Field names are fixed-length binary (byte arrays that can contain null bytes).
- Key-level TTL is (re)applied on writes (
EXPIRE, "always" semantics). - No field-level TTL (
HEXPIRE/HGETEX/HSETEX) and noRESTOREare used.
What we ruled out
- Not client misuse —
HSEToverwrites existing fields, so the application cannot create duplicate fields. - Not field-level TTL / lazy field expiry.
- Not a
RESTOREor foreign-RDB import path (this is native Dragonfly replication).
Expected behavior
- A hash should never hold duplicate fields when written via
HSET(binary field names should compare correctly). - A single corrupt key should not put full sync into an infinite retry loop or stall the primary — it should be surfaced/skipped so replication can make progress and the primary stays responsive.
To reproduce
Not deterministically reproducible — appears intermittent under sustained HSET load to hashes with binary field names. Steps we believe are relevant:
- 1 primary + 1 replica.
- Continuously
HSETmany entries into a hash using fixed-length binary field names; apply a key-level TTL. - Trigger/allow a replica full sync while under load.
- Observe (occasionally) the replica full-sync failing on
Duplicate hash fields detectedand the primary'sStalled heartbeat() fiber.
Environment
- Dragonfly v1.34.2
- Kubernetes (dragonfly-operator), 1 primary + 1 replica
Questions
- Is this a known issue, and is there a fix / target version? (Duplicate-field validation was added for the
RESTORE/load paths, e.g. #8260 and #8328, but those detect/reject rather than prevent creation, and the latter isn't in a released version yet.) - Can full sync be made resilient to a single corrupt key (skip/repair) so it doesn't loop and stall the primary?
Source: dragonflydb/dragonfly