clickhouse-native 0.10.0-x86_64-linux-gnu → 0.11.0-x86_64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/clickhouse_native/3.3/clickhouse_native.so +0 -0
- data/lib/clickhouse_native/3.4/clickhouse_native.so +0 -0
- data/lib/clickhouse_native/4.0/clickhouse_native.so +0 -0
- data/lib/clickhouse_native/client.rb +1 -1
- data/lib/clickhouse_native/pool.rb +22 -31
- data/lib/clickhouse_native/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d6186352daf6afcb3b55c2b1839055b8d4bc1d414067f6c52bf6353cfce221d5
|
|
4
|
+
data.tar.gz: e5b25c22dc3d3e66987a3d5c03bf1e91829507b5cc6c31522e96adaa6a820554
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b37f44e1705a8a5fef335e8be1b7b493e1b5622721b4bfa9d13133b7ab14d44d3fab4ee0b3128bfdfc0c809544804b72678bbe4491d206233fda75443777ca14
|
|
7
|
+
data.tar.gz: 97605a75f445c3b74360aec37c247cd0219eb741894e4623504481afe2ae7deabe63c9aa3638377e68f07ddb562e42c4c504c9ad1a6274aa3959d7315392ba90
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -8,16 +8,17 @@ module ClickhouseNative
|
|
|
8
8
|
|
|
9
9
|
def initialize(host:, port:, database: "default", user: "default", password: "",
|
|
10
10
|
compression: :none, logger: nil, settings: {},
|
|
11
|
-
pool_size: 5, pool_timeout: 5
|
|
11
|
+
pool_size: 5, pool_timeout: 5,
|
|
12
|
+
ping_before_query: true, tcp_keepalive: true, retry_timeout: 1)
|
|
12
13
|
@host = host
|
|
13
14
|
@port = port
|
|
14
15
|
@database = database
|
|
15
|
-
client_kwargs = {
|
|
16
|
-
|
|
16
|
+
client_kwargs = {
|
|
17
|
+
host:, port:, database:, user:, password:, compression:, logger:, settings:,
|
|
18
|
+
ping_before_query:, tcp_keepalive:, retry_timeout:
|
|
19
|
+
}
|
|
17
20
|
@pool = ConnectionPool.new(size: pool_size, timeout: pool_timeout) do
|
|
18
|
-
|
|
19
|
-
client.execute(@set_sql) if @set_sql
|
|
20
|
-
client
|
|
21
|
+
Client.new(**client_kwargs)
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
24
|
|
|
@@ -25,18 +26,24 @@ module ClickhouseNative
|
|
|
25
26
|
# path leaves the socket in an unknown state. The C++ binding issues
|
|
26
27
|
# ResetConnection, but a subsequent send can still surface buffered
|
|
27
28
|
# protocol errors from the prior aborted operation — those get
|
|
28
|
-
# attributed to whatever SQL we tried next
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
# debugging that.
|
|
29
|
+
# attributed to whatever SQL we tried next, producing misleading log
|
|
30
|
+
# lines and re-raises in unrelated code. A fresh socket + handshake is
|
|
31
|
+
# cheap relative to debugging that.
|
|
32
32
|
#
|
|
33
33
|
# ConnectionError gets one automatic retry: pooled connections that
|
|
34
34
|
# have been idle long enough for the server / an LB to FIN them
|
|
35
|
-
# surface as "closed" on the very next recv (errno
|
|
36
|
-
# "closed: Success"
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
35
|
+
# surface as "closed" on the very next recv (errno is whatever stale
|
|
36
|
+
# value was left in the thread — "closed: Success", "closed: Operation
|
|
37
|
+
# now in progress", etc. all mean the same recv()==0). Discarding and
|
|
38
|
+
# re-checking out lands a fresh socket and the operation succeeds. The
|
|
39
|
+
# retry only triggers when the dead-connection error fired before any
|
|
40
|
+
# data was sent, so write operations don't risk double-execution.
|
|
41
|
+
#
|
|
42
|
+
# This is the backstop: with ping_before_query on (the default) the
|
|
43
|
+
# driver already pings and transparently reconnects a dead socket
|
|
44
|
+
# before running the query, so most stale connections never surface as
|
|
45
|
+
# a ConnectionError here at all. This retry still covers the residual
|
|
46
|
+
# race (socket dies between the ping and the query).
|
|
40
47
|
def with
|
|
41
48
|
attempts = 0
|
|
42
49
|
begin
|
|
@@ -84,21 +91,5 @@ module ClickhouseNative
|
|
|
84
91
|
def describe_table(table, db_name: nil)
|
|
85
92
|
with { |c| c.describe_table(table, db_name:) }
|
|
86
93
|
end
|
|
87
|
-
|
|
88
|
-
private
|
|
89
|
-
|
|
90
|
-
# Render a `SET key1 = val1, key2 = val2` statement once at pool setup
|
|
91
|
-
# so every checked-out connection starts with the same session
|
|
92
|
-
# settings. Matches how the HTTP driver injected global_params per
|
|
93
|
-
# request. Values: Integer / Float render bare; anything else is
|
|
94
|
-
# quoted as a SQL string literal.
|
|
95
|
-
def settings_sql(settings)
|
|
96
|
-
return nil if settings.nil? || settings.empty?
|
|
97
|
-
parts = settings.map do |k, v|
|
|
98
|
-
literal = v.is_a?(Numeric) ? v.to_s : "'#{v.to_s.gsub("'", "''")}'"
|
|
99
|
-
"#{k} = #{literal}"
|
|
100
|
-
end
|
|
101
|
-
"SET #{parts.join(', ')}"
|
|
102
|
-
end
|
|
103
94
|
end
|
|
104
95
|
end
|