clickhouse-native 0.11.0-x86_64-linux-gnu → 0.12.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc6d857ba9d4764d568add9796d0b072d5522d3d5b1602ac431482915c0dd820
|
|
4
|
+
data.tar.gz: 31dcfe4e8e7402fad3d612f72471903f19e673a4b202219324a2775f8960cfd3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc29fcea233bd492d7623986476ac70ad2da0925b4e2e55a8bbd3f4fd6f21623ab45145034d68ac46c17046074cf7ab602c5acce183ed86848736805eb9aa914
|
|
7
|
+
data.tar.gz: d02c3621e6fea634f9f9399a8aabea15c58051f3d4bcb49222a3b914ded50a5f1ec5a673990d29e22b14181cf78f5ff654c86443790fc169fe1e30cfe5390450
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -22,8 +22,8 @@ module ClickhouseNative
|
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# On
|
|
26
|
-
#
|
|
25
|
+
# On an aborted operation, discard the client rather than reuse it: the
|
|
26
|
+
# socket is left in an unknown state. The C++ binding issues
|
|
27
27
|
# ResetConnection, but a subsequent send can still surface buffered
|
|
28
28
|
# protocol errors from the prior aborted operation — those get
|
|
29
29
|
# attributed to whatever SQL we tried next, producing misleading log
|
|
@@ -44,15 +44,18 @@ module ClickhouseNative
|
|
|
44
44
|
# before running the query, so most stale connections never surface as
|
|
45
45
|
# a ConnectionError here at all. This retry still covers the residual
|
|
46
46
|
# race (socket dies between the ping and the query).
|
|
47
|
+
#
|
|
48
|
+
# A bare `rescue` is not enough to spot an abandoned query. Timeout and
|
|
49
|
+
# Sidekiq shutdown raise off Exception rather than StandardError, and
|
|
50
|
+
# Thread#kill raises nothing at all — Parallel.in_threads kills every
|
|
51
|
+
# sibling worker the moment one of them fails. Miss those and the
|
|
52
|
+
# connection goes back in with the server still streaming a response at
|
|
53
|
+
# it; the next checkout reads that leftover as its own, which surfaces
|
|
54
|
+
# as a bogus packet type far from here.
|
|
47
55
|
def with
|
|
48
56
|
attempts = 0
|
|
49
57
|
begin
|
|
50
|
-
@pool.with
|
|
51
|
-
yield client
|
|
52
|
-
rescue
|
|
53
|
-
@pool.discard_current_connection(&:close)
|
|
54
|
-
raise
|
|
55
|
-
end
|
|
58
|
+
@pool.with { |client| discard_unless_clean { yield client } }
|
|
56
59
|
rescue ConnectionError
|
|
57
60
|
attempts += 1
|
|
58
61
|
retry if attempts == 1
|
|
@@ -91,5 +94,30 @@ module ClickhouseNative
|
|
|
91
94
|
def describe_table(table, db_name: nil)
|
|
92
95
|
with { |c| c.describe_table(table, db_name:) }
|
|
93
96
|
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
# Keep the client only when the block either finished or left of its own
|
|
101
|
+
# accord. A `break` out of a streaming read is deliberate, and the binding
|
|
102
|
+
# has already reconnected the client on its way out (query_each resets the
|
|
103
|
+
# connection before rb_jump_tag), so it is good to reuse — discarding would
|
|
104
|
+
# buy a second connect on top of the one already paid. An exception is an
|
|
105
|
+
# abort, and so is Thread#kill: it raises nothing, so no rescue ever sees
|
|
106
|
+
# it, and its only trace is an "aborting" thread while ensure runs.
|
|
107
|
+
def discard_unless_clean
|
|
108
|
+
finished = false
|
|
109
|
+
begin
|
|
110
|
+
result = yield
|
|
111
|
+
finished = true
|
|
112
|
+
result
|
|
113
|
+
rescue Exception # rubocop:disable Lint/RescueException
|
|
114
|
+
@pool.discard_current_connection(&:close)
|
|
115
|
+
raise
|
|
116
|
+
ensure
|
|
117
|
+
if !finished && Thread.current.status == "aborting"
|
|
118
|
+
@pool.discard_current_connection(&:close)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
94
122
|
end
|
|
95
123
|
end
|