Skip to content

feat(sdk): implement vsr header framing#3254

Open
numinnex wants to merge 16 commits into
masterfrom
integration_tests
Open

feat(sdk): implement vsr header framing#3254
numinnex wants to merge 16 commits into
masterfrom
integration_tests

Conversation

@numinnex
Copy link
Copy Markdown
Contributor

Adds Vsr feature flag in the sdk crate that introduces the consensus header required by the requests.
Additionally adds one hello_world test that tests the login command using the new integration test suite adapted to server-ng binary.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

❌ Patch coverage is 22.25313% with 559 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.44%. Comparing base (99c82b8) to head (a380f4b).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
core/server-ng/src/bootstrap.rs 0.00% 450 Missing ⚠️
core/metadata/src/stm/user.rs 5.88% 48 Missing ⚠️
core/metadata/src/impls/metadata.rs 0.00% 11 Missing ⚠️
core/sdk/src/tcp/tcp_client.rs 60.00% 5 Missing and 3 partials ⚠️
core/message_bus/src/lib.rs 58.82% 4 Missing and 3 partials ⚠️
core/consensus/src/client_table.rs 0.00% 6 Missing ⚠️
core/message_bus/src/client_listener/quic.rs 66.66% 0 Missing and 6 partials ⚠️
core/message_bus/src/socket_opts.rs 81.25% 0 Missing and 6 partials ⚠️
core/message_bus/src/replica/io.rs 0.00% 0 Missing and 5 partials ⚠️
core/sdk/src/websocket/websocket_client.rs 88.57% 2 Missing and 2 partials ⚠️
... and 4 more

❌ Your patch check has failed because the patch coverage (22.25%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3254      +/-   ##
============================================
- Coverage     73.78%   73.44%   -0.35%     
  Complexity      943      943              
============================================
  Files          1200     1200              
  Lines        109116   109661     +545     
  Branches      86004    86567     +563     
============================================
+ Hits          80516    80543      +27     
- Misses        25874    26353     +479     
- Partials       2726     2765      +39     
Components Coverage Δ
Rust Core 74.50% <22.25%> (-0.43%) ⬇️
Java SDK 58.44% <ø> (ø)
C# SDK 69.13% <ø> (-0.33%) ⬇️
Python SDK 81.43% <ø> (ø)
Node SDK 91.44% <ø> (ø)
Go SDK 39.91% <ø> (ø)
Files with missing lines Coverage Δ
core/binary_protocol/src/consensus/operation.rs 96.19% <100.00%> (+0.07%) ⬆️
core/binary_protocol/src/dispatch.rs 91.45% <100.00%> (ø)
.../src/traits/binary_impls/personal_access_tokens.rs 100.00% <ø> (ø)
core/common/src/traits/binary_impls/users.rs 100.00% <ø> (ø)
core/message_bus/src/client_listener/tcp.rs 78.26% <100.00%> (-1.74%) ⬇️
core/message_bus/src/client_listener/tcp_tls.rs 83.78% <100.00%> (-0.84%) ⬇️
core/message_bus/src/client_listener/ws.rs 79.16% <100.00%> (-1.61%) ⬇️
core/message_bus/src/client_listener/wss.rs 83.78% <100.00%> (-0.84%) ⬇️
core/message_bus/src/replica/listener.rs 84.41% <100.00%> (-0.40%) ⬇️
core/message_bus/src/transports/quic.rs 91.76% <100.00%> (-0.25%) ⬇️
... and 18 more

... and 24 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hubcio
Copy link
Copy Markdown
Contributor

hubcio commented May 14, 2026

/ready

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label May 14, 2026
Copy link
Copy Markdown
Contributor

@hubcio hubcio left a comment

Choose a reason for hiding this comment

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

notes on items that did not fit a line range:

  • the IggyNamespace::new masking issue (namespace.rs:108-113) is upstream and not touched by this PR, but the SDK now feeds raw wire u32s straight into it (vsr.rs:187), so the silent-collision blast radius lands inside this PR. would be good to range-check at the SDK boundary even if the namespace fix lands separately.
  • send_raw_with_response retry at tcp_client.rs:136-148 is pre-existing, but the new reset_vsr_session() calls at lines 548/567 turn the retry path into a silent recovery failure when auto_login=Disabled: reset clears the bound session, connect() skips re-login, next send_raw encodes with session=None and returns Unauthenticated for what looks like a transient transport error. consider gating retry on session.is_bound() under vsr, or forcing auto_login on under vsr.
  • #[cfg(feature = "vsr")] is interleaved per-line across core/sdk/src/{tcp,quic,websocket}/*.rs (8 separate gates in tcp_client.rs alone). consider extracting send_legacy / send_vsr helpers per transport, or splitting the vsr framing into its own module, to reduce mis-edit hazard.

Comment thread core/sdk/src/vsr.rs Outdated
}
_ => {
let operation =
Operation::from_command_code(code).ok_or(IggyError::FeatureUnavailable)?;
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.

Operation::from_command_code returns None for every read-only command (PING, GET_STATS, GET_STREAM, POLL_MESSAGES, etc. - see the read_only_commands_have_no_operation test in core/binary_protocol/src/consensus/operation.rs). this branch then returns FeatureUnavailable for every read. any vsr-mode integration test that does client.ping(), get_*, or poll_messages will fail closed - hello_world only logs in so it masks the bug today. the read path needs to bypass the op-table lookup (dedicated Operation::Read/Operation::NonReplicated/Operation::Query or similar, with session + request_id only).

Comment thread core/sdk/src/vsr.rs Outdated
topic_id: &WireIdentifier,
partition_id: Option<u32>,
) -> Result<u64, IggyError> {
let stream_id = stream_id.as_u32().ok_or(IggyError::FeatureUnavailable)?;
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.

namespace_from_partition calls WireIdentifier::as_u32().ok_or(FeatureUnavailable). the String variant always returns None, so send_messages, store_consumer_offset, delete_consumer_offset, *_2, and delete_segments all fail closed whenever stream/topic is supplied by name (the idiomatic SDK usage). either resolve name → numeric id via metadata round-trip before computing the namespace, or surface a clear numeric-only restriction with a proper error variant.

Comment thread core/sdk/src/vsr.rs
let stream_id = stream_id.as_u32().ok_or(IggyError::FeatureUnavailable)?;
let topic_id = topic_id.as_u32().ok_or(IggyError::FeatureUnavailable)?;
let partition_id = partition_id.ok_or(IggyError::FeatureUnavailable)?;
Ok(IggyNamespace::new(stream_id as usize, topic_id as usize, partition_id as usize).inner())
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.

partition_id as usize is unchecked at the SDK boundary, and IggyNamespace::new then does (partition as u64) & PARTITION_MASK (namespace.rs:108-113) with no overflow check on the masked field. any wire partition_id >= 2^20 wraps and two distinct partitions collapse to the same namespace, routing to the wrong shard. validate at the SDK boundary, and ideally make IggyNamespace::new fallible so the limits (4096/4096/1M) are enforced by the type rather than masked away.

Comment thread core/sdk/src/vsr.rs Outdated
let header = RequestHeader {
command: Command2::Request,
operation,
size: total_size as u32,
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.

size: total_size as u32 silently truncates on payloads > 4 GiB. checked_add two lines above only protects the usize math; nothing protects the u32 narrowing. swap for u32::try_from(total_size).map_err(...)

Comment thread core/sdk/src/vsr.rs Outdated

let mut request = BytesMut::with_capacity(total_size);
request.put_slice(bytemuck::bytes_of(&header));
request.put_slice(payload);
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.

fresh BytesMut + two put_slice calls per request memcpy the full header + payload on the hot send path. legacy framing wrote header/code/payload into a caller-owned buffer. consider vectored write of header + payload, or reserve a header slot in the caller buffer so the payload doesn't need to be copied.

Comment thread core/server-ng/src/session_manager.rs Outdated
Comment thread core/server-ng/src/session_manager.rs Outdated
Comment thread core/server-ng/src/server_error.rs
Comment thread core/message_bus/src/socket_opts.rs Outdated
Comment thread core/integration-vsr/src/lib.rs Outdated
@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels May 20, 2026
@numinnex
Copy link
Copy Markdown
Contributor Author

@hubcio made a commit that addresses issues from those comments

@numinnex
Copy link
Copy Markdown
Contributor Author

/review

@hubcio
Copy link
Copy Markdown
Contributor

hubcio commented May 20, 2026

@numinnex my review had 19 comments; youaddressed only 4 (vsr.rs:61 u32::try_from, vsr.rs:209-211, validate_namespace_field, session_manager::add_connection removed, integration-vsr crate removed).

15 issues are still present. if you dont want to fix them now please at least add TODO in code.

@numinnex
Copy link
Copy Markdown
Contributor Author

/review

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

Labels

S-waiting-on-author PR is waiting on author response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants