Skip to content

fix(epoxy): add list operation#4604

Draft
MasterPtato wants to merge 1 commit into04-09-fix_pb-envoy_reduce_round_trips_for_ws_connectionfrom
04-09-fix_epoxy_add_list_operation
Draft

fix(epoxy): add list operation#4604
MasterPtato wants to merge 1 commit into04-09-fix_pb-envoy_reduce_round_trips_for_ws_connectionfrom
04-09-fix_epoxy_add_list_operation

Conversation

@MasterPtato
Copy link
Copy Markdown
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Contributor Author

@claude
Copy link
Copy Markdown

claude bot commented Apr 10, 2026

PR Review: fix(epoxy): add list operation

State: DRAFT | Author: MasterPtato | +492 / -142

Summary

This PR adds a range/list operation to the epoxy KV subsystem:

  1. Refactors read_value.rs into get_local.rs with an improved key: &[u8] signature
  2. Adds list_local.rs: range scan over committed KV values with optional optimistic cache merging
  3. Adds list_optimistic.rs: intended fan-out for list, but incomplete (see below)
  4. Extends v2.bare protocol schema with CommittedEntry, KvListRequest, KvListResponse

Critical Bugs (Blockers)

1. list_optimistic.rs is a broken copy-paste of get_optimistic.rs

The function is still named epoxy_kv_get_optimistic. The body references input.key (which does not exist on Input -- which has begin_key/end_key/limit/reverse) and uses Output { value: Some(...) } when Output here has entries: Vec. This file will not compile. The list fan-out logic is entirely unimplemented.

2. KvListRequest is not handled in message_request.rs

The variant was added to the RequestKind union in the protocol schema but there is no corresponding match arm in message_request_inner. Nodes receiving a KvListRequest over the wire will hit an unhandled case.

High Severity Logic Errors

3. cache_begin_key is constructed from end_key (list_local.rs)

let cache_begin_key = KvOptimisticCacheKey::new(end_key.to_vec()); // BUG: should be begin_key

This makes the cache range scan always have begin == end, so cache entries are never returned when include_cache = true.

4. Output ordering is not preserved in list_local_values

Entries are collected into a std::collections::HashMap before being returned as a Vec. HashMap iteration order is non-deterministic, discarding the ordering FDB provides. The reverse parameter becomes a no-op in the final output. Use an IndexMap (insertion-order) or sort the output by key before returning.

5. Cache entry deserialized with wrong key type (list_local.rs)

In the Either::Right (cache) branch, entries are deserialized using KvValueKey instead of KvOptimisticCacheKey. Compare with get_local.rs which correctly uses cache_key.deserialize(...). This will produce incorrect data or panic.

Medium Severity Issues

6. limit is not applied to the cache stream

The value stream respects limit, but the RangeOption for the cache stream has no limit set. A small limit from the caller will still cause a full cache range scan.

7. CommittedEntry schema type is unused

CommittedEntry (key + value) was added to v2.bare but KvListResponse uses list (value only). If callers need to know which key each value belongs to, KvListResponse should use list. Currently CommittedEntry has no references.

8. No legacy subspace fallback in list_local_values

read_local_value falls back to LegacyCommittedValueKey for v1 EPaxos data. list_local_values only scans the v2 KvValueKey subspace. During a migration window, list operations will silently omit entries that single-key gets return correctly.

Convention Issues

9. Glob import from anyhow in list_optimistic.rs

use anyhow::*;

From CLAUDE.md: "Do not glob import (::*) from anyhow. Instead, import individual types and traits." Use use anyhow::Result; instead.

10. filter_map idiom can be simplified (list_local.rs)

// Current
.filter_map(|e| {
    if let Some(value) = e.value { Some(Entry { ... }) } else { None }
})

// Preferred
.filter_map(|e| e.value.map(|value| Entry { ... }))

11. Doc comments in list_optimistic.rs were copied verbatim and are stale

The comments still describe get semantics and contain -- em-dash substitutes. Per CLAUDE.md: "Do not use em dashes. Use periods to separate sentences instead."

Test Coverage

No tests are included (PR is draft). Before merging, tests should cover: forward and reverse range scans, key range boundaries, cache merge with include_cache = true (including the cache_begin_key bug as a regression), and the KvListRequest dispatch path.

Summary Table

Issue Severity
list_optimistic.rs is a broken copy-paste that will not compile Blocker
KvListRequest unhandled in message_request.rs dispatch Blocker
cache_begin_key uses end_key instead of begin_key High
HashMap destroys FDB sort order; reverse is a no-op High
Cache entries deserialized with wrong key type High
limit not applied to cache stream Medium
CommittedEntry unused; list response omits keys Medium
No legacy subspace fallback Medium
Glob import use anyhow::* Low
filter_map idiom Low
Stale/incorrect copied comments Low
No tests Required before merge

The refactoring of read_value.rs into get_local.rs is clean and the &[u8] signature improvement is a nice change. The rest needs significant work before it can be merged.

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