Skip to content

Connection pool size configuration #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 28, 2025

Conversation

muzarski
Copy link
Contributor

@muzarski muzarski commented Apr 23, 2025

Fixes: #240
Ref: #132

Depends on: #280 (I need metrics support to implement one integration test). <- already on master

Implements:

  • cass_cluster_set_core_connections_per_host
  • cass_cluster_set_core_connections_per_shard (as an extension to cpp-driver API)

Integration tests

Existing ErrorsConnectionTimeouts metrics test

CASSANDRA_INTEGRATION_TEST_F(MetricsTests, ErrorsConnectionTimeouts) {
  CHECK_FAILURE;

  Session session =
      default_cluster().with_core_connections_per_host(2).with_connect_timeout(1).connect(
          "", false); // Quick connection timeout and no assertion

  CassMetrics metrics = session.metrics();
  EXPECT_GE(2u, metrics.errors.connection_timeouts);
}

I don't know who implemented this test, but (IMO) it's just wrong. So my understanding of intentions is:

  1. we set 2 connections per host
  2. we set low connect timeout
  3. we expect at least 2 connection timeouts registered in the metrics

If those were the intentions, the EXPECT_GE(2u, metrics.errors.connection_timeouts); is wrong - it should be the other way around. Currently it expects 2 >= connection_timeouts.

Ok, so let's say we fix it. It still won't work with rust driver. The Session object will not even be built - we will fail to open a control connection (because of timeouts) and fail to fetch the metadata. In particular, we won't even be able to call Session::get_metrics() - the cass_session_get_metrics will return early with some log error message.

Thus, I'm not enabling this test.

Fun fact: in my local setup, this test passes. Even though, the connect timeout is low, it is not triggered. And then, the metrics.errors.connection_timeouts is 0 - this means that aforementioned assertion passes as well.

My new StatsShardConnections metrics test

I implemented simple test where we configure a pool size to be 2 connections per shard (cass_cluster_set_core_connections_per_shard). It checks whether all connections are registered in the metrics. The expected value is at least nr_hosts * nr_shards * 2.

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • PR description sums up the changes and reasons why they should be introduced.
  • [ ] I have implemented Rust unit tests for the features/changes introduced.
  • I have enabled appropriate tests in .github/workflows/build.yml in gtest_filter.
  • I have enabled appropriate tests in .github/workflows/cassandra.yml in gtest_filter.

@muzarski muzarski self-assigned this Apr 23, 2025
@muzarski muzarski added the P1 P1 priority item - very important label Apr 23, 2025
@muzarski muzarski added this to the 0.5 milestone Apr 23, 2025
@muzarski muzarski marked this pull request as draft April 23, 2025 11:57
@muzarski muzarski force-pushed the core-connections-per-host-shard branch from 4b4ec8e to f70522d Compare April 24, 2025 12:28
@muzarski muzarski requested review from wprzytula and Lorak-mmk and removed request for wprzytula April 24, 2025 13:23
@muzarski muzarski marked this pull request as ready for review April 24, 2025 13:25
@muzarski muzarski force-pushed the core-connections-per-host-shard branch from f70522d to 4b924ae Compare April 28, 2025 11:09
@muzarski
Copy link
Contributor Author

Rebased on master

I haven't set the default value yet. This will be done once
cass_cluster_set_core_connections_per_shard is introduced and implemented (later in this PR).
This will serve as an extension to cpp API.
The default connection pool size is 1 per shard.
This tests `cass_cluster_set_core_connections_per_shard` as well as
`cass_session_get_metrics`.
@muzarski muzarski force-pushed the core-connections-per-host-shard branch from 4b924ae to c538885 Compare April 28, 2025 13:31
@muzarski muzarski merged commit 748d53f into scylladb:master Apr 28, 2025
12 checks passed
@muzarski muzarski deleted the core-connections-per-host-shard branch April 28, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 P1 priority item - very important
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement cass_cluster_set_core_connections_per_host
3 participants