-
Notifications
You must be signed in to change notification settings - Fork 59
Populate the DRIVER_CONFIG report - phase 2 #997
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
base: master
Are you sure you want to change the base?
Changes from all commits
81c8f5e
be49969
2065a4e
a713dd2
b7d1114
cb06e6b
44b5e5f
e8d73ae
fa1c0bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1468,7 +1468,10 @@ def __init__(self, | |
|
|
||
| self.ssl_options = ssl_options | ||
| self.ssl_context = ssl_context | ||
| self.sockopts = sockopts | ||
| # Materialized once: these are applied to every socket the cluster opens | ||
| # and are read again to build the configuration report, so a one-shot | ||
| # iterable would leave whichever consumer ran second with nothing at all. | ||
| self.sockopts = list(sockopts) if sockopts is not None else None | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Question] 🔵 What does the |
||
| self.cql_version = cql_version | ||
| self.max_schema_agreement_wait = max_schema_agreement_wait | ||
| self.control_connection_timeout = control_connection_timeout | ||
|
|
@@ -1520,7 +1523,7 @@ def __init__(self, | |
| # Built whatever the flag says, so that the flag is the only thing that | ||
| # decides whether a connection reports: see _make_connection_kwargs. The | ||
| # reporter holds no state, so an unused one costs nothing. | ||
| self._driver_config_reporter = DriverConfigReporter() | ||
| self._driver_config_reporter = DriverConfigReporter(self) | ||
|
|
||
| self.control_connection = ControlConnection( | ||
| self, self.control_connection_timeout, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -846,9 +846,37 @@ class Connection(object): | |
|
|
||
| # If the number of orphaned streams reaches this threshold, this connection | ||
| # will become marked and will be replaced with a new connection by the | ||
| # owning pool (currently, only HostConnection supports this) | ||
| # owning pool (currently, only HostConnection supports this). The default | ||
| # for this class's max_in_flight; a connection derives its own in __init__. | ||
| orphaned_threshold = 3 * max_in_flight // 4 | ||
|
|
||
| @staticmethod | ||
| def max_request_id_for(max_in_flight): | ||
| """ | ||
| The highest request id a connection with this limit will hand out. | ||
|
|
||
| Request ids run from zero to this inclusive, and borrow_connection | ||
| admits a request only while in_flight is below it. Capped at the CQL | ||
| stream id range, which is all the protocol can address however high | ||
| max_in_flight is set. | ||
| """ | ||
| return min(max_in_flight - 1, (2 ** 15) - 1) | ||
|
|
||
| @staticmethod | ||
| def orphaned_threshold_for(max_in_flight): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Major] 🟠 Not capped the way The report then prints |
||
| """ | ||
| The orphaned stream count at which a connection with this limit is | ||
| marked for replacement. | ||
| """ | ||
| return 3 * max_in_flight // 4 | ||
|
|
||
| # Both limits are derived, and both are asked for rather than stored on the | ||
| # class, because max_in_flight is tuned at runtime -- assigned on the class, | ||
| # or patched in a test -- and a value derived once does not follow it. A | ||
| # connection derives both in __init__ from the limit in force when it is | ||
| # built, and the configuration report, which has to describe them before any | ||
| # connection exists, asks with the class's current limit. | ||
|
|
||
| is_defunct = False | ||
| is_closed = False | ||
| lock = None | ||
|
|
@@ -944,7 +972,9 @@ def __init__(self, host='127.0.0.1', port=9042, authenticator=None, | |
| if not self.ssl_context and self.ssl_options: | ||
| self.ssl_context = self._build_ssl_context_from_options() | ||
|
|
||
| self.max_request_id = min(self.max_in_flight - 1, (2 ** 15) - 1) | ||
| self.max_request_id = self.max_request_id_for(self.max_in_flight) | ||
| self.orphaned_threshold = self.orphaned_threshold_for(self.max_in_flight) | ||
|
|
||
| # Don't fill the deque with 2**15 items right away. Start with some and add | ||
| # more if needed. | ||
| initial_size = min(300, self.max_in_flight) | ||
|
|
@@ -1563,7 +1593,13 @@ def _handle_options_response(self, options_response): | |
| # only the control connection reports it. A reporter left as None means | ||
| # the cluster has configuration reporting disabled. | ||
| if self.is_control_connection and self._driver_config_reporter is not None: | ||
| self._driver_config_reporter.add_startup_options(options) | ||
| # Whether this is a ScyllaDB node is already known: the features | ||
| # above were parsed from the SUPPORTED response, and sharding info | ||
| # is what the driver itself keys ScyllaDB-only behaviour off (see | ||
| # ControlConnection._try_connect), so the report describes what the | ||
| # driver will actually do rather than only what it was configured to. | ||
| self._driver_config_reporter.add_startup_options( | ||
| options, is_scylla=self.features.sharding_info is not None) | ||
|
|
||
| if self.cql_version: | ||
| if self.cql_version not in supported_cql_versions: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Minor] 🟡 The entry describes the
__init_subclass__version rather than what shipped: both limits are derived in__init__(connection.py:975-976), not in the class body; a subclass that sets either in its class body has it overwritten, so "A subclass that sets either itself keeps it" is not true; andmax_request_idis still an instance attribute, so it has not moved to the class --orphaned_thresholdis the one that gained a classmethod for the report to read.To be clear, the code is what I asked for last round. It's the entry that needs to follow it.