Skip to content

Bug with alt_hosts from kwargs in first Connection in Client.__init__ #481

@ryandrey

Description

@ryandrey

Describe the bug
During Client initialization with round_robin=True and alternative hosts first Connection in deque initialized with alt_hosts in kwargs

To Reproduce

CREATE TABLE test
(
    project_id UInt16,
    properties JSON,
    timestamp  DateTime64(6, 'UTC')
) ENGINE = Memory;


INSERT INTO test(project_id, properties, timestamp)
VALUES (1, '{
  "a": 22,
  "b": "lorem"
}', now64());

import clickhouse_driver

ch_client = clickhouse_driver.Client(host="localhost",
                                     round_robin=True,
                                     alt_hosts='localhost,localhost'
)

result = ch_client.execute("SELECT * FROM test;")

Expected behavior
I expect that all Connections in self.connections have only 1 host in self.hosts.
You should check round_robin=True and alt_hosts before self.connections = deque([Connection(*args, **kwargs)]) and do kwargs.pop('alt_hosts').

Versions

Version of package: 0.2.9
ClickHouse server version: 24.9.2.42
Python version: 3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions