Skip to content

*: refactor proxy to hub lib for columnar#10849

Open
yongman wants to merge 8 commits into
pingcap:masterfrom
yongman:refactor-proxy-base
Open

*: refactor proxy to hub lib for columnar#10849
yongman wants to merge 8 commits into
pingcap:masterfrom
yongman:refactor-proxy-base

Conversation

@yongman
Copy link
Copy Markdown
Member

@yongman yongman commented May 19, 2026

What problem does this PR solve?

Issue Number: ref #10844

Problem Summary:
Proxy source code is complicated to maintain.

What is changed and how it works?

Build the tiflash server with ENABLE_NEXT_GEN_COLUMNAR=ON and ENABLE_NEXT_GEN=ON will link the new tiflash-columnar-hub lib to access kvengine.

  1. Remove the old tiflash-proxy-columnar contrib.
  2. Add the new lightweight tiflash-columnar-hub with cloud-storage-engine dependencies to the crontrib directly to simplfy maintainance.
  3. Add pd store heartbeat to keep store healthy in pd.
  4. Add status_server to expose http apis such as /debug/pprof/....

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Summary by CodeRabbit

  • New Features

    • TiFlash Columnar Hub runtime with HTTP status endpoints (metrics, profiling, config, ready).
    • Columnar readers and snapshot fetching with in-memory cache and cloud storage integration.
    • Exposed FFI surface for columnar proxy interactions and runtime helpers.
  • Bug Fixes

    • Improved startup/readiness behavior and defensive handling when running in columnar mode.
  • Chores

    • Migrated to a new columnar-hub workspace, updated Rust toolchain and build wiring.

Signed-off-by: yongman <yming0221@gmail.com>
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented May 19, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels May 19, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented May 19, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jayson-huang for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

Replace the old columnar proxy submodule with a new Rust-based tiflash-columnar-hub, update build/CMake wiring, introduce C++ FFI contracts, implement a Rust cdylib runtime (cloud helper, columnar reader FFI, status server, profiling, metrics), and wire the hub into disaggregated storage and proxy state machine.

Changes

TiFlash Columnar Hub Proxy Integration

Layer / File(s) Summary
Submodule and Build System Migration
.gitmodules, cmake/find_tiflash_proxy.cmake, contrib/tiflash-proxy-cmake/CMakeLists.txt, contrib/tiflash-columnar-hub/Makefile, contrib/tiflash-columnar-hub/Cargo.toml, contrib/tiflash-columnar-hub/hub-runtime/Cargo.toml, contrib/tiflash-columnar-hub/rust-toolchain.toml
Removes contrib/tiflash-proxy-columnar entry and updates CMake and proxy build plumbing to reference contrib/tiflash-columnar-hub, including Makefile/Cargo manifests, lockfile/toolchain integration, and .gitignore for Rust target.
C++ FFI Contract and Data Types
contrib/tiflash-columnar-hub/hub-runtime/ffi/src/RaftStoreProxyFFI/*
Adds C++ ABI headers: version/magic, Common, ColumnFamily, EncryptionFFI, ProxyFFI with enums/structs and EngineStoreServerHelper function-pointer table; exposes ffi_get_server_info_from_proxy.
Rust Cargo Workspace and Build Configuration
contrib/tiflash-columnar-hub/Cargo.toml, contrib/tiflash-columnar-hub/hub-runtime/Cargo.toml, contrib/tiflash-columnar-hub/Makefile, contrib/tiflash-columnar-hub/workspace-hack/*
Defines Rust workspace (hub-runtime), pins dependencies and patches, adds workspace-hack to avoid allocator conflicts for cdylib, and provides Makefile targets and toolchain pinning.
Rust FFI Type Bindings and Basic Helpers
contrib/tiflash-columnar-hub/hub-runtime/src/basic_ffi_impls.rs, contrib/tiflash-columnar-hub/hub-runtime/src/interfaces.rs, contrib/tiflash-columnar-hub/hub-runtime/src/domain_impls.rs, contrib/tiflash-columnar-hub/hub-runtime/src/lib.rs
Implements Rust-side ABI types and helpers: unsafe unwrapping trait, BaseBuffView conversions and to_slice, protobuf wrapper, pinned builders for Rust-owned strings/vectors, GC entrypoint, and re-exports with version/FFI entrypoints.
Rust Engine Store Helper and Hub Runtime
contrib/tiflash-columnar-hub/hub-runtime/src/engine_store_helper.rs, contrib/tiflash-columnar-hub/hub-runtime/src/hub.rs
Publishes a global EngineStoreServerHelper pointer with acquire/release accessors, wraps helper operations via a trait, and defines ColumnarHub holding CloudHelper, status, and config with FFI pointer conversions.
Rust Cloud Helper and Columnar Reader
contrib/tiflash-columnar-hub/hub-runtime/src/cloud_helper.rs, contrib/tiflash-columnar-hub/hub-runtime/src/columnar_impls.rs
Implements CloudHelper to fetch snapshots from leader stores with retries/backoff, PD caching, IA meta GC, in-memory weighted snapshot cache, and FFI functions to construct and read columnar readers from encoded protobuf/byte views.
Rust HTTP Status Server and Runtime Services
contrib/tiflash-columnar-hub/hub-runtime/src/run.rs, contrib/tiflash-columnar-hub/hub-runtime/src/status_server.rs, contrib/tiflash-columnar-hub/hub-runtime/src/profile.rs, contrib/tiflash-columnar-hub/hub-runtime/src/metrics.rs, contrib/tiflash-columnar-hub/hub-runtime/src/server_info.rs
Adds full runtime: config/CLI overrides, logging resolution, PD registration/heartbeat, store-id persistence, Hyper-based status server with metrics/profiling/failpoints/engine-store proxying, profiling and metrics modules, and tests.
C++ Disaggregated Context and Storage Integration
dbms/src/Interpreters/SharedContexts/Disagg.h, dbms/src/Server/Server.cpp, dbms/src/Server/main.cpp, dbms/src/Storages/KVStore/ProxyStateMachine.h, dbms/src/Storages/KVStore/TMTContext.cpp, dbms/src/Storages/Page/V3/CMakeLists.txt, dbms/src/Storages/StorageDisaggregated.cpp, dbms/src/Storages/StorageDisaggregatedColumnar.cpp
Adds columnar_proxy_helper to shared context with accessors; moves proxy-helper setup to shared context; handle nullable KVStore paths in startup/stop flows; switch page-storage include to TIFLASH_PROXY_INCLUDE_DIR; and improve error handling and runtime checks in columnar read path.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~65 minutes

Possibly related PRs

  • pingcap/tiflash#10842: Overlapping changes to CMake/find logic for next-gen columnar proxy source selection.

Suggested labels

approved, lgtm

Suggested reviewers

  • JaySon-Huang
  • CalvinNeo
  • JinheLin

Poem

🐇 I hopped through headers, Rust and C,
Built snapshots, metrics, and FFI,
A columnar hub now hums in place,
Status, profiling, heartbeat race,
Cheers — a rabbit happy with this spree.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

@ti-chi-bot ti-chi-bot Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 19, 2026
yongman added 2 commits May 19, 2026 21:31
Signed-off-by: yongman <yming0221@gmail.com>
Signed-off-by: yongman <yming0221@gmail.com>
Signed-off-by: yongman <yming0221@gmail.com>
@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 21, 2026
Signed-off-by: yongman <yming0221@gmail.com>
@yongman yongman marked this pull request as ready for review May 21, 2026 10:36
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 21, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented May 21, 2026

@yongman I've received your pull request and will start the review. I'll conduct a thorough review covering code quality, potential issues, and implementation details.

⏳ This process typically takes 10-30 minutes depending on the complexity of the changes.

ℹ️ Learn more details on Pantheon AI.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contrib/tiflash-columnar-hub/hub-runtime/src/basic_ffi_impls.rs`:
- Around line 69-72: ProtoMsgBaseBuff::new currently calls
msg.write_to_bytes().unwrap() which can panic; change its signature to return
protobuf::ProtobufResult<Self> (i.e., return Ok(ProtoMsgBaseBuff{ data }) or
propagate the error from write_to_bytes()) instead of unwrapping, and update the
two FFI callers ffi_server_info and ffi_get_server_info_from_proxy to handle the
Result—map Err to a non-zero u32 error code returned over the FFI and on Ok
extract the ProtoMsgBaseBuff to continue; ensure no unwraps remain and error
paths return the designated non-zero value.
- Around line 59-62: The current BaseBuffView::to_slice calls
std::slice::from_raw_parts unconditionally which is UB when data is null even if
len == 0; modify the method to check self.data for null and return an empty
slice (&[]) when data.is_null() (or when len == 0 and data.is_null()), otherwise
call unsafe std::slice::from_raw_parts(self.data as *const _, self.len as
usize); update the implementation inside impl BaseBuffView::to_slice to perform
this null check before constructing the slice.

In `@contrib/tiflash-columnar-hub/hub-runtime/src/cloud_helper.rs`:
- Around line 638-665: The code currently calls merge_from_bytes(...).unwrap()
on DelegateResponse (delegate_resp.merge_from_bytes(&snap_data).unwrap()) and on
kvenginepb::ChangeSet (cs.merge_from_bytes(&snap_bytes).unwrap()), which panics
on malformed payloads; change those unwraps to proper error handling: replace
both unwrap() calls with match or map_err to capture the protobuf parse error,
log a descriptive message including tag/shard_id, and propagate the error to the
caller (return Err(...)) using an appropriate Error variant (or wrap the parse
error into an existing Error type) so invalid/partial responses are returned as
errors instead of panicking the worker task; update references around
DelegateResponse::merge_from_bytes and kvenginepb::ChangeSet::merge_from_bytes
accordingly.

In `@contrib/tiflash-columnar-hub/hub-runtime/src/columnar_impls.rs`:
- Around line 76-179: The ffi_make_columnar_reader should not panic on malformed
FFI input: add a null check for hub_ptr (use
RaftStoreProxyPtr::is_null()/as_ref() guard) and replace all unchecked slice
indexing and unwrap() calls in parse_table_ranges, the filter_conditions loop,
the tables_range_view loop, and the protobuf merge_from_bytes calls for columns,
table_scan, ann_query_info, and fts_query_info with validated bounds checks and
error handling; on any length/truncation/parse error (from parse_from_bytes or
merge_from_bytes) return a ColumnarReaderPtr containing crate::Error::Other(...)
converted via .into() instead of panicking so callers receive
ColumnarReaderPtr.error_type.

In `@contrib/tiflash-columnar-hub/hub-runtime/src/domain_impls.rs`:
- Around line 35-64: The current From<u32> for RawRustPtrType uses
std::mem::transmute which can produce undefined behaviour for invalid
discriminants and ffi_gc_rust_ptr panics on unexpected tags (which will abort
across FFI); replace the unchecked transmute with a checked conversion
(implement TryFrom<u32> for RawRustPtrType or an explicit mapping function that
matches each u32 to a valid RawRustPtrType and returns a Result/Option), update
call sites to use the try conversion and handle failures gracefully, and modify
ffi_gc_rust_ptr (and any other extern "C" entrypoints using RawRustPtrType) to
avoid panic on unknown tags by either safely ignoring unknown/None variants,
logging an error, or performing the correct free for additional valid variants
(e.g., ReadIndexTask, ArcFutureWaker, TimerTask) rather than calling panic!; key
symbols to change: the impl From<u32> for RawRustPtrType, add TryFrom/TryInto
for RawRustPtrType, and update ffi_gc_rust_ptr to use the checked conversion and
non-panicking error path.

In `@contrib/tiflash-columnar-hub/hub-runtime/src/engine_store_helper.rs`:
- Around line 29-37: Change the global pointer pattern to a one-shot, unsafe
initializer: replace the raw Atomic store with a
OnceLock<NonNull<EngineStoreServerHelper>> (or OnceCell) and make
init_engine_store_server_helper unsafe and accept
NonNull<EngineStoreServerHelper> (not *const u8); call once_lock.set(ptr) so the
pointer can only be set once. Update get_engine_store_server_helper to read the
OnceLock, unwrap_or_panic if unset, then convert the stored NonNull to &'static
EngineStoreServerHelper inside an unsafe block. Keep names
ENGINE_STORE_SERVER_HELPER_PTR, init_engine_store_server_helper, and
get_engine_store_server_helper to locate the changes.

In `@contrib/tiflash-columnar-hub/hub-runtime/src/run.rs`:
- Around line 318-320: The code currently assigns the "--advertise-engine-addr"
value into the same field used for the bind address (config.server.engine_addr),
which clobbers the listen address when both flags are provided; instead, add or
use a separate field (e.g., config.server.advertise_engine_addr) and set that
from matches.value_of("advertise-engine-addr") so the existing
config.server.engine_addr remains the bind address; update the ServerConfig
struct to include advertise_engine_addr (or the equivalent field already
present) and wire that field where PD/store registration constructs the
advertised endpoint.
- Around line 955-987: The sanitizer in sanitize_proxy_args is dropping attached
short-option values like -A1.2.3.4:20170 because it only expands -C, -s, -L and
-f; add a branch that mirrors the others to handle strip_prefix("-A") (check
value.is_empty(), push "-A".to_owned() and value.to_owned(), increment i,
continue) so attached -A... forms are preserved for clap parsing; ensure the new
branch follows the same pattern and placement as the existing -C/-s/-L/-f
blocks.
- Around line 1125-1134: In run_proxy, guard against malformed FFI inputs: first
check argc >= 0 and only cast to usize after that check (use the validated
n_args for Vec::with_capacity), ensure argv is non-null when n_args > 0, and for
each index verify argv.offset(i) is non-null before calling CStr::from_ptr; do
not call unwrap() on CStr::to_str() — instead handle invalid UTF-8 by using
to_str().map(...) or to_string_lossy() and propagate or log errors for any
invalid C string so the function doesn’t panic; reference the run_proxy function
and the earlier run_raftstore_proxy_ffi call path when adding these validations.

In `@contrib/tiflash-columnar-hub/hub-runtime/src/status_server.rs`:
- Around line 298-313: The handlers currently detect "simplify" and "verbose" by
substring checks which mis-handle values like "?verbose=false" and match
unrelated keys; update handle_metrics and handle_ready to call the shared
parse_bool_query helper (or implement exact-query parsing) to read the boolean
query parameter by name (e.g., parse_bool_query(&req.uri(), "simplify") and
parse_bool_query(&req.uri(), "verbose")), so that exact keys and explicit false
values are respected instead of using query.contains(...).

In `@contrib/tiflash-proxy-cmake/CMakeLists.txt`:
- Around line 109-114: The current CMake uses set_property(... PROPERTY
OBJECT_DEPENDS ...) to attach ${_TIFLASH_PROXY_CARGO_LOCK} to
${_TIFLASH_PROXY_LIBRARY}, but ${_TIFLASH_PROXY_LIBRARY} is produced by
add_custom_command and OBJECT_DEPENDS will not retrigger that command; remove
the set_property(...) block and instead, inside the add_custom_command(...) that
creates ${_TIFLASH_PROXY_LIBRARY}, add "${_TIFLASH_PROXY_CARGO_LOCK}" to its
DEPENDS list (guarded with if(EXISTS ${_TIFLASH_PROXY_CARGO_LOCK})), so changes
to the Cargo.lock will correctly re-run the custom command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1fa92c01-2a8e-4015-8a7f-e7dcdd067faa

📥 Commits

Reviewing files that changed from the base of the PR and between 6f17860 and e04f1d5.

⛔ Files ignored due to path filters (1)
  • contrib/tiflash-columnar-hub/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (38)
  • .gitmodules
  • cmake/find_tiflash_proxy.cmake
  • contrib/tiflash-columnar-hub/.gitignore
  • contrib/tiflash-columnar-hub/Cargo.toml
  • contrib/tiflash-columnar-hub/Makefile
  • contrib/tiflash-columnar-hub/hub-runtime/Cargo.toml
  • contrib/tiflash-columnar-hub/hub-runtime/ffi/src/RaftStoreProxyFFI/@version
  • contrib/tiflash-columnar-hub/hub-runtime/ffi/src/RaftStoreProxyFFI/ColumnFamily.h
  • contrib/tiflash-columnar-hub/hub-runtime/ffi/src/RaftStoreProxyFFI/Common.h
  • contrib/tiflash-columnar-hub/hub-runtime/ffi/src/RaftStoreProxyFFI/EncryptionFFI.h
  • contrib/tiflash-columnar-hub/hub-runtime/ffi/src/RaftStoreProxyFFI/ProxyFFI.h
  • contrib/tiflash-columnar-hub/hub-runtime/ffi/src/RaftStoreProxyFFI/VersionCheck.h
  • contrib/tiflash-columnar-hub/hub-runtime/src/basic_ffi_impls.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/cloud_helper.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/columnar_impls.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/domain_impls.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/engine_store_helper.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/hub.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/interfaces.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/lib.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/metrics.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/profile.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/run.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/server_info.rs
  • contrib/tiflash-columnar-hub/hub-runtime/src/status_server.rs
  • contrib/tiflash-columnar-hub/rust-toolchain.toml
  • contrib/tiflash-columnar-hub/workspace-hack/Cargo.toml
  • contrib/tiflash-columnar-hub/workspace-hack/src/lib.rs
  • contrib/tiflash-proxy-cmake/CMakeLists.txt
  • contrib/tiflash-proxy-columnar
  • dbms/src/Interpreters/SharedContexts/Disagg.h
  • dbms/src/Server/Server.cpp
  • dbms/src/Server/main.cpp
  • dbms/src/Storages/KVStore/ProxyStateMachine.h
  • dbms/src/Storages/KVStore/TMTContext.cpp
  • dbms/src/Storages/Page/V3/CMakeLists.txt
  • dbms/src/Storages/StorageDisaggregated.cpp
  • dbms/src/Storages/StorageDisaggregatedColumnar.cpp
💤 Files with no reviewable changes (2)
  • contrib/tiflash-proxy-columnar
  • .gitmodules

Comment thread contrib/tiflash-columnar-hub/hub-runtime/src/basic_ffi_impls.rs
Comment thread contrib/tiflash-columnar-hub/hub-runtime/src/basic_ffi_impls.rs
Comment thread contrib/tiflash-columnar-hub/hub-runtime/src/cloud_helper.rs
Comment thread contrib/tiflash-columnar-hub/hub-runtime/src/columnar_impls.rs
Comment thread contrib/tiflash-columnar-hub/hub-runtime/src/domain_impls.rs
Comment thread contrib/tiflash-columnar-hub/hub-runtime/src/run.rs
Comment thread contrib/tiflash-columnar-hub/hub-runtime/src/run.rs
Comment thread contrib/tiflash-columnar-hub/hub-runtime/src/run.rs
Comment thread contrib/tiflash-columnar-hub/hub-runtime/src/status_server.rs
Comment on lines +109 to +114
if (EXISTS "${_TIFLASH_PROXY_CARGO_LOCK}")
set_property(
SOURCE ${_TIFLASH_PROXY_LIBRARY}
APPEND
PROPERTY OBJECT_DEPENDS "${_TIFLASH_PROXY_CARGO_LOCK}")
endif()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In CMake, does set_property(SOURCE <generated_output_path> PROPERTY OBJECT_DEPENDS ...)affect rebuilds for anadd_custom_command(OUTPUT ...)target, or must the dependency be listed inadd_custom_command(... DEPENDS ...)?

💡 Result:

The OBJECT_DEPENDS source file property does not affect the rebuild behavior of add_custom_command(OUTPUT ...) targets [1][2]. OBJECT_DEPENDS is a specialized property intended to specify additional dependencies for compiled object files (such as those generated from C++ source files) [1][2]. When using Makefile or Ninja generators, an object file will be recompiled if any file listed in OBJECT_DEPENDS is newer than the object file itself [1][2]. This property is not intended to track dependencies for custom commands and does not influence the dependency graph of add_custom_command outputs [1][2]. To ensure that an add_custom_command output is rebuilt when a dependency changes, you must list the dependency explicitly in the DEPENDS argument of the add_custom_command itself [3]. If your custom command needs to depend on the output of another command or a specific file, include that file path or the OUTPUT of the other command directly in the DEPENDS list [3]. If you are attempting to create a dependency on a different target (like a library or executable), using the target name in the DEPENDS list will establish the necessary dependency [3]. For more complex inter-target dependencies where file-level dependencies are not automatically handled, add_dependencies may be used to establish target-level ordering, but this does not replace the need for file-level dependencies in add_custom_command [1][4].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="contrib/tiflash-proxy-cmake/CMakeLists.txt"
# Show the relevant region around the reported lines plus the nearby variable definitions
nl -ba "$FILE" | sed -n '70,150p'

Repository: pingcap/tiflash

Length of output: 102


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="contrib/tiflash-proxy-cmake/CMakeLists.txt"
if [ ! -f "$FILE" ]; then
  echo "Missing $FILE" >&2
  exit 1
fi

# Print a narrower window around the reported lines using cat -n
cat -n "$FILE" | sed -n '80,140p'

Repository: pingcap/tiflash

Length of output: 2174


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "_TIFLASH_PROXY_CARGO_LOCK" -S contrib/tiflash-proxy-cmake/CMakeLists.txt

Repository: pingcap/tiflash

Length of output: 250


Cargo.lock dependency is wired to the wrong CMake mechanism

  • ${_TIFLASH_PROXY_CARGO_LOCK} is only added via set_property(... PROPERTY OBJECT_DEPENDS ...) (lines 109-114), but ${_TIFLASH_PROXY_LIBRARY} is the OUTPUT of add_custom_command(...) (lines 98-107). OBJECT_DEPENDS is for compiled object files and won’t trigger reruns of an add_custom_command when the lockfile changes.
  • Remove the set_property(SOURCE ${_TIFLASH_PROXY_LIBRARY} ... OBJECT_DEPENDS ...) block and instead add "${_TIFLASH_PROXY_CARGO_LOCK}" to the DEPENDS list of that add_custom_command(...) (conditionally with if(EXISTS ...)).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contrib/tiflash-proxy-cmake/CMakeLists.txt` around lines 109 - 114, The
current CMake uses set_property(... PROPERTY OBJECT_DEPENDS ...) to attach
${_TIFLASH_PROXY_CARGO_LOCK} to ${_TIFLASH_PROXY_LIBRARY}, but
${_TIFLASH_PROXY_LIBRARY} is produced by add_custom_command and OBJECT_DEPENDS
will not retrigger that command; remove the set_property(...) block and instead,
inside the add_custom_command(...) that creates ${_TIFLASH_PROXY_LIBRARY}, add
"${_TIFLASH_PROXY_CARGO_LOCK}" to its DEPENDS list (guarded with if(EXISTS
${_TIFLASH_PROXY_CARGO_LOCK})), so changes to the Cargo.lock will correctly
re-run the custom command.

Signed-off-by: yongman <yming0221@gmail.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
dbms/src/Server/Server.cpp (1)

1230-1231: 💤 Low value

Use the local is_disagg_storage_mode for consistency.

A few lines above (Line 753) you already cache is_disagg_storage_mode = global_context->getSharedContextDisagg()->isDisaggregatedStorageMode(); and use it throughout main. Calling getSharedContextDisagg()->isDisaggregatedStorageMode() again here is functionally equivalent but inconsistent with the surrounding style.

♻️ Proposed tweak
-                    if (global_context->getSharedContextDisagg()->isDisaggregatedStorageMode()
-                        && !store_ident.has_value())
+                    if (is_disagg_storage_mode && !store_ident.has_value())
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Server/Server.cpp` around lines 1230 - 1231, Replace the direct call
to global_context->getSharedContextDisagg()->isDisaggregatedStorageMode() with
the cached local boolean is_disagg_storage_mode for consistency; specifically,
update the if-condition that checks disaggregated storage and store_ident (the
line currently using
global_context->getSharedContextDisagg()->isDisaggregatedStorageMode()) to
reference is_disagg_storage_mode alongside store_ident.has_value().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@dbms/src/Server/Server.cpp`:
- Around line 1230-1231: Replace the direct call to
global_context->getSharedContextDisagg()->isDisaggregatedStorageMode() with the
cached local boolean is_disagg_storage_mode for consistency; specifically,
update the if-condition that checks disaggregated storage and store_ident (the
line currently using
global_context->getSharedContextDisagg()->isDisaggregatedStorageMode()) to
reference is_disagg_storage_mode alongside store_ident.has_value().

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: db96903f-3922-4fe1-a098-b19a403b2c70

📥 Commits

Reviewing files that changed from the base of the PR and between e04f1d5 and 196d272.

📒 Files selected for processing (1)
  • dbms/src/Server/Server.cpp

yongman and others added 2 commits May 22, 2026 11:11
Signed-off-by: yongman <yming0221@gmail.com>
…nullptr or not

Signed-off-by: JaySon-Huang <tshent@qq.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@dbms/src/Server/Server.cpp`:
- Around line 1209-1214: The code logs "columnar proxy is ready to serve" when
proxy_machine.isColumnar() is true even if the proxy isn't runnable; update the
condition so the columnar-ready message only appears when the proxy is runnable
as well—either reorder to check proxy_machine.isProxyRunnable() first or change
the branch to require both predicates (e.g., proxy_machine.isColumnar() &&
proxy_machine.isProxyRunnable()) before calling LOG_INFO(log, "columnar proxy is
ready to serve"), ensuring the rest of the else-if logic
(proxy_machine.isProxyRunnable()) still executes correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fa478638-3aa1-448a-ba7f-be455210742d

📥 Commits

Reviewing files that changed from the base of the PR and between f74cb3b and 804117f.

📒 Files selected for processing (2)
  • dbms/src/Server/Server.cpp
  • dbms/src/Storages/KVStore/ProxyStateMachine.h

Comment on lines +1209 to +1214
if (proxy_machine.isColumnar())
{
const auto store_id = tmt_context.getKVStore()->getStoreID(std::memory_order_seq_cst);
LOG_INFO(log, "columnar proxy is ready to serve");
}
else if (proxy_machine.isProxyRunnable())
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Gate the columnar “ready” path on runnable state.

At Line 1209, isColumnar() is checked before isProxyRunnable(), so a columnar-but-not-runnable configuration can still log “ready to serve”.

Proposed fix
-        if (proxy_machine.isColumnar())
+        if (proxy_machine.isColumnar() && proxy_machine.isProxyRunnable())
         {
             LOG_INFO(log, "columnar proxy is ready to serve");
         }
+        else if (proxy_machine.isColumnar())
+        {
+            LOG_WARNING(log, "columnar mode is enabled but proxy is not runnable");
+        }
         else if (proxy_machine.isProxyRunnable())
         {
             auto kvstore = tmt_context.getKVStore();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Server/Server.cpp` around lines 1209 - 1214, The code logs "columnar
proxy is ready to serve" when proxy_machine.isColumnar() is true even if the
proxy isn't runnable; update the condition so the columnar-ready message only
appears when the proxy is runnable as well—either reorder to check
proxy_machine.isProxyRunnable() first or change the branch to require both
predicates (e.g., proxy_machine.isColumnar() && proxy_machine.isProxyRunnable())
before calling LOG_INFO(log, "columnar proxy is ready to serve"), ensuring the
rest of the else-if logic (proxy_machine.isProxyRunnable()) still executes
correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants