Skip to content

Gate test-only helpers; fix and enable clippy performance lints - #138

Open
austin-barrington wants to merge 9 commits into
refactor/split-large-functionsfrom
refactor/lint-cleanup
Open

austin-barrington wants to merge 9 commits into
refactor/split-large-functionsfrom
refactor/lint-cleanup

Conversation

@austin-barrington

Copy link
Copy Markdown
Member

Stacked on #137. Plan: docs/superpowers/plans/2026-11-03-lint-and-test-support-cleanup.md.

  • Test-only helpers leave production builds.

    • 8 helpers used only by unit tests get #[cfg(test)], along with one private function and one import that only they used.
    • 9 helpers used by integration tests, benches or proxy tests get #[doc(hidden)] and a "Test support." line.
  • Clippy performance findings are fixed:

    • redundant clones, across lib, tests and benches;
    • three large futures, now Box::pinned;
    • one needless_collect, now any;
    • four or(...) calls, now lazy;
    • five hot-path lock scopes narrowed:
      • location cache: the entry is built before taking the write lock;
      • location cache: the read guard ends before the map fallback;
      • take_qps: the guard ends at remove;
      • statement summary: the read lock is dropped before the sort.

    batching_wal's drain(..) stays, with a reason: the buffer is reused.

  • [lints.clippy] in all three crates: redundant_clone, large_futures, needless_collect, iter_with_drain and or_fun_call, made errors by CI's -D warnings. significant_drop_tightening stays off.

No behaviour change. Gate: fmt, clippy --workspace --all-targets -D warnings, unit, integration 376 and CLI 54 tests all pass.

@cursor

cursor Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Refactors are mechanical lint fixes and API visibility gates; no intended behavior change, with tests noted as passing in the PR description.

Overview
Adds [lints.clippy] performance rules (redundant_clone, large_futures, needless_collect, iter_with_drain, or_fun_call) to hyperbytedb, hyperbytedb-proxy, and hyperbytedb-cli, aligned with CI treating warnings as errors.

Test surface cleanup: helpers that are unit-test-only are #[cfg(test)]; helpers used from integration tests, benches, or proxy tests get #[doc(hidden)] and a “Test support.” note so they stay out of the public contract without changing runtime behavior.

Lint-driven refactors across lib, benches, and tests: drop redundant Arc/clone(); Box::pin on oversized startup futures in serve / Raft bootstrap; any instead of collecting missing field columns in the chDB adapter; lazy or_else for pool-size resolution and split-key selection; shorter lock hold times in ShardLocationCache, statement summary sorting, and RegionWriteStats::take_qps. batching_wal keeps drain(..) with an explicit allow (buffer reuse); compat tests allow needless_collect where asserts need a Vec.

Reviewed by Cursor Bugbot for commit 985270c. Configure here.

consensus.propose returns Ok for a committed op that the apply refused
(a stale epoch). Drain ignored ClusterResponse.ok, so a refused
TransferPrimary counted as handed off. Check it, as the shard scheduler
does.
flushed_through started at 0 on open, while last_sequence is restored
from disk. Only the flush truncates, so every entry below the oldest one
left was flushed. With the mark at 0, every DELETE and DROP SERIES on a
restarted node that had nothing left to flush waited the full 15 s for
it, inside the Raft apply on replicated nodes.
drop_series wiped the measurement's series metadata, then built the
delete predicate, which refuses a field or an unknown tag. A refused
DROP SERIES returned an error and left SHOW SERIES empty. Build every
predicate first.

DROP SERIES with no FROM deleted rows only on a sharded node; on a single
node it dropped the series and kept every row, which tombstones no longer
hide. It now deletes them everywhere.
A peer deletes a DELETE's rows from its whole table after waiting up to
15 s for its WAL to flush. The coordinator sent one request per region on
the 5 s peer timeout: a peer leading K regions ran K full-table deletes,
and under steady ingest the coordinator timed out and reported a failed
delete that the peer then carried out. Send each primary one request, with
the flush wait plus the peer timeout to answer in.
is_unknown_table matched "Code: 60", which codes 600-609 also start
with, and a delete that failed with one reported success. is_unknown_column
matched "Code: 47" (470-479), and a replica stored such a failed delete
as a tombstone. Match "Code: 60." and "Code: 47.".
The deep-dive and developer guides still pointed at
adapters/cluster/sync_client.rs, which became CatchUpService in
application/cluster/catch_up.rs. Also drop a repeated #[doc(hidden)] and
a repeated doc line, and move apply_shard_map_op's doc comment from
`mod apply;` onto the function.

This branch has not been deployed

No deployments
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