You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by hg...@apache.org on 2026/07/02 22:08:50 UTC
(iggy) 43/43: fix(server-ng): reject flush with typed unavailable deny
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a commit to branch http-listener-rebased
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit 7c78a34676b7bd459f865606391409cefa8334ae
Author: Hubert Gruszecki <h....@gmail.com>
AuthorDate: Thu Jul 2 23:59:40 2026 +0200
fix(server-ng): reject flush with typed unavailable deny
server-ng has no on-demand flush primitive: the journal
drains to disk on its own threshold. FLUSH_UNSAVED_BUFFER
had no handler, so it fell through the non-replicated
catch-all and fake-succeeded with an empty ok, attesting a
durability guarantee the server never made.
Return a typed FeatureUnavailable from the response builder
instead. The existing deny path surfaces it through the
reply status the SDK peeks, so clients get an honest error.
A real force-flush primitive remains future work.
---
core/integration/tests/server/flush_vsr.rs | 66 ++++++++++++++++++++++++++++++
core/integration/tests/server/mod.rs | 3 ++
core/server-ng/src/responses.rs | 11 +++--
3 files changed, 77 insertions(+), 3 deletions(-)
diff --git a/core/integration/tests/server/flush_vsr.rs b/core/integration/tests/server/flush_vsr.rs
new file mode 100644
index 000000000..68f41040e
--- /dev/null
+++ b/core/integration/tests/server/flush_vsr.rs
@@ -0,0 +1,66 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Flush contract against server-ng (vsr): the server has no on-demand flush
+//! primitive, so `FLUSH_UNSAVED_BUFFER` must surface a typed
+//! `FeatureUnavailable` over the SDK rather than the non-replicated catch-all's
+//! empty-ok, which would fake a durability guarantee.
+
+use iggy::prelude::*;
+use integration::iggy_harness;
+
+// server-ng partition ids are 0-based (CreateTopic assigns them from 0).
+const PARTITION_ID: u32 = 0;
+
+#[iggy_harness(
+ test_client_transport = [Tcp],
+ server(tcp.socket.override_defaults = true, tcp.socket.nodelay = true)
+)]
+async fn given_valid_partition_when_flushing_should_reject_feature_unavailable(
+ harness: &TestHarness,
+) {
+ let client = harness.tcp_root_client().await.expect("tcp root client");
+ client
+ .create_stream("flush-stream")
+ .await
+ .expect("create stream");
+ let stream_id = Identifier::from_str_value("flush-stream").expect("stream identifier");
+ client
+ .create_topic(
+ &stream_id,
+ "flush-topic",
+ 1,
+ CompressionAlgorithm::None,
+ None,
+ IggyExpiry::NeverExpire,
+ MaxTopicSize::ServerDefault,
+ )
+ .await
+ .expect("create topic");
+ let topic_id = Identifier::from_str_value("flush-topic").expect("topic identifier");
+
+ // A valid, existing partition proves the deny is feature-unavailable, not a
+ // target-not-found in disguise; fsync makes it the strongest durability ask.
+ let result = client
+ .flush_unsaved_buffer(&stream_id, &topic_id, PARTITION_ID, true)
+ .await;
+
+ assert!(
+ matches!(&result, Err(error) if error.as_code() == IggyError::FeatureUnavailable.as_code()),
+ "flush over TCP-ng must surface Err(FeatureUnavailable), got {result:?}"
+ );
+}
diff --git a/core/integration/tests/server/mod.rs b/core/integration/tests/server/mod.rs
index eeb536de9..619402c6f 100644
--- a/core/integration/tests/server/mod.rs
+++ b/core/integration/tests/server/mod.rs
@@ -24,6 +24,9 @@ mod cg;
// The ported round-robin membership join scenario runs against server-ng.
#[cfg(feature = "vsr")]
mod cg_vsr;
+// Flush (FLUSH_UNSAVED_BUFFER) has no server-ng primitive; it must deny typed.
+#[cfg(feature = "vsr")]
+mod flush_vsr;
// Raw-HTTP data-plane contract against server-ng's shard-0 listener.
#[cfg(feature = "vsr")]
mod http_vsr;
diff --git a/core/server-ng/src/responses.rs b/core/server-ng/src/responses.rs
index 3dc41486c..b5a8d26f3 100644
--- a/core/server-ng/src/responses.rs
+++ b/core/server-ng/src/responses.rs
@@ -29,9 +29,9 @@ use crate::wire::{transport_kind_to_wire, usize_to_u32};
use bytes::{BufMut, Bytes, BytesMut};
use consensus::{MetadataHandle, VsrConsensus};
use iggy_binary_protocol::codes::{
- GET_CLUSTER_METADATA_CODE, GET_CONSUMER_GROUP_CODE, GET_CONSUMER_GROUPS_CODE,
- GET_PERSONAL_ACCESS_TOKENS_CODE, GET_STATS_CODE, GET_STREAM_CODE, GET_STREAMS_CODE,
- GET_TOPIC_CODE, GET_TOPICS_CODE, GET_USER_CODE, GET_USERS_CODE,
+ FLUSH_UNSAVED_BUFFER_CODE, GET_CLUSTER_METADATA_CODE, GET_CONSUMER_GROUP_CODE,
+ GET_CONSUMER_GROUPS_CODE, GET_PERSONAL_ACCESS_TOKENS_CODE, GET_STATS_CODE, GET_STREAM_CODE,
+ GET_STREAMS_CODE, GET_TOPIC_CODE, GET_TOPICS_CODE, GET_USER_CODE, GET_USERS_CODE,
};
use iggy_binary_protocol::consensus::{RESULT_COUNT_LEN, result_code};
use iggy_binary_protocol::primitives::consumer::WireConsumer;
@@ -474,6 +474,11 @@ pub(crate) fn build_non_replicated_response(
NonReplicatedResponse::Bytes(GetConsumerGroupsResponse { groups }.to_bytes())
}))
}
+ // server-ng has no force-flush primitive: the journal drains to disk on
+ // its own threshold, not on demand. Answer an honest `FeatureUnavailable`
+ // rather than the non-replicated catch-all's empty-ok, which would attest
+ // a durability guarantee the server never made.
+ FLUSH_UNSAVED_BUFFER_CODE => Err(IggyError::FeatureUnavailable),
_ => match iggy_binary_protocol::dispatch::lookup_command(code) {
Some(meta) if !meta.is_replicated() => Ok(NonReplicatedResponse::Empty),
Some(_) => Err(IggyError::FeatureUnavailable),