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/10/16 16:20:37 UTC
(iggy) branch fix/remove-cg-session-timeout updated (8c229ca4b -> 27f6a7660)
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a change to branch fix/remove-cg-session-timeout
in repository https://gitbox.apache.org/repos/asf/iggy.git
omit 8c229ca4b Merge branch 'master' into fix/remove-cg-session-timeout
omit db4d86fe5 Merge branch 'master' into fix/remove-cg-session-timeout
omit 8d1b1c0e0 fix(server): explain the session timeout floor at boot and in docs
omit f89b5254a fix(server)!: derive session timeout from heartbeat.interval
new aabbf5bc1 fix(server)!: derive session timeout from heartbeat.interval
new ea9e15f42 fix(server): explain the session timeout floor at boot and in docs
new 27f6a7660 fix(ci): keep job timing API errors from failing finalize_pr
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (8c229ca4b)
\
N -- N -- N refs/heads/fix/remove-cg-session-timeout (27f6a7660)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/pre-merge.yml | 3 +++
1 file changed, 3 insertions(+)
(iggy) 03/03: fix(ci): keep job timing API errors from failing finalize_pr
Posted by hg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a commit to branch fix/remove-cg-session-timeout
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit 27f6a7660f02ac098a2080d92412321e83947288
Author: Hubert Gruszecki <h....@gmail.com>
AuthorDate: Fri Oct 16 18:19:11 2026 +0200
fix(ci): keep job timing API errors from failing finalize_pr
On re-run attempts of full-matrix runs, the job listing in "Get job
execution times" exceeds the ~10 s GitHub gateway timeout and gets
a 502. The unhandled error failed the step, so "Check status" never
ran and the required finalize_pr check failed with all jobs green.
The durations only fill the summary table, and the gate reads
needs.*.result, so the step can now fail without failing the job.
---
.github/workflows/pre-merge.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/pre-merge.yml b/.github/workflows/pre-merge.yml
index 13456e635..956ca8384 100644
--- a/.github/workflows/pre-merge.yml
+++ b/.github/workflows/pre-merge.yml
@@ -213,8 +213,11 @@ jobs:
needs: [common, detect, runtime, rust-test-build, test-rust, test-rust-runtime, test-python, test-php, test-node, test-go, test-java, test-csharp, test-cpp, test-swift, test-bdd, test-examples, test-other]
if: ${{ !cancelled() }}
steps:
+ # The durations only fill the summary table. A GitHub API error here
+ # must not skip "Check status", which decides the required check.
- name: Get job execution times
id: times
+ continue-on-error: true
uses: actions/github-script@v9
with:
script: |
(iggy) 02/03: fix(server): explain the session timeout floor at boot and in docs
Posted by hg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a commit to branch fix/remove-cg-session-timeout
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit ea9e15f422ec12cb52421d4dc1b0d7ac382dcc41
Author: Hubert Gruszecki <h....@gmail.com>
AuthorDate: Fri Oct 16 15:45:34 2026 +0200
fix(server): explain the session timeout floor at boot and in docs
Boot rejected every heartbeat.interval up to about 17.67s at the
default 5s report interval, but neither the docs nor the error named
that floor. The refusal of consumer_group.session_timeout did not
name its successor either. The [heartbeat] text also promised that a
dead client loses its session with checks off, but a half-open TCP
socket keeps it. State the floor and name the session timeout in both
refusals. Rename staleness_window() to session_timeout(), so that one
value has one name.
Two stale-client specs no longer sleep 30s: one waits for zero
members, and the other sleeps 20s again.
The Swift userLifecycle test failed when the primary answered
transient_not_committed (57) while it applied another test's op. The
SDK then reports the later refusals of that request as 57 too. The
test now sends a fresh request, which gets a definite answer.
---
core/configs/src/common/server.rs | 13 +++---
core/configs/src/configs_impl/file_provider.rs | 17 ++++++++
core/configs/src/server_config/server.rs | 8 ++--
core/configs/src/server_config/validators.rs | 16 ++++----
.../stale_client_consumer_group_scenario.rs | 48 +++++++++++-----------
core/server/config.toml | 10 ++++-
core/server/src/boot/mod.rs | 4 +-
core/server/src/dispatch/host.rs | 4 +-
core/server/src/dispatch/session_ops.rs | 4 +-
foreign/node/README.md | 9 ++--
.../swift/Tests/IggyE2ETests/ClientE2ETests.swift | 4 +-
.../IggyE2ETests/Support/E2EEnvironment.swift | 21 ++++++++++
12 files changed, 102 insertions(+), 56 deletions(-)
diff --git a/core/configs/src/common/server.rs b/core/configs/src/common/server.rs
index 3d93d0ba0..09f16db14 100644
--- a/core/configs/src/common/server.rs
+++ b/core/configs/src/common/server.rs
@@ -85,21 +85,20 @@ pub struct HeartbeatConfig {
}
impl HeartbeatConfig {
- // A client is stale once it misses 1.2 intervals. Integer 6/5 rather
- // than `mul_f64`, which panics on an absurd interval.
- const STALENESS_NUMERATOR: u32 = 6;
- const STALENESS_DENOMINATOR: u32 = 5;
+ // Integer 6/5 rather than `mul_f64`, which panics on an absurd interval.
+ const SESSION_TIMEOUT_NUMERATOR: u32 = 6;
+ const SESSION_TIMEOUT_DENOMINATOR: u32 = 5;
/// The session timeout, 1.2 x `interval`. With heartbeat checks on, a
/// connection silent this long stops renewing its session. With or without
/// checks, the metadata primary ends a session that no server renewed for
/// this long.
#[must_use]
- pub fn staleness_window(&self) -> Duration {
+ pub fn session_timeout(&self) -> Duration {
self.interval
.get_duration()
- .saturating_mul(Self::STALENESS_NUMERATOR)
- / Self::STALENESS_DENOMINATOR
+ .saturating_mul(Self::SESSION_TIMEOUT_NUMERATOR)
+ / Self::SESSION_TIMEOUT_DENOMINATOR
}
}
diff --git a/core/configs/src/configs_impl/file_provider.rs b/core/configs/src/configs_impl/file_provider.rs
index 00ac8f744..91bd1049e 100644
--- a/core/configs/src/configs_impl/file_provider.rs
+++ b/core/configs/src/configs_impl/file_provider.rs
@@ -33,6 +33,8 @@ pub enum RelocatedTarget {
TopicOption(&'static str),
MovedTo(&'static str),
Removed,
+ /// Removed, and another setting now decides the value. The text names it.
+ Superseded(&'static str),
}
/// A config key that no longer exists, and what took over from it.
@@ -58,6 +60,7 @@ impl RelocatedKey {
}
RelocatedTarget::MovedTo(path) => format!("move this setting to '{path}'"),
RelocatedTarget::Removed => "this setting or table was removed".to_string(),
+ RelocatedTarget::Superseded(successor) => successor.to_string(),
}
}
}
@@ -379,6 +382,20 @@ mod tests {
assert_eq!(key.guidance(), "move this setting to 'encryption'");
}
+ #[test]
+ fn superseded_settings_name_what_decides_the_value_now() {
+ let key = RelocatedKey {
+ path: "consumer_group.session_timeout",
+ replacement: RelocatedTarget::Superseded(
+ "the session timeout is now 1.2 x heartbeat.interval",
+ ),
+ };
+ assert_eq!(
+ key.guidance(),
+ "the session timeout is now 1.2 x heartbeat.interval"
+ );
+ }
+
fn names(names: &[&str]) -> Vec<String> {
names.iter().map(|name| (*name).to_string()).collect()
}
diff --git a/core/configs/src/server_config/server.rs b/core/configs/src/server_config/server.rs
index 406a9696c..56f23a483 100644
--- a/core/configs/src/server_config/server.rs
+++ b/core/configs/src/server_config/server.rs
@@ -153,11 +153,13 @@ const RELOCATED_CONFIG_KEYS: &[RelocatedKey] = &[
path: "extra",
replacement: RelocatedTarget::Removed,
},
- // 1.2 x heartbeat.interval is the session timeout now. Refusing the old
- // key keeps an operator's timeout from changing without notice.
+ // Refusing the old key keeps an operator's timeout from changing without
+ // notice.
RelocatedKey {
path: "consumer_group.session_timeout",
- replacement: RelocatedTarget::Removed,
+ replacement: RelocatedTarget::Superseded(
+ "the session timeout is now 1.2 x heartbeat.interval",
+ ),
},
];
diff --git a/core/configs/src/server_config/validators.rs b/core/configs/src/server_config/validators.rs
index 92b1f644f..ce7caf83a 100644
--- a/core/configs/src/server_config/validators.rs
+++ b/core/configs/src/server_config/validators.rs
@@ -359,11 +359,11 @@ impl Validatable<ConfigurationError> for ServerConfig {
// These knobs sit on shared section structs, so the rejects live
// here rather than in those types' own `Validatable` impls. `0` /
// `disabled` / `unlimited` all parse to the same zero duration.
- let staleness_window = self.heartbeat.staleness_window();
+ let session_timeout = self.heartbeat.session_timeout();
let heartbeat_interval = self.consumer_group.heartbeat_interval.get_duration();
if heartbeat_interval.is_zero() {
eprintln!(
- "{COMPONENT} consumer_group.heartbeat_interval ({heartbeat_interval:?}) must be nonzero; the session timeout, 1.2 x heartbeat.interval, is {staleness_window:?}"
+ "{COMPONENT} consumer_group.heartbeat_interval ({heartbeat_interval:?}) must be nonzero; the session timeout, 1.2 x heartbeat.interval, is {session_timeout:?}"
);
return Err(ConfigurationError::InvalidConfigurationValue);
}
@@ -373,16 +373,16 @@ impl Validatable<ConfigurationError> for ServerConfig {
.saturating_add(CONSUMER_SESSION_REPORT_TIMEOUT)
.saturating_mul(CONSUMER_SESSION_MISSED_REPORT_TOLERANCE + 1)
.saturating_add(heartbeat_interval);
- if staleness_window <= minimum_timeout {
+ if session_timeout <= minimum_timeout {
eprintln!(
- "{COMPONENT} 1.2 x heartbeat.interval ({staleness_window:?}) must exceed {minimum_timeout:?}, covering three consumer_group.heartbeat_interval periods and two gather/send deadlines, allowing one missed report"
+ "{COMPONENT} the session timeout, 1.2 x heartbeat.interval ({session_timeout:?}), must exceed {minimum_timeout:?}, covering three consumer_group.heartbeat_interval periods and two gather/send deadlines, allowing one missed report. Raise heartbeat.interval, which sets the session timeout also with heartbeat.enabled = false, or lower consumer_group.heartbeat_interval"
);
return Err(ConfigurationError::InvalidConfigurationValue);
}
let cluster_timeout = self.cluster.heartbeat_timeout.get_duration();
- if self.cluster.enabled && staleness_window <= cluster_timeout {
+ if self.cluster.enabled && session_timeout <= cluster_timeout {
eprintln!(
- "{COMPONENT} 1.2 x heartbeat.interval ({staleness_window:?}) must exceed cluster.heartbeat_timeout ({cluster_timeout:?})"
+ "{COMPONENT} the session timeout, 1.2 x heartbeat.interval ({session_timeout:?}), must exceed cluster.heartbeat_timeout ({cluster_timeout:?}). Raise heartbeat.interval"
);
return Err(ConfigurationError::InvalidConfigurationValue);
}
@@ -1120,7 +1120,7 @@ mod tests {
}
#[test]
- fn given_heartbeat_window_above_missed_report_budget_when_validating_should_pass() {
+ fn given_session_timeout_above_missed_report_budget_when_validating_should_pass() {
let config = config_with_override(
"[consumer_group]\nheartbeat_interval = \"500ms\"\n[heartbeat]\ninterval = \"6417ms\"\n",
);
@@ -1140,7 +1140,7 @@ mod tests {
}
#[test]
- fn given_heartbeat_window_within_cluster_liveness_window_when_validating_should_reject() {
+ fn given_session_timeout_within_cluster_liveness_window_when_validating_should_reject() {
for interval in ["12500ms", "15s"] {
let config = config_with_override(&format!(
"[cluster]\nenabled = true\nheartbeat_timeout = \"18s\"\n[consumer_group]\nheartbeat_interval = \"500ms\"\n[heartbeat]\ninterval = \"{interval}\"\n"
diff --git a/core/integration/tests/server/scenarios/stale_client_consumer_group_scenario.rs b/core/integration/tests/server/scenarios/stale_client_consumer_group_scenario.rs
index 0812a4393..e649ed757 100644
--- a/core/integration/tests/server/scenarios/stale_client_consumer_group_scenario.rs
+++ b/core/integration/tests/server/scenarios/stale_client_consumer_group_scenario.rs
@@ -32,6 +32,11 @@ use tokio::time::sleep;
/// suite.
const STALE_EVICTION_TIMEOUT: Duration = Duration::from_secs(30);
const STALE_EVICTION_RETRY_INTERVAL: Duration = Duration::from_millis(200);
+/// How long a live member must keep its membership across a backup restart.
+/// More than twice the 8.4s session timeout at the specs' 7s heartbeat
+/// interval, so the wait outlasts the expiry of a lease that the restart
+/// stopped renewing.
+const MEMBERSHIP_HOLD_PERIOD: Duration = Duration::from_secs(20);
const STREAM_NAME: &str = "stale-test-stream";
const TOPIC_NAME: &str = "stale-test-topic";
@@ -142,7 +147,7 @@ async fn given_live_member_when_backup_restarts_should_preserve_membership(
harness.kill_node(2).unwrap();
harness.restart_node(2).unwrap();
- sleep(STALE_EVICTION_TIMEOUT).await;
+ sleep(MEMBERSHIP_HOLD_PERIOD).await;
let observer = harness.root_client_for_node(0).await.unwrap();
let after = observer
@@ -446,28 +451,15 @@ async fn should_handle_stale_client_with_manual_reconnection(
// waiting for. That is also why the assertion below gets only a couple of
// attempts -- each one refreshes liveness, so retrying harder makes
// eviction less likely, not more.
- let deadline = tokio::time::Instant::now() + STALE_EVICTION_TIMEOUT;
- loop {
- let group = setup_client
- .get_consumer_group(
- &Identifier::named(STREAM_NAME).unwrap(),
- &Identifier::named(TOPIC_NAME).unwrap(),
- &Identifier::named(CONSUMER_GROUP_NAME).unwrap(),
- )
- .await
- .unwrap()
- .expect("consumer group exists");
- if group.members_count == 0 {
- break;
- }
- assert!(
- tokio::time::Instant::now() < deadline,
- "stale client was not evicted within {STALE_EVICTION_TIMEOUT:?}, \
- group still reports {} member(s)",
- group.members_count
- );
- sleep(STALE_EVICTION_RETRY_INTERVAL).await;
- }
+ integration::harness::wait_for_consumer_group_assignment(
+ &setup_client,
+ &Identifier::named(STREAM_NAME).unwrap(),
+ &Identifier::named(TOPIC_NAME).unwrap(),
+ &Identifier::named(CONSUMER_GROUP_NAME).unwrap(),
+ 0,
+ STALE_EVICTION_TIMEOUT,
+ )
+ .await;
let mut got_error = false;
for _ in 0..3 {
@@ -582,7 +574,15 @@ async fn should_handle_stale_client_with_auto_reconnection(
// Stay silent until the verifier evicts the connection and
// the server ends the session, so the consumer must
// reconnect, log in again and rejoin its group.
- sleep(STALE_EVICTION_TIMEOUT).await;
+ integration::harness::wait_for_consumer_group_assignment(
+ &setup_client,
+ &Identifier::named(STREAM_NAME).unwrap(),
+ &Identifier::named(TOPIC_NAME).unwrap(),
+ &Identifier::named(CONSUMER_GROUP_NAME).unwrap(),
+ 0,
+ STALE_EVICTION_TIMEOUT,
+ )
+ .await;
}
}
}
diff --git a/core/server/config.toml b/core/server/config.toml
index b3485d122..0905e628a 100644
--- a/core/server/config.toml
+++ b/core/server/config.toml
@@ -326,14 +326,20 @@ enabled = true
# Interval for expected client heartbeats. 1.2 x interval is the session
# timeout: the metadata primary ends a session that no server reported for
# that long, whether or not heartbeat checks are enabled. That covers a closed
-# connection, a crashed client and a lost node. With checks on, it also covers
-# a silent connection, which loses its session after about 2.4 x interval.
+# connection and a lost node. With checks on, it also covers a silent
+# connection, which loses its session after about 2.4 x interval. With checks
+# off, a client host that dies without closing its socket keeps its session:
+# TCP and WebSocket set no keepalive, and only QUIC closes such a connection,
+# after quic.max_idle_timeout. An idle HTTP session expires after about
+# 2.4 x interval either way.
# The consumer groups of an ended session rebalance, and its client must log
# in again. Each new primary grants a fresh timeout. Incomplete client lists
# defer expiry across the cluster until a full timeout has passed without an
# incomplete report. 1.2 x interval must exceed cluster.heartbeat_timeout when
# clustering is enabled, and three consumer_group.heartbeat_interval periods
# plus two gather (3s) and send (100ms) deadlines, allowing one missed report.
+# So interval must exceed (3 x consumer_group.heartbeat_interval + 6.2s) / 1.2:
+# about 17.67s at the default 5s, and always more than 5.16s.
# The SDKs ping automatically every 5 s, but only from a connected high-level
# client: the Rust and Java pingers start in connect(), so a session that logs
# in without it never pings. Use the same settings on all nodes.
diff --git a/core/server/src/boot/mod.rs b/core/server/src/boot/mod.rs
index f6acb1087..a1d0e90a1 100644
--- a/core/server/src/boot/mod.rs
+++ b/core/server/src/boot/mod.rs
@@ -875,7 +875,7 @@ async fn shard_main(
let hb_shard = Rc::clone(&shard);
let hb_sessions = Rc::clone(&sessions);
let hb_interval = config.heartbeat.interval.get_duration();
- let hb_max_age = config.heartbeat.staleness_window();
+ let hb_max_age = config.heartbeat.session_timeout();
let hb_handle = compio::runtime::spawn(async move {
crate::dispatch::session_ops::run_heartbeat_verifier(
hb_shard,
@@ -1043,7 +1043,7 @@ async fn shard_main(
let (stop_tx, stop_rx) = channel(1);
let cleaner_shard = Rc::clone(&shard);
let interval = config.consumer_group.heartbeat_interval.get_duration();
- let timeout = config.heartbeat.staleness_window();
+ let timeout = config.heartbeat.session_timeout();
let system_path = config.get_system_path();
let handle = compio::runtime::spawn(async move {
crate::consumer_group::liveness::run(
diff --git a/core/server/src/dispatch/host.rs b/core/server/src/dispatch/host.rs
index 859a2362d..21d187fea 100644
--- a/core/server/src/dispatch/host.rs
+++ b/core/server/src/dispatch/host.rs
@@ -183,7 +183,7 @@ where
shard,
submit,
&self.consumer_group_liveness,
- self.server_config.heartbeat.staleness_window(),
+ self.server_config.heartbeat.session_timeout(),
&self.completion_relays,
);
}
@@ -198,7 +198,7 @@ where
self.sessions
.borrow()
.iter_consumer_sessions(if self.server_config.heartbeat.enabled {
- self.server_config.heartbeat.staleness_window()
+ self.server_config.heartbeat.session_timeout()
} else {
Duration::MAX
})
diff --git a/core/server/src/dispatch/session_ops.rs b/core/server/src/dispatch/session_ops.rs
index a5e3f005e..88404aa34 100644
--- a/core/server/src/dispatch/session_ops.rs
+++ b/core/server/src/dispatch/session_ops.rs
@@ -364,8 +364,8 @@ const fn eviction_reason_for(error: &LoginRegisterError) -> EvictionReason {
}
/// Per-shard heartbeat verifier: every `interval`, evict group-member
-/// connections that sent nothing for `max_age`, the heartbeat staleness
-/// window. Mirrors the legacy `verify_heartbeats` periodic task. Eviction
+/// connections that sent nothing for `max_age`, the session timeout.
+/// Mirrors the legacy `verify_heartbeats` periodic task. Eviction
/// removes the connection binding and sends `Eviction(StaleClient)`. The
/// shared logical session and its group membership remain until committed
/// lease expiry or explicit logout.
diff --git a/foreign/node/README.md b/foreign/node/README.md
index 04037815e..f61cc66a0 100644
--- a/foreign/node/README.md
+++ b/foreign/node/README.md
@@ -92,10 +92,11 @@ keeps an idle session alive when the server's `[heartbeat]` eviction is enabled.
With the default heartbeat settings, a client that sends nothing for 36 s
(1.2 x the 30 s interval) stops renewing its session, and the server ends the
session about 36 s later. The verifier checks once per interval and also evicts
-the connection of a consumer-group member that is silent past 36 s. Raising the
-client interval past that window, or setting it to 0 to disable client
-heartbeats, lets an idle session expire. Any other unusable value is rejected
-instead of silently disabling the heartbeat.
+the connection of a consumer-group member that is silent past 36 s. If the
+client interval exceeds 36 s, the verifier evicts an idle group member. If it
+exceeds about 72 s, or is 0 to disable client heartbeats, any idle session
+expires. Any other unusable value is rejected instead of silently disabling the
+heartbeat.
`sendBinaryRequest(code, payload)` sends an arbitrary command code. Known replicated commands use their registered operation, while unknown codes reach the server as non-replicated requests and are rejected by servers that do not register them.
diff --git a/foreign/swift/Tests/IggyE2ETests/ClientE2ETests.swift b/foreign/swift/Tests/IggyE2ETests/ClientE2ETests.swift
index 9acc134c8..a5e7cecc8 100644
--- a/foreign/swift/Tests/IggyE2ETests/ClientE2ETests.swift
+++ b/foreign/swift/Tests/IggyE2ETests/ClientE2ETests.swift
@@ -317,8 +317,8 @@ struct UserE2ETests {
let identity = try await other.login(username: username, password: "secret-1")
#expect(identity.userID == created.id)
_ = try await other.getStreams()
- await #expect(throws: IggyError(.unauthorized)) {
- try await other.createStream(name: E2EEnvironment.uniqueName("swift-forbidden"))
+ await expectReplicatedIggyError(.unauthorized) {
+ _ = try await other.createStream(name: E2EEnvironment.uniqueName("swift-forbidden"))
}
try await client.changePassword(userID, currentPassword: "secret-1", newPassword: "secret-2")
diff --git a/foreign/swift/Tests/IggyE2ETests/Support/E2EEnvironment.swift b/foreign/swift/Tests/IggyE2ETests/Support/E2EEnvironment.swift
index 4923cfd66..05a809efc 100644
--- a/foreign/swift/Tests/IggyE2ETests/Support/E2EEnvironment.swift
+++ b/foreign/swift/Tests/IggyE2ETests/Support/E2EEnvironment.swift
@@ -199,6 +199,27 @@ func expectIggyError(_ code: IggyErrorCode, sourceLocation: SourceLocation = #_s
}
}
+/// ``expectIggyError(_:sourceLocation:_:)`` for a replicated request. The
+/// server refuses one with `transientNotCommitted` while it applies another
+/// test's op, and the SDK then reports every later refusal of that request the
+/// same way. Only a fresh request, a new run of `body`, gets a definite answer.
+func expectReplicatedIggyError(_ code: IggyErrorCode, sourceLocation: SourceLocation = #_sourceLocation, _ body: () async throws -> Void) async {
+ await expectIggyError(code, sourceLocation: sourceLocation) {
+ for _ in 1..<uncertainOutcomeAttempts {
+ do {
+ return try await body()
+ } catch let error as IggyError where error.code == .transientNotCommitted {
+ continue
+ }
+ }
+ try await body()
+ }
+}
+
+/// Runs of `body` in ``expectReplicatedIggyError(_:sourceLocation:_:)``. Each
+/// uncertain run waits out the request timeout.
+private let uncertainOutcomeAttempts = 3
+
extension IggyClient {
/// ``sendMessages(streamID:topicID:partitioning:messages:)`` for a batch
/// the test does not read back, so the call can take a literal.
(iggy) 01/03: fix(server)!: derive session timeout from heartbeat.interval
Posted by hg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hubcio pushed a commit to branch fix/remove-cg-session-timeout
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit aabbf5bc1e44c8df1ed38e01180dd7df970a1210
Author: Hubert Gruszecki <h....@gmail.com>
AuthorDate: Thu Oct 15 19:10:46 2026 +0200
fix(server)!: derive session timeout from heartbeat.interval
Two settings timed out a silent client. The heartbeat verifier
evicted after 1.2 x heartbeat.interval, while the session report
and the lease used consumer_group.session_timeout. No validator
related them, so a client silent for two 30s timeouts lost its
session even under a 60s heartbeat interval, and the [heartbeat]
docs described only the verifier.
Remove consumer_group.session_timeout, and refuse to boot while it
is still set, so a configured timeout cannot change unnoticed. The
lease, the activity window of the session report and the verifier
now all use 1.2 x heartbeat.interval, also with heartbeat checks
off, and the validators check that window. At the defaults a
closed connection ends after about 36s and a silent one after
about 72s. A heartbeat.interval of 17.7s or less now needs a
shorter consumer_group.heartbeat_interval. Specs that pinned an 8s
timeout set a 7s interval, and those that close their members turn
the checks off so idle open members keep their sessions.
---
bdd/docker-compose.cluster.yml | 1 -
core/configs/src/common/defaults.rs | 5 --
core/configs/src/common/displays.rs | 4 +-
core/configs/src/common/server.rs | 23 +++++-
core/configs/src/server_config/server.rs | 6 ++
core/configs/src/server_config/validators.rs | 91 ++++++++++------------
core/integration/tests/cluster/chaos_monkey.rs | 14 ++--
.../tests/cluster/client_table_restart.rs | 11 ++-
.../verify_consumer_group_partition_assignment.rs | 61 +++++++++------
core/integration/tests/sdk/consumer_group.rs | 4 +-
.../tests/sdk/consumer_group_membership.rs | 7 +-
core/integration/tests/server/cg.rs | 11 ++-
.../stale_client_consumer_group_scenario.rs | 53 +++++++------
core/server/config.toml | 44 +++++------
core/server/src/boot/mod.rs | 10 ++-
core/server/src/dispatch/host.rs | 10 +--
core/server/src/dispatch/session_ops.rs | 13 ++--
.../Fixtures/IggyServerFixture.cs | 21 +++--
.../Iggy_SDK.Tests.Integration/HeartbeatTests.cs | 6 +-
foreign/node/README.md | 13 ++--
20 files changed, 213 insertions(+), 195 deletions(-)
diff --git a/bdd/docker-compose.cluster.yml b/bdd/docker-compose.cluster.yml
index 0ccc3a676..9004a45f0 100644
--- a/bdd/docker-compose.cluster.yml
+++ b/bdd/docker-compose.cluster.yml
@@ -60,7 +60,6 @@ x-cluster-topology: &cluster-topology
# Keep role-specific scenarios on view 0 when a loaded CI runner delays
# one replica during startup.
IGGY_CLUSTER_HEARTBEAT_TIMEOUT: "30s"
- IGGY_CONSUMER_GROUP_SESSION_TIMEOUT: "60s"
IGGY_CLUSTER_NODES_0_NAME: leader-node
IGGY_CLUSTER_NODES_0_IP: 172.28.0.101
IGGY_CLUSTER_NODES_0_REPLICA_ID: "0"
diff --git a/core/configs/src/common/defaults.rs b/core/configs/src/common/defaults.rs
index 2ede3d6d2..6d44232a4 100644
--- a/core/configs/src/common/defaults.rs
+++ b/core/configs/src/common/defaults.rs
@@ -182,11 +182,6 @@ impl Default for HeartbeatConfig {
impl Default for ConsumerGroupConfig {
fn default() -> ConsumerGroupConfig {
ConsumerGroupConfig {
- session_timeout: SERVER_CONFIG
- .consumer_group
- .session_timeout
- .parse()
- .unwrap(),
heartbeat_interval: SERVER_CONFIG
.consumer_group
.heartbeat_interval
diff --git a/core/configs/src/common/displays.rs b/core/configs/src/common/displays.rs
index c06d0d1cf..8fdf94c5e 100644
--- a/core/configs/src/common/displays.rs
+++ b/core/configs/src/common/displays.rs
@@ -108,8 +108,8 @@ impl Display for ConsumerGroupConfig {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
- "{{ rebalancing_timeout: {}, session_timeout: {}, heartbeat_interval: {} }}",
- self.rebalancing_timeout, self.session_timeout, self.heartbeat_interval
+ "{{ rebalancing_timeout: {}, heartbeat_interval: {} }}",
+ self.rebalancing_timeout, self.heartbeat_interval
)
}
}
diff --git a/core/configs/src/common/server.rs b/core/configs/src/common/server.rs
index dec2379da..3d93d0ba0 100644
--- a/core/configs/src/common/server.rs
+++ b/core/configs/src/common/server.rs
@@ -22,6 +22,7 @@ use serde_with::DisplayFromStr;
use serde_with::serde_as;
use server_common::MemoryPoolSettings;
use server_common::log::{TelemetryEndpointSettings, TelemetrySettings};
+use std::time::Duration;
pub use server_common::log::TelemetryTransport;
@@ -83,6 +84,25 @@ pub struct HeartbeatConfig {
pub interval: IggyDuration,
}
+impl HeartbeatConfig {
+ // A client is stale once it misses 1.2 intervals. Integer 6/5 rather
+ // than `mul_f64`, which panics on an absurd interval.
+ const STALENESS_NUMERATOR: u32 = 6;
+ const STALENESS_DENOMINATOR: u32 = 5;
+
+ /// The session timeout, 1.2 x `interval`. With heartbeat checks on, a
+ /// connection silent this long stops renewing its session. With or without
+ /// checks, the metadata primary ends a session that no server renewed for
+ /// this long.
+ #[must_use]
+ pub fn staleness_window(&self) -> Duration {
+ self.interval
+ .get_duration()
+ .saturating_mul(Self::STALENESS_NUMERATOR)
+ / Self::STALENESS_DENOMINATOR
+ }
+}
+
#[serde_as]
#[derive(Debug, Deserialize, Serialize, Clone, ConfigEnv)]
#[serde(default)]
@@ -92,9 +112,6 @@ pub struct ConsumerGroupConfig {
pub rebalancing_timeout: IggyDuration,
#[config_env(leaf)]
#[serde_as(as = "DisplayFromStr")]
- pub session_timeout: IggyDuration,
- #[config_env(leaf)]
- #[serde_as(as = "DisplayFromStr")]
pub heartbeat_interval: IggyDuration,
}
diff --git a/core/configs/src/server_config/server.rs b/core/configs/src/server_config/server.rs
index 21040b991..406a9696c 100644
--- a/core/configs/src/server_config/server.rs
+++ b/core/configs/src/server_config/server.rs
@@ -153,6 +153,12 @@ const RELOCATED_CONFIG_KEYS: &[RelocatedKey] = &[
path: "extra",
replacement: RelocatedTarget::Removed,
},
+ // 1.2 x heartbeat.interval is the session timeout now. Refusing the old
+ // key keeps an operator's timeout from changing without notice.
+ RelocatedKey {
+ path: "consumer_group.session_timeout",
+ replacement: RelocatedTarget::Removed,
+ },
];
/// Top-level on-disk config schema for the `iggy-server` binary.
diff --git a/core/configs/src/server_config/validators.rs b/core/configs/src/server_config/validators.rs
index 95af784df..92b1f644f 100644
--- a/core/configs/src/server_config/validators.rs
+++ b/core/configs/src/server_config/validators.rs
@@ -359,11 +359,11 @@ impl Validatable<ConfigurationError> for ServerConfig {
// These knobs sit on shared section structs, so the rejects live
// here rather than in those types' own `Validatable` impls. `0` /
// `disabled` / `unlimited` all parse to the same zero duration.
- let session_timeout = self.consumer_group.session_timeout.get_duration();
+ let staleness_window = self.heartbeat.staleness_window();
let heartbeat_interval = self.consumer_group.heartbeat_interval.get_duration();
if heartbeat_interval.is_zero() {
eprintln!(
- "{COMPONENT} consumer_group.heartbeat_interval ({heartbeat_interval:?}) must be nonzero; consumer_group.session_timeout is {session_timeout:?}"
+ "{COMPONENT} consumer_group.heartbeat_interval ({heartbeat_interval:?}) must be nonzero; the session timeout, 1.2 x heartbeat.interval, is {staleness_window:?}"
);
return Err(ConfigurationError::InvalidConfigurationValue);
}
@@ -373,16 +373,16 @@ impl Validatable<ConfigurationError> for ServerConfig {
.saturating_add(CONSUMER_SESSION_REPORT_TIMEOUT)
.saturating_mul(CONSUMER_SESSION_MISSED_REPORT_TOLERANCE + 1)
.saturating_add(heartbeat_interval);
- if session_timeout <= minimum_timeout {
+ if staleness_window <= minimum_timeout {
eprintln!(
- "{COMPONENT} consumer_group.session_timeout ({session_timeout:?}) must exceed {minimum_timeout:?}, covering three consumer_group.heartbeat_interval periods and two gather/send deadlines, allowing one missed report"
+ "{COMPONENT} 1.2 x heartbeat.interval ({staleness_window:?}) must exceed {minimum_timeout:?}, covering three consumer_group.heartbeat_interval periods and two gather/send deadlines, allowing one missed report"
);
return Err(ConfigurationError::InvalidConfigurationValue);
}
let cluster_timeout = self.cluster.heartbeat_timeout.get_duration();
- if self.cluster.enabled && session_timeout <= cluster_timeout {
+ if self.cluster.enabled && staleness_window <= cluster_timeout {
eprintln!(
- "{COMPONENT} consumer_group.session_timeout ({session_timeout:?}) must exceed cluster.heartbeat_timeout ({cluster_timeout:?})"
+ "{COMPONENT} 1.2 x heartbeat.interval ({staleness_window:?}) must exceed cluster.heartbeat_timeout ({cluster_timeout:?})"
);
return Err(ConfigurationError::InvalidConfigurationValue);
}
@@ -398,13 +398,6 @@ impl Validatable<ConfigurationError> for ServerConfig {
);
return Err(ConfigurationError::InvalidConfigurationValue);
}
- if self.heartbeat.enabled && self.heartbeat.interval.get_duration().is_zero() {
- eprintln!(
- "{COMPONENT} heartbeat.interval must be nonzero when heartbeat.enabled: it sizes both the verifier's sleep and the staleness window, so zero spins the verifier and reaps every live session on its first pass"
- );
- return Err(ConfigurationError::InvalidConfigurationValue);
- }
-
Ok(())
}
}
@@ -1101,30 +1094,35 @@ mod tests {
}
#[test]
- fn given_invalid_consumer_session_intervals_when_validating_should_reject() {
- for settings in [
- "heartbeat_interval = \"0\"",
- "session_timeout = \"0\"",
- "session_timeout = \"disabled\"",
- "session_timeout = \"unlimited\"",
- "heartbeat_interval = \"500ms\"\nsession_timeout = \"2s\"",
- "heartbeat_interval = \"500ms\"\nsession_timeout = \"6500ms\"",
- "heartbeat_interval = \"500ms\"\nsession_timeout = \"7500ms\"",
- "heartbeat_interval = \"500ms\"\nsession_timeout = \"7700ms\"",
- "heartbeat_interval = \"20s\"\nsession_timeout = \"27s\"",
- "heartbeat_interval = \"20s\"\nsession_timeout = \"66s\"",
- "heartbeat_interval = \"30s\"\nsession_timeout = \"30s\"",
- "heartbeat_interval = \"31s\"\nsession_timeout = \"30s\"",
+ fn given_invalid_session_liveness_intervals_when_validating_should_reject() {
+ for (report_interval, heartbeat_interval) in [
+ ("0", "30s"),
+ ("5s", "0"),
+ ("5s", "disabled"),
+ ("5s", "unlimited"),
+ ("500ms", "2s"),
+ ("500ms", "5s"),
+ ("500ms", "6250ms"),
+ ("500ms", "6416ms"),
+ ("20s", "22500ms"),
+ ("20s", "55s"),
+ ("30s", "25s"),
+ ("31s", "25s"),
] {
- let config = config_with_override(&format!("[consumer_group]\n{settings}\n"));
- assert!(config.validate().is_err(), "accepted {settings}");
+ let config = config_with_override(&format!(
+ "[consumer_group]\nheartbeat_interval = \"{report_interval}\"\n[heartbeat]\ninterval = \"{heartbeat_interval}\"\n"
+ ));
+ assert!(
+ config.validate().is_err(),
+ "accepted {report_interval} reports with a {heartbeat_interval} heartbeat"
+ );
}
}
#[test]
- fn given_consumer_session_timeout_above_missed_report_budget_when_validating_should_pass() {
+ fn given_heartbeat_window_above_missed_report_budget_when_validating_should_pass() {
let config = config_with_override(
- "[consumer_group]\nheartbeat_interval = \"500ms\"\nsession_timeout = \"7701ms\"\n",
+ "[consumer_group]\nheartbeat_interval = \"500ms\"\n[heartbeat]\ninterval = \"6417ms\"\n",
);
assert!(config.validate().is_ok());
}
@@ -1142,16 +1140,15 @@ mod tests {
}
#[test]
- fn given_consumer_session_timeout_within_cluster_liveness_window_when_validating_should_reject()
- {
- for timeout in ["15s", "20s"] {
+ fn given_heartbeat_window_within_cluster_liveness_window_when_validating_should_reject() {
+ for interval in ["12500ms", "15s"] {
let config = config_with_override(&format!(
- "[cluster]\nenabled = true\nheartbeat_timeout = \"20s\"\n[consumer_group]\nheartbeat_interval = \"500ms\"\nsession_timeout = \"{timeout}\"\n"
+ "[cluster]\nenabled = true\nheartbeat_timeout = \"18s\"\n[consumer_group]\nheartbeat_interval = \"500ms\"\n[heartbeat]\ninterval = \"{interval}\"\n"
));
- assert!(config.validate().is_err(), "accepted {timeout}");
+ assert!(config.validate().is_err(), "accepted {interval}");
}
let config = config_with_override(
- "[cluster]\nenabled = true\nheartbeat_timeout = \"20s\"\n[consumer_group]\nheartbeat_interval = \"500ms\"\nsession_timeout = \"21s\"\n",
+ "[cluster]\nenabled = true\nheartbeat_timeout = \"18s\"\n[consumer_group]\nheartbeat_interval = \"500ms\"\n[heartbeat]\ninterval = \"16s\"\n",
);
assert!(config.validate().is_ok());
}
@@ -1171,17 +1168,15 @@ mod tests {
}
#[test]
- fn given_zero_heartbeat_interval_when_heartbeat_enabled_should_reject() {
- let config = config_with_override("[heartbeat]\nenabled = true\ninterval = \"0\"\n");
- assert!(config.validate().is_err());
- }
-
- #[test]
- fn given_zero_heartbeat_interval_when_heartbeat_disabled_should_pass() {
- let config = config_with_override("[heartbeat]\nenabled = false\ninterval = \"0\"\n");
- config
- .validate()
- .expect("a disabled heartbeat never reads its interval");
+ fn given_zero_heartbeat_interval_when_validating_should_reject() {
+ // The session timeout derives from the interval even with heartbeat
+ // checks off, so zero would expire every session on its first pass.
+ for enabled in [true, false] {
+ let config = config_with_override(&format!(
+ "[heartbeat]\nenabled = {enabled}\ninterval = \"0\"\n"
+ ));
+ assert!(config.validate().is_err(), "accepted enabled = {enabled}");
+ }
}
// http.enabled needs a non-ServerDefault JWT expiry to clear the sibling
diff --git a/core/integration/tests/cluster/chaos_monkey.rs b/core/integration/tests/cluster/chaos_monkey.rs
index c177a58f3..725a10e4f 100644
--- a/core/integration/tests/cluster/chaos_monkey.rs
+++ b/core/integration/tests/cluster/chaos_monkey.rs
@@ -182,11 +182,11 @@ const DEFAULT_KILL_INTERVAL: Duration = Duration::from_secs(15);
const DEFAULT_DOWNTIME: Duration = Duration::from_secs(5);
/// Every reconnect gives a client a new id, so a member whose node dies stays
-/// behind as a stale member until its lease expires. These values (taken from
-/// client_table_restart.rs) expire it within one kill interval instead of the
-/// default 30 s.
+/// behind as a stale member until its lease expires. The lease lasts 1.2 x the
+/// client heartbeat interval. These values (taken from client_table_restart.rs)
+/// expire it within one kill interval instead of the default 36 s.
const GROUP_HEARTBEAT_INTERVAL: &str = "500ms";
-const GROUP_SESSION_TIMEOUT: &str = "8s";
+const CLIENT_HEARTBEAT_INTERVAL: &str = "7s";
/// Each node runs its own segment cleaner on a timer that starts at boot.
/// With the default one-minute interval, a node killed within a minute of its
/// boot never cleans, so expiry would barely run during the chaos phase.
@@ -483,8 +483,8 @@ fn build_cluster() -> TestHarness {
GROUP_HEARTBEAT_INTERVAL.to_owned(),
),
(
- "consumer_group.session_timeout".to_owned(),
- GROUP_SESSION_TIMEOUT.to_owned(),
+ "heartbeat.interval".to_owned(),
+ CLIENT_HEARTBEAT_INTERVAL.to_owned(),
),
(
"data_maintenance.messages.interval".to_owned(),
@@ -2557,7 +2557,7 @@ fn run_metadata(config: &ChaosConfig) -> serde_json::Value {
"producer_batch": PRODUCER_BATCH,
"producer_pause_ms": PRODUCER_PAUSE.as_millis(),
"heartbeat_interval": GROUP_HEARTBEAT_INTERVAL,
- "session_timeout": GROUP_SESSION_TIMEOUT,
+ "client_heartbeat_interval": CLIENT_HEARTBEAT_INTERVAL,
"cleaner_interval": CLEANER_INTERVAL,
},
"host": {
diff --git a/core/integration/tests/cluster/client_table_restart.rs b/core/integration/tests/cluster/client_table_restart.rs
index fb44f268c..96537fc3a 100644
--- a/core/integration/tests/cluster/client_table_restart.rs
+++ b/core/integration/tests/cluster/client_table_restart.rs
@@ -694,8 +694,8 @@ const LIVENESS_OBSERVATION: Duration = Duration::from_secs(12);
#[iggy_harness(server(
metadata.clients_table_max = 4,
heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
sharding.cpu_allocation = "0..1",
))]
async fn given_full_registry_when_new_clients_arrive_should_preserve_live_members_until_expiry(
@@ -904,7 +904,6 @@ async fn given_full_registry_when_new_clients_arrive_should_preserve_live_member
#[iggy_harness(server(
metadata.clients_table_max = "18",
consumer_group.heartbeat_interval = "5s",
- consumer_group.session_timeout = "30s",
sharding.cpu_allocation = "0..1",
))]
async fn given_ended_sessions_when_registry_is_full_should_retire_more_than_one_per_heartbeat(
@@ -938,8 +937,8 @@ async fn given_ended_sessions_when_registry_is_full_should_retire_more_than_one_
#[iggy_harness(server(
heartbeat.enabled = false,
+ heartbeat.interval = "18s",
consumer_group.heartbeat_interval = "5s",
- consumer_group.session_timeout = "22s",
sharding.cpu_allocation = "0..1",
))]
async fn given_many_recovered_members_when_expiring_should_drain_without_another_interval(
@@ -1004,8 +1003,8 @@ async fn given_many_recovered_members_when_expiring_should_drain_without_another
#[iggy_harness(cluster_nodes = 3, server(
heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
sharding.cpu_allocation = "0..1",
))]
async fn given_backup_member_when_primary_restarts_should_preserve_membership(
@@ -1036,8 +1035,8 @@ async fn given_backup_member_when_primary_restarts_should_preserve_membership(
#[iggy_harness(cluster_nodes = 3, server(
heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
sharding.cpu_allocation = "0..1",
))]
async fn given_backup_member_when_host_crashes_should_expire_membership(harness: &mut TestHarness) {
@@ -1058,8 +1057,8 @@ async fn given_backup_member_when_host_crashes_should_expire_membership(harness:
#[iggy_harness(cluster_nodes = 3, server(
heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
sharding.cpu_allocation = "0..1",
))]
async fn given_primary_member_when_host_crashes_should_expire_membership(
diff --git a/core/integration/tests/data_integrity/verify_consumer_group_partition_assignment.rs b/core/integration/tests/data_integrity/verify_consumer_group_partition_assignment.rs
index c1459d06a..cb660f026 100644
--- a/core/integration/tests/data_integrity/verify_consumer_group_partition_assignment.rs
+++ b/core/integration/tests/data_integrity/verify_consumer_group_partition_assignment.rs
@@ -28,9 +28,12 @@
//! assignment. At the former 2s interval the 16-consumer spec sat 2.27s into a
//! 2.4s deadline over quic -- under 5% margin.
//!
-//! Connection eviction retains logical sessions. The liveness specs also set
-//! a short consumer-group session timeout so ordered Logout can remove stale
-//! memberships. Their stale clients send no further activity.
+//! `1.2 x heartbeat.interval` is also the session timeout, with or without
+//! heartbeat checks. The specs that wait for a closed member's session to end
+//! set a 7s interval and a 500ms `consumer_group.heartbeat_interval`, near the
+//! validator's minimum, and turn the checks off so an idle open member keeps
+//! its session. The two stale-client specs keep the checks on, so their
+//! silent sockets lose their sessions.
use iggy::prelude::*;
use integration::harness::wait_for_consumer_group_assignment;
@@ -50,6 +53,10 @@ const PARTITIONS_COUNT: u32 = 3;
/// `consumer_group.rebalancing_timeout`, which outlasts this bound, so the
/// deadline cannot complete the handoff for them.
const MEMBERS_CONVERGENCE_TIMEOUT: Duration = Duration::from_secs(15);
+/// Bounds the removal of members whose sockets stay open and silent. At the
+/// 7s heartbeat interval, the server stops renewing such a session after 8.4s
+/// and ends it about 8.4s later.
+const SILENT_MEMBERS_EXPIRY_TIMEOUT: Duration = Duration::from_secs(30);
/// Covers two passes of the default 1 s `reconcile_periodic_interval` with
/// margin, and stays far below the default `consumer_group.rebalancing_timeout`.
const LEAVE_OBSERVATION_WINDOW: Duration = Duration::from_secs(3);
@@ -87,9 +94,8 @@ async fn create_tcp_client(server_addr: &str) -> IggyClient {
#[iggy_harness(server(
consumer_group.rebalancing_timeout = "1s",
heartbeat.enabled = true,
- heartbeat.interval = "2s",
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn should_not_duplicate_partition_assignments_after_stale_client_cleanup(
harness: &TestHarness,
@@ -187,7 +193,7 @@ async fn should_not_duplicate_partition_assignments_after_stale_client_cleanup(
);
// Membership removal follows logical-session expiry, including after TCP eviction.
- await_members_count(&root_client, 0).await;
+ await_members_count_within(&root_client, 0, SILENT_MEMBERS_EXPIRY_TIMEOUT).await;
// 9. Now create 3 new clients and join same CG (simulating app restart after kill -9).
let client1 = create_tcp_client(&server_addr).await;
@@ -585,9 +591,9 @@ async fn should_not_lose_messages_with_concurrent_polls_during_partition_add(
#[iggy_harness(test_client_transport = [Tcp, WebSocket, Quic], server(
consumer_group.rebalancing_timeout = "1s",
- heartbeat.interval = "60s",
+ heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn should_handle_partition_add_then_consumer_disconnect_then_new_join(harness: &TestHarness) {
let root_client = harness.root_client().await.unwrap();
@@ -1896,9 +1902,8 @@ async fn should_timeout_revocation(harness: &TestHarness) {
#[iggy_harness(server(
consumer_group.rebalancing_timeout = "1s",
heartbeat.enabled = true,
- heartbeat.interval = "2s",
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn should_not_duplicate_after_reconnect_without_heartbeat(harness: &TestHarness) {
let server_addr = harness.server().raw_tcp_addr().expect("tcp addr");
@@ -1979,7 +1984,7 @@ async fn should_not_duplicate_after_reconnect_without_heartbeat(harness: &TestHa
}
}
- await_members_count(&root_client, 0).await;
+ await_members_count_within(&root_client, 0, SILENT_MEMBERS_EXPIRY_TIMEOUT).await;
// 5. Phase 2: 3 new clients join, poll concurrently — exactly 1 must get the message
let new_client1 = create_tcp_client(&server_addr).await;
@@ -2038,8 +2043,9 @@ async fn should_not_duplicate_after_reconnect_without_heartbeat(harness: &TestHa
test_client_transport = [Tcp, WebSocket, Quic],
server(
consumer_group.rebalancing_timeout = "1s",
- consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s"
+ heartbeat.enabled = false,
+ heartbeat.interval = "7s",
+ consumer_group.heartbeat_interval = "500ms"
)
)]
async fn should_not_duplicate_partition_assignments_after_client_reconnect(harness: &TestHarness) {
@@ -2199,13 +2205,21 @@ async fn should_not_duplicate_partition_assignments_after_client_reconnect(harne
}
async fn await_members_count(client: &IggyClient, expected: u32) -> ConsumerGroupDetails {
+ await_members_count_within(client, expected, MEMBERS_CONVERGENCE_TIMEOUT).await
+}
+
+async fn await_members_count_within(
+ client: &IggyClient,
+ expected: u32,
+ timeout: Duration,
+) -> ConsumerGroupDetails {
wait_for_consumer_group_assignment(
client,
&Identifier::named(STREAM_NAME).unwrap(),
&Identifier::named(TOPIC_NAME).unwrap(),
&Identifier::named(CONSUMER_GROUP_NAME).unwrap(),
expected,
- MEMBERS_CONVERGENCE_TIMEOUT,
+ timeout,
)
.await
}
@@ -2572,9 +2586,9 @@ async fn should_transfer_never_polled_partitions_immediately(harness: &TestHarne
#[iggy_harness(test_client_transport = [Tcp, WebSocket, Quic], server(
consumer_group.rebalancing_timeout = "1s",
- heartbeat.interval = "60s",
+ heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn should_rebalance_when_member_with_pending_revocation_leaves(harness: &TestHarness) {
let root_client = harness.root_client().await.unwrap();
@@ -2926,10 +2940,9 @@ async fn should_wait_for_manual_commit_before_completing_revocation(harness: &Te
#[iggy_harness(test_client_transport = [Tcp, WebSocket, Quic], server(
consumer_group.rebalancing_timeout = "1s",
- heartbeat.enabled = true,
- heartbeat.interval = "60s",
+ heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn should_redistribute_when_revocation_target_leaves(harness: &TestHarness) {
let root_client = harness.root_client().await.unwrap();
@@ -3210,10 +3223,9 @@ async fn should_not_assign_partition_to_wrong_member_after_slab_reuse(harness: &
}
#[iggy_harness(test_client_transport = [Tcp, WebSocket, Quic], server(
- heartbeat.enabled = true,
- heartbeat.interval = "60s",
+ heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn should_not_complete_other_members_revocations_on_leave(harness: &TestHarness) {
let root_client = harness.root_client().await.unwrap();
@@ -3698,10 +3710,9 @@ async fn should_not_starve_any_member_in_large_scale_rebalance(harness: &TestHar
#[iggy_harness(test_client_transport = [Tcp, WebSocket, Quic], server(
consumer_group.rebalancing_timeout = "1s",
- heartbeat.enabled = true,
- heartbeat.interval = "60s",
+ heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn should_maintain_balance_after_member_churn(harness: &TestHarness) {
let root_client = harness.root_client().await.unwrap();
diff --git a/core/integration/tests/sdk/consumer_group.rs b/core/integration/tests/sdk/consumer_group.rs
index f233560da..25dc105fd 100644
--- a/core/integration/tests/sdk/consumer_group.rs
+++ b/core/integration/tests/sdk/consumer_group.rs
@@ -36,8 +36,8 @@ const READ_TIMEOUT: Duration = Duration::from_secs(10);
// Pins a 60s server heartbeat because harness clients never ping on their own:
// the SDK pinger is spawned by `IggyClient::connect`, which the harness builder
-// does not call. At the shipped 30s interval an idle group member is reaped by
-// the server's verifier, and the failure surfaces as a short member count
+// does not call. With heartbeat checks on, the server logs out a group member
+// that stays silent too long, and the failure surfaces as a short member count
// instead of anything about the scenario under test.
#[iggy_harness(
test_client_transport = [Tcp, WebSocket, Quic],
diff --git a/core/integration/tests/sdk/consumer_group_membership.rs b/core/integration/tests/sdk/consumer_group_membership.rs
index 3eef81c91..dbf32ac57 100644
--- a/core/integration/tests/sdk/consumer_group_membership.rs
+++ b/core/integration/tests/sdk/consumer_group_membership.rs
@@ -48,10 +48,9 @@ const CONSUMER_GROUP_MEMBER_NOT_FOUND: u32 = 5006;
// Every spec here pins a 60s server heartbeat because harness clients never
// ping on their own: the SDK pinger is spawned by `IggyClient::connect`, which
-// the harness builder does not call. At the shipped 30s interval a group member
-// that idles through another client's setup is reaped by the server's verifier,
-// and the failure surfaces as a short member count instead of anything about
-// the scenario under test.
+// the harness builder does not call. With heartbeat checks on, the server logs
+// out a group member that stays silent too long, and the failure surfaces as a
+// short member count instead of anything about the scenario under test.
// A consumer-group member holding zero partitions has the same empty client-side
// assignment as a non-member; only membership tells them apart. When the group
diff --git a/core/integration/tests/server/cg.rs b/core/integration/tests/server/cg.rs
index 69a061006..05ed08ba1 100644
--- a/core/integration/tests/server/cg.rs
+++ b/core/integration/tests/server/cg.rs
@@ -26,12 +26,11 @@ use integration::iggy_harness;
// Consumer group scenarios do not support HTTP (stateful operations).
-// Every spec here pins a 60s server heartbeat because harness clients never
-// ping on their own: the SDK pinger is spawned by `IggyClient::connect`, which
-// the harness builder does not call. At the shipped 30s interval a group member
-// that idles through another client's setup is reaped by the server's verifier,
-// and the failure surfaces as a short member count instead of anything about
-// the scenario under test.
+// Harness clients never ping on their own: the SDK pinger is spawned by
+// `IggyClient::connect`, which the harness builder does not call. With
+// heartbeat checks on, the server logs out a group member that stays silent
+// too long, and the failure surfaces as a missing member or a reassigned
+// partition instead of anything about the scenario under test.
#[iggy_harness(
test_client_transport = [Tcp, WebSocket, Quic],
diff --git a/core/integration/tests/server/scenarios/stale_client_consumer_group_scenario.rs b/core/integration/tests/server/scenarios/stale_client_consumer_group_scenario.rs
index 9b83c0601..0812a4393 100644
--- a/core/integration/tests/server/scenarios/stale_client_consumer_group_scenario.rs
+++ b/core/integration/tests/server/scenarios/stale_client_consumer_group_scenario.rs
@@ -25,10 +25,12 @@ use std::sync::Arc;
use std::time::Duration;
use tokio::time::sleep;
-/// Bounds the wait for the heartbeat verifier to evict a client that stopped
-/// pinging. Generous relative to the 2.4s threshold it covers, because the
-/// eviction pass competes with the rest of the suite.
-const STALE_EVICTION_TIMEOUT: Duration = Duration::from_secs(20);
+/// Bounds the wait for a client that stopped sending to lose its group
+/// membership. At the specs' 7s heartbeat interval, the server stops renewing
+/// a silent session after 8.4s and ends it about 8.4s later. Generous relative
+/// to that, because the report and expiry passes compete with the rest of the
+/// suite.
+const STALE_EVICTION_TIMEOUT: Duration = Duration::from_secs(30);
const STALE_EVICTION_RETRY_INTERVAL: Duration = Duration::from_millis(200);
const STREAM_NAME: &str = "stale-test-stream";
@@ -46,9 +48,8 @@ enum Restart {
#[iggy_harness(cluster_nodes = 1, server(
heartbeat.enabled = true,
- heartbeat.interval = "2s",
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn given_client_disconnect_when_member_is_replaced_should_resume_consumption(
harness: &mut integration::harness::TestHarness,
@@ -58,9 +59,8 @@ async fn given_client_disconnect_when_member_is_replaced_should_resume_consumpti
#[iggy_harness(cluster_nodes = 1, server(
heartbeat.enabled = true,
- heartbeat.interval = "2s",
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn given_server_shutdown_when_member_is_replaced_should_resume_consumption(
harness: &mut integration::harness::TestHarness,
@@ -70,9 +70,8 @@ async fn given_server_shutdown_when_member_is_replaced_should_resume_consumption
#[iggy_harness(cluster_nodes = 1, server(
heartbeat.enabled = true,
- heartbeat.interval = "2s",
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn given_server_crash_when_member_is_replaced_should_resume_consumption(
harness: &mut integration::harness::TestHarness,
@@ -82,8 +81,8 @@ async fn given_server_crash_when_member_is_replaced_should_resume_consumption(
#[iggy_harness(cluster_nodes = 1, server(
heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn given_heartbeat_disabled_when_member_is_replaced_after_crash_should_resume_consumption(
harness: &mut integration::harness::TestHarness,
@@ -93,8 +92,8 @@ async fn given_heartbeat_disabled_when_member_is_replaced_after_crash_should_res
#[iggy_harness(cluster_nodes = 3, server(
heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn given_cluster_node_restart_when_member_is_replaced_should_resume_consumption(
harness: &mut integration::harness::TestHarness,
@@ -104,8 +103,8 @@ async fn given_cluster_node_restart_when_member_is_replaced_should_resume_consum
#[iggy_harness(cluster_nodes = 3, server(
heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn given_cluster_restart_when_member_is_replaced_should_resume_consumption(
harness: &mut integration::harness::TestHarness,
@@ -115,8 +114,8 @@ async fn given_cluster_restart_when_member_is_replaced_should_resume_consumption
#[iggy_harness(cluster_nodes = 3, server(
heartbeat.enabled = false,
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn given_live_member_when_backup_restarts_should_preserve_membership(
harness: &mut integration::harness::TestHarness,
@@ -393,9 +392,8 @@ async fn setup_resources(client: &IggyClient, durability: Durability) {
/// Tests that a stale client receives clean errors and can manually reconnect.
#[iggy_harness(server(
heartbeat.enabled = true,
- heartbeat.interval = "2s",
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn should_handle_stale_client_with_manual_reconnection(
harness: &integration::harness::TestHarness,
@@ -442,12 +440,12 @@ async fn should_handle_stale_client_with_manual_reconnection(
}
assert_eq!(messages_polled, 5);
- // Wait for the heartbeat verifier (2s interval, 2.4s threshold) to evict
- // the stale client, observed through `setup_client` rather than by polling
- // `stale_client` itself: a poll counts as activity and would keep resetting
- // the staleness the test is waiting for. That is also why the assertion
- // below gets only a couple of attempts -- each one refreshes liveness, so
- // retrying harder makes eviction less likely, not more.
+ // Wait for the server to end the stale client's session, observed through
+ // `setup_client` rather than by polling `stale_client` itself: a poll
+ // counts as activity and would keep resetting the staleness the test is
+ // waiting for. That is also why the assertion below gets only a couple of
+ // attempts -- each one refreshes liveness, so retrying harder makes
+ // eviction less likely, not more.
let deadline = tokio::time::Instant::now() + STALE_EVICTION_TIMEOUT;
loop {
let group = setup_client
@@ -539,9 +537,8 @@ async fn should_handle_stale_client_with_manual_reconnection(
/// Tests that IggyConsumer automatically recovers after stale disconnect.
#[iggy_harness(server(
heartbeat.enabled = true,
- heartbeat.interval = "2s",
+ heartbeat.interval = "7s",
consumer_group.heartbeat_interval = "500ms",
- consumer_group.session_timeout = "8s",
))]
async fn should_handle_stale_client_with_auto_reconnection(
harness: &integration::harness::TestHarness,
@@ -570,7 +567,7 @@ async fn should_handle_stale_client_with_auto_reconnection(
let mut messages_consumed = 0u32;
let start = std::time::Instant::now();
- let timeout = Duration::from_secs(15);
+ let timeout = STALE_EVICTION_TIMEOUT + Duration::from_secs(15);
while messages_consumed < TOTAL_MESSAGES && start.elapsed() < timeout {
let poll_result: Option<Result<ReceivedMessage, IggyError>> =
@@ -582,8 +579,10 @@ async fn should_handle_stale_client_with_auto_reconnection(
if let Some(Ok(_)) = poll_result {
messages_consumed += 1;
if messages_consumed == 5 {
- // Sleep longer than heartbeat threshold (2s * 1.2 = 2.4s) to trigger staleness
- sleep(Duration::from_millis(4000)).await;
+ // Stay silent until the verifier evicts the connection and
+ // the server ends the session, so the consumer must
+ // reconnect, log in again and rejoin its group.
+ sleep(STALE_EVICTION_TIMEOUT).await;
}
}
}
diff --git a/core/server/config.toml b/core/server/config.toml
index 4605e563f..b3485d122 100644
--- a/core/server/config.toml
+++ b/core/server/config.toml
@@ -18,19 +18,10 @@
# Root directory for server data. Environment override: IGGY_PATH.
path = "local_data"
-# Consumer group rebalancing and session liveness.
+# Consumer group rebalancing and session reports. [heartbeat] sets the session timeout.
[consumer_group]
# Maximum time a partition can remain in pending revocation before being force-transferred to the target member.
rebalancing_timeout = "30s"
-# The metadata primary removes members whose hosting server stops reporting their
-# connections for this long, including after a crash. An isolated live consumer
-# loses its session and must log in again. Each new primary grants a fresh timeout.
-# Expiry is always enabled. Incomplete client lists defer expiry across the cluster
-# until a full timeout has passed without an incomplete report.
-# Must exceed cluster.heartbeat_timeout when clustering is enabled, and
-# three heartbeat_interval periods plus two gather (3s) and send (100ms)
-# deadlines, allowing one missed report before expiry.
-session_timeout = "30s"
# Server-to-server session reports run even when client heartbeat checks are disabled.
# Must be nonzero. Use the same settings on all nodes.
heartbeat_interval = "5s"
@@ -326,21 +317,26 @@ interval = "1 m"
# Heartbeat configuration
[heartbeat]
-# Enables or disables the client heartbeat verification process. When
-# enabled, a connection that sends nothing (no request, no PING) for
-# 1.2 x interval has its session released so its consumer groups
-# rebalance off it. Only a connection that still holds a group
-# membership is evicted; one that holds none is left alone and is
-# reaped when its socket closes.
+# Enables or disables client heartbeat checks. When enabled, a connection
+# that sends nothing (no request, no PING) for 1.2 x interval stops renewing
+# its session, and the verifier evicts it if it holds a group membership.
+# When disabled, an open connection keeps its session alive however long it
+# stays silent.
enabled = true
-# Interval for expected client heartbeats. The Rust, Go, Python, Node and
-# async Java SDKs ping automatically every 5 s, well inside the resulting 36 s
-# staleness window, but only from a connected high-level client: the Rust and
-# async Java pingers are armed by connect(), so a session that logs in without
-# it never pings. The blocking Java and the C# SDK have no automatic heartbeat
-# at all, only a manual ping. Wherever nothing pings, an idle consumer-group
-# member is evicted, and only the application can keep it alive (ping) or
-# bring it back afterwards (reconnect).
+# Interval for expected client heartbeats. 1.2 x interval is the session
+# timeout: the metadata primary ends a session that no server reported for
+# that long, whether or not heartbeat checks are enabled. That covers a closed
+# connection, a crashed client and a lost node. With checks on, it also covers
+# a silent connection, which loses its session after about 2.4 x interval.
+# The consumer groups of an ended session rebalance, and its client must log
+# in again. Each new primary grants a fresh timeout. Incomplete client lists
+# defer expiry across the cluster until a full timeout has passed without an
+# incomplete report. 1.2 x interval must exceed cluster.heartbeat_timeout when
+# clustering is enabled, and three consumer_group.heartbeat_interval periods
+# plus two gather (3s) and send (100ms) deadlines, allowing one missed report.
+# The SDKs ping automatically every 5 s, but only from a connected high-level
+# client: the Rust and Java pingers start in connect(), so a session that logs
+# in without it never pings. Use the same settings on all nodes.
interval = "30 s"
# OpenTelemetry configuration
diff --git a/core/server/src/boot/mod.rs b/core/server/src/boot/mod.rs
index f193a3d0c..f6acb1087 100644
--- a/core/server/src/boot/mod.rs
+++ b/core/server/src/boot/mod.rs
@@ -867,19 +867,21 @@ async fn shard_main(
});
bus.track_background(reconciler_handle);
- // Per-shard heartbeat verifier: evicts connections that stop pinging,
- // releasing their consumer-group membership. Gated on config so a
- // deployment without heartbeats never reaps live sessions.
+ // Per-shard heartbeat verifier: evicts group-member connections that stop
+ // pinging. Lease expiry, not eviction, ends their sessions. Gated on
+ // config so a deployment without heartbeats never evicts a live client.
let heartbeat_stop_tx = if config.heartbeat.enabled {
let (hb_stop_tx, hb_stop_rx) = channel::<()>(1);
let hb_shard = Rc::clone(&shard);
let hb_sessions = Rc::clone(&sessions);
let hb_interval = config.heartbeat.interval.get_duration();
+ let hb_max_age = config.heartbeat.staleness_window();
let hb_handle = compio::runtime::spawn(async move {
crate::dispatch::session_ops::run_heartbeat_verifier(
hb_shard,
hb_sessions,
hb_interval,
+ hb_max_age,
hb_stop_rx,
)
.await;
@@ -1041,7 +1043,7 @@ async fn shard_main(
let (stop_tx, stop_rx) = channel(1);
let cleaner_shard = Rc::clone(&shard);
let interval = config.consumer_group.heartbeat_interval.get_duration();
- let timeout = config.consumer_group.session_timeout.get_duration();
+ let timeout = config.heartbeat.staleness_window();
let system_path = config.get_system_path();
let handle = compio::runtime::spawn(async move {
crate::consumer_group::liveness::run(
diff --git a/core/server/src/dispatch/host.rs b/core/server/src/dispatch/host.rs
index 64f3cec3c..859a2362d 100644
--- a/core/server/src/dispatch/host.rs
+++ b/core/server/src/dispatch/host.rs
@@ -183,10 +183,7 @@ where
shard,
submit,
&self.consumer_group_liveness,
- self.server_config
- .consumer_group
- .session_timeout
- .get_duration(),
+ self.server_config.heartbeat.staleness_window(),
&self.completion_relays,
);
}
@@ -201,10 +198,7 @@ where
self.sessions
.borrow()
.iter_consumer_sessions(if self.server_config.heartbeat.enabled {
- self.server_config
- .consumer_group
- .session_timeout
- .get_duration()
+ self.server_config.heartbeat.staleness_window()
} else {
Duration::MAX
})
diff --git a/core/server/src/dispatch/session_ops.rs b/core/server/src/dispatch/session_ops.rs
index 469298a0a..a5e3f005e 100644
--- a/core/server/src/dispatch/session_ops.rs
+++ b/core/server/src/dispatch/session_ops.rs
@@ -363,16 +363,18 @@ const fn eviction_reason_for(error: &LoginRegisterError) -> EvictionReason {
}
}
-/// Per-shard heartbeat verifier: evict connections that have not pinged within
-/// `1.2 x interval`. Mirrors the legacy `verify_heartbeats` periodic task.
-/// Eviction removes the connection binding and sends `Eviction(StaleClient)`.
-/// The shared logical session and its group membership remain until committed
+/// Per-shard heartbeat verifier: every `interval`, evict group-member
+/// connections that sent nothing for `max_age`, the heartbeat staleness
+/// window. Mirrors the legacy `verify_heartbeats` periodic task. Eviction
+/// removes the connection binding and sends `Eviction(StaleClient)`. The
+/// shared logical session and its group membership remain until committed
/// lease expiry or explicit logout.
#[allow(clippy::future_not_send)]
pub async fn run_heartbeat_verifier<B, MJ, S, SB>(
shard: Rc<ShellShard<B, MJ, S, SB>>,
sessions: Rc<RefCell<SessionManager>>,
interval: std::time::Duration,
+ max_age: std::time::Duration,
stop_rx: shard::Receiver<()>,
) where
B: ShellBus,
@@ -381,9 +383,6 @@ pub async fn run_heartbeat_verifier<B, MJ, S, SB>(
S: 'static,
SB: SuperblockStore + 'static,
{
- // Legacy `MAX_THRESHOLD`: a client is stale once it misses 1.2 intervals.
- // Integer 6/5 rather than `mul_f64`, which panics on an absurd interval.
- let max_age = interval.saturating_mul(6) / 5;
loop {
// `Ok(_)`: stop signalled -> exit. `Err(_)`: interval elapsed -> pass.
// Waiting on the stop channel rather than sleeping past it keeps this
diff --git a/foreign/csharp/Iggy_SDK.Tests.Integration/Fixtures/IggyServerFixture.cs b/foreign/csharp/Iggy_SDK.Tests.Integration/Fixtures/IggyServerFixture.cs
index 158c1b966..ac28ebb1a 100644
--- a/foreign/csharp/Iggy_SDK.Tests.Integration/Fixtures/IggyServerFixture.cs
+++ b/foreign/csharp/Iggy_SDK.Tests.Integration/Fixtures/IggyServerFixture.cs
@@ -57,13 +57,20 @@ public class IggyServerFixture : IAsyncInitializer, IAsyncDisposable
protected bool EnabledServerTraceLogs => true;
/// <summary>
- /// Server-side heartbeat interval. Short so a client that stops pinging is evicted within a few seconds
- /// instead of the default five. Clients from <see cref="CreateClient" /> ping at half this interval;
- /// any client built by hand must set <see cref="IggyClientConfigurator.HeartbeatInterval" /> below it or
- /// be evicted once idle past 1.2 intervals.
+ /// Server-side heartbeat interval. 1.2 intervals is the session timeout: a client that stops pinging is
+ /// evicted once idle past it and loses its session about one timeout later. 13 s is the shortest
+ /// whole-second interval whose timeout exceeds the cluster's 15 s heartbeat timeout, as the server
+ /// requires. Clients from <see cref="CreateClient" /> ping at half this interval; any client built by
+ /// hand must set <see cref="IggyClientConfigurator.HeartbeatInterval" /> below 1.2 intervals or be
+ /// evicted once idle past them.
/// </summary>
- public static readonly TimeSpan ServerHeartbeatInterval = TimeSpan.FromSeconds(2);
- public static readonly TimeSpan SessionTimeout = TimeSpan.FromSeconds(30);
+ public static readonly TimeSpan ServerHeartbeatInterval = TimeSpan.FromSeconds(13);
+
+ /// <summary>
+ /// How often every node reports its sessions to the metadata primary. The server accepts the short
+ /// heartbeat interval above only with reports this frequent.
+ /// </summary>
+ public static readonly TimeSpan SessionReportInterval = TimeSpan.FromMilliseconds(500);
/// <summary>
/// Extra environment variables for every node, layered over the cluster's base configuration.
@@ -74,7 +81,7 @@ public class IggyServerFixture : IAsyncInitializer, IAsyncDisposable
{
{ "IGGY_HEARTBEAT_ENABLED", "true" },
{ "IGGY_HEARTBEAT_INTERVAL", $"{ServerHeartbeatInterval.TotalSeconds}s" },
- { "IGGY_CONSUMER_GROUP_SESSION_TIMEOUT", $"{SessionTimeout.TotalSeconds}s" }
+ { "IGGY_CONSUMER_GROUP_HEARTBEAT_INTERVAL", $"{SessionReportInterval.TotalMilliseconds}ms" }
};
/// <summary>
diff --git a/foreign/csharp/Iggy_SDK.Tests.Integration/HeartbeatTests.cs b/foreign/csharp/Iggy_SDK.Tests.Integration/HeartbeatTests.cs
index 52ca8aaf6..e2e444a53 100644
--- a/foreign/csharp/Iggy_SDK.Tests.Integration/HeartbeatTests.cs
+++ b/foreign/csharp/Iggy_SDK.Tests.Integration/HeartbeatTests.cs
@@ -34,9 +34,9 @@ public class HeartbeatTests
private const string TopicName = "heartbeat-topic";
private const string GroupName = "heartbeat-group";
- // Transport eviction removes the binding; committed lease expiry removes membership.
- private static readonly TimeSpan IdleFor = IggyServerFixture.SessionTimeout +
- IggyServerFixture.ServerHeartbeatInterval * 3;
+ // Transport eviction removes the binding; committed lease expiry removes membership. A silent session stops
+ // renewing after 1.2 intervals and ends 1.2 intervals later. The rest covers the report and expiry passes.
+ private static readonly TimeSpan IdleFor = IggyServerFixture.ServerHeartbeatInterval * 3;
[ClassDataSource<IggyServerFixture>(Shared = SharedType.PerAssembly)]
public required IggyServerFixture Fixture { get; init; }
diff --git a/foreign/node/README.md b/foreign/node/README.md
index 172753a7d..04037815e 100644
--- a/foreign/node/README.md
+++ b/foreign/node/README.md
@@ -89,12 +89,13 @@ The client pings every `heartbeatInterval` milliseconds, 5000 by default, which
keeps an idle session alive when the server's `[heartbeat]` eviction is enabled.
`heartbeatInterval` also accepts a duration expression such as `"10s"` or
`"1h 30m"`, like the Rust SDK.
-With the default heartbeat settings, a group member becomes eligible for
-eviction after 36 s of silence (1.2 x the 30 s interval); the verifier checks
-once per interval. Raising the client interval past that window, or setting it
-to 0 to disable client heartbeats, exposes an idle consumer-group member to
-eviction; a connection holding no group membership is left alone. Any other
-unusable value is rejected instead of silently disabling the heartbeat.
+With the default heartbeat settings, a client that sends nothing for 36 s
+(1.2 x the 30 s interval) stops renewing its session, and the server ends the
+session about 36 s later. The verifier checks once per interval and also evicts
+the connection of a consumer-group member that is silent past 36 s. Raising the
+client interval past that window, or setting it to 0 to disable client
+heartbeats, lets an idle session expire. Any other unusable value is rejected
+instead of silently disabling the heartbeat.
`sendBinaryRequest(code, payload)` sends an arbitrary command code. Known replicated commands use their registered operation, while unknown codes reach the server as non-replicated requests and are rejected by servers that do not register them.