Skip to content

Commit 2d0509d

Browse files
committed
fix(kernel): normalize zero pool maxsize
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
1 parent 510bf30 commit 2d0509d

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

CONNECTION_PARAMETERS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ to change without notice.
102102
| ------------------------------------ | ----------- | :----: | :----: | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
103103
| `_socket_timeout` | `float` (s) ||| `900` (Thrift); `120` (kernel) | Thrift: socket send/recv/connect timeout. Kernel: total HTTP request deadline from connect through response-body completion. A positive value is forwarded; unset or `0` selects the kernel's 120s default. On the kernel path, `0` is neither unlimited nor an immediate timeout. |
104104
| `_pool_connections` | `int` || ⚠️ | `10` | Number of urllib3 connection pools. Configures the connector's shared Python HTTP client; the kernel's query transport is its own Rust stack. |
105-
| `_pool_maxsize` | `int` || ⚠️ | `20` (Thrift); `100` (kernel when unset) | Max idle connections retained per host. An explicit value always configures the shared Python HTTP client and also configures the kernel's Rust HTTP pool with kernel ≥ 1.1.0. |
105+
| `_pool_maxsize` | `int` || ⚠️ | `20` (Thrift); `100` (kernel when unset) | Max idle connections retained per host. A positive value always configures the shared Python HTTP client and also configures the kernel's Rust HTTP pool with kernel ≥ 1.1.0. Unset or `0` keeps each client's default. |
106106
| `_proxy_auth_method` | `str` || ⚠️ | `None` | `basic` or `negotiate` (Kerberos). Applies to the shared Python HTTP client; not threaded to the kernel query transport. See [`docs/proxy.md`](docs/proxy.md). |
107107
| `_retry_stop_after_attempts_count` | `int` ||| `30` | Max attempts in a retry sequence. Bounded to `[1, 60]` on Thrift; forwarded to the kernel's retry policy. |
108108
| `_retry_stop_after_attempts_duration`| `float` (s) ||| `900` | Max total wall-clock seconds spent retrying. Forwarded to the kernel. |
@@ -204,7 +204,8 @@ None — the kernel's parameter surface is currently a subset of Thrift's.
204204

205205
- **Connection pooling / proxy**: `_pool_connections` and `_proxy_auth_method`
206206
configure only the shared Python HTTP client. `_pool_maxsize` also configures
207-
the kernel's Rust HTTP pool when explicitly set and using kernel ≥ 1.1.0.
207+
the kernel's Rust HTTP pool when positive and using kernel ≥ 1.1.0. A value of
208+
`0` is treated as unset: the shared client keeps 20 and the kernel keeps 100.
208209
- **`use_inline_params`** renders parameters inline on Thrift; the kernel uses
209210
native parameter binding.
210211

src/databricks/sql/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def _create_backend(
313313
auth_options=kernel_auth_options,
314314
retry_options=kernel_retry_options,
315315
request_timeout_secs=kwargs.get("_socket_timeout"),
316-
max_connections=kwargs.get("_pool_maxsize"),
316+
max_connections=kwargs.get("_pool_maxsize") or None,
317317
telemetry_options=kernel_telemetry_options,
318318
)
319319

tests/unit/test_session.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,20 @@ def test_retry_and_socket_timeout_threaded_into_kernel_client(self):
480480
finally:
481481
conn.close()
482482

483+
conn = databricks.sql.connect(
484+
server_hostname="foo",
485+
http_path="/sql/1.0/warehouses/abc",
486+
use_kernel=True,
487+
access_token="dapi-xyz",
488+
enable_telemetry=False,
489+
_pool_maxsize=0,
490+
)
491+
try:
492+
_, kwargs = mock_kernel_client.call_args
493+
assert kwargs["max_connections"] is None
494+
finally:
495+
conn.close()
496+
483497
def test_azure_sp_m2m_kwargs_threaded_into_kernel_auth_options(self):
484498
# The Azure SP credentials a user passes to connect() must reach the
485499
# kernel auth bridge via auth_options; without this threading the

0 commit comments

Comments
 (0)