Skip to content

docs: collection metadata delta design#501

Merged
bootjp merged 7 commits intomainfrom
docs/collection-metadata-delta-design
Apr 13, 2026
Merged

docs: collection metadata delta design#501
bootjp merged 7 commits intomainfrom
docs/collection-metadata-delta-design

Conversation

@bootjp
Copy link
Copy Markdown
Owner

@bootjp bootjp commented Apr 13, 2026

Summary

  • Add comprehensive design doc for the Delta + Claim pattern
  • Covers List, Hash, Set, ZSet metadata conflict resolution
  • Includes key layouts, write/read paths, background compaction, POP claim mechanism
  • Migration strategy and implementation status tracking

Test plan

  • Docs only, no code changes

Comprehensive design for the Delta + Claim pattern to resolve write
conflicts on Redis collection metadata (List, Hash, Set, ZSet).
Includes key layouts, write/read paths, background compaction,
POP claim mechanism, migration strategy, and implementation status.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request outlines a design for implementing a Delta pattern across Redis collection types to eliminate write conflicts on metadata keys. It introduces wide-column decomposition for Hash and Set types, a CAS-based Claim mechanism for List POP operations, and a background compaction process. The review feedback highlights an inconsistency in the List metadata key layout description, identifies a broken internal section reference, and suggests consolidating redundant terminology for delta limits to improve clarity for implementers.

Comment thread docs/collection_metadata_delta_design.md Outdated
Comment thread docs/collection_metadata_delta_design.md Outdated
Comment thread docs/collection_metadata_delta_design.md Outdated
bootjp added 2 commits April 13, 2026 23:23
- Fix base meta key format: !lst|meta|<userKey> (no length prefix),
  matching existing codebase (store/list_helpers.go)
- Fix broken cross-reference to nonexistent Section 11.1
- Remove maxDeltaHardLimit alias, use maxDeltaScanLimit consistently
@bootjp
Copy link
Copy Markdown
Owner Author

bootjp commented Apr 13, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request proposes a design for 'Collection Metadata Delta' to resolve write conflicts in Redis collection types (List, Hash, Set, and ZSet) by moving from a Read-Modify-Write pattern to a Delta-based approach. The design includes wide-column decomposition for Hash and Set, a background compaction process, and a CAS-based Claim mechanism for List POP operations. Feedback was provided regarding an inaccurate future date in the implementation status section.


## Implementation Status

> Last updated: 2026-04-13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The date '2026-04-13' is in the future. Please ensure this date is accurate or remove it to avoid confusion.

bootjp added 3 commits April 13, 2026 23:37
… tests)

Data Loss:
- Add DEL command batched-loop cleanup design for Delta/Claim keys
- Document that DEL must exhaust all delta/claim keys, not just maxDeltaScanLimit

Consistency:
- Document dual-path txnStartTS problem and required Delta prefix scan fix
- Add HLC overflow behavior (error on logical counter exhaustion)
- Add Raft single-leader guarantee as explicit dependency for commitTS uniqueness

Performance:
- Add expected latency targets for resolveListMeta (< 100us at 64 deltas)
- Document LRANGE compound scan cost (meta + items + claims)

Migration:
- Add batched migration design for large Hash/Set collections
- Document partial migration marker and merged read path

Tests:
- Add Jepsen mixed standalone/MULTI workload requirement to Phase L5
- Add Hash/Set migration edge case tests (crash, OCC, batch, partial read)
Data Loss (6 fixes):
- DEL: tombstone marker + batched cleanup for large collections
- Claim GC: must respect MVCC retention window for item/claim deletion
- RPOP: re-resolve metadata guard against compacted sequences
- Partial migration: wide-column keys take precedence (dedup rule)
- Lazy reaping: TOCTOU prevention via atomic Delta prefix scan
- txnStartTS: added implementation status tracking line

Concurrency/Fault (6 fixes):
- HLC overflow: updated to match actual implementation (wall advance)
- Compactor cursor: reset on leader transition (term change detection)
- ABA analysis: explicit Claim OCC analysis under compaction recycling
- Compaction vs writer: explicit safety analysis added
- Sync compaction: per-key mutex/singleflight for hard limit
- Dual-path interaction matrix table

Consistency (4 fixes):
- Negative Len: defensive clamp in all resolve*Meta functions
- readTS invariant: explicit same-timestamp constraint
- Stale Claim OCC: PUSH must register Claim key in readSet
- MULTI/EXEC isolation: corrected from 'matches Redis' to 'weaker than Redis serializable'

Performance (4 fixes):
- txnStartTS reverse scan: cost analysis and caching suggestion
- maxKeysPerTick: default 512 specified
- Migration batch: byte-bounded (512 KiB) not just count-bounded
- Eager migration: background worker option to limit merge window

Tests (10 additions):
- Jepsen workloads for Hash, Set, ZSet (not just List)
- Crash recovery tests for List delta/claim
- DEL large-delta test (>256 deltas)
- maxDeltaScanLimit overflow integration test
- txnStartTS Delta-awareness test
- Concurrent compaction test
- Empty collection lifecycle test
- SRANDMEMBER wide-column test
- Benchmark pass/fail criteria (100us/500us targets)
@bootjp
Copy link
Copy Markdown
Owner Author

bootjp commented Apr 13, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive design for 'Collection Metadata Deltas' to eliminate write conflicts on Redis collection metadata (List, Hash, Set, ZSet) under high concurrency. The design transitions from a Read-Modify-Write pattern on a single metadata key to a conflict-free Delta pattern, where writers append unique delta entries. Key components include wide-column decomposition for Hash and Set types, a CAS-based 'Claim' mechanism for List POP operations to ensure mutual exclusion without metadata locks, and a background compaction worker to collapse deltas and perform garbage collection of claimed items. The design also addresses critical consistency requirements for MULTI/EXEC transactions and provides a detailed multi-phase implementation and migration plan. I have no feedback to provide as the design is thorough and addresses the identified performance bottlenecks effectively.

@bootjp bootjp enabled auto-merge April 13, 2026 15:25
@bootjp bootjp merged commit 00e68f0 into main Apr 13, 2026
7 checks passed
@bootjp bootjp deleted the docs/collection-metadata-delta-design branch April 13, 2026 15:28
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.

1 participant