google-cloud-spanner 2.18.0 → 2.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/google/cloud/spanner/pool.rb +14 -10
- data/lib/google/cloud/spanner/transaction.rb +6 -14
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86e6ca163f96c37fa118d05ecf481289318c707f1de83ffb401c20b40afacb69
|
4
|
+
data.tar.gz: 12cbaad3945956e2da31862d23d0ef66658539fc30daee432879650d2ab3d028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b866a7a87beb50165b5b1593a4e92a1e0a4684f7a5e7210647aae4ecbe05fcf9f61b1309b00d37deb94e592bc98e541ea1f1104e411a32f6ed9bc4bbde1ee624
|
7
|
+
data.tar.gz: d8c40babae83b334f95e15ea242f7b1271ecf510cd19722619e759b2a3082df04400b1fc3e78f572a0708ecca76ee68a71192fab92a425d1c27f3c8d58a58aca
|
data/CHANGELOG.md
CHANGED
@@ -29,7 +29,11 @@ module Google
|
|
29
29
|
# {Google::Cloud::Spanner::Session} instances.
|
30
30
|
#
|
31
31
|
class Pool
|
32
|
+
# @return [Array<Session>] A stack of `Session` objects.
|
32
33
|
attr_accessor :sessions_available
|
34
|
+
|
35
|
+
# @return [Hash{String => Session}] A hash with session_id as keys,
|
36
|
+
# and `Session` objects as values.
|
33
37
|
attr_accessor :sessions_in_use
|
34
38
|
|
35
39
|
def initialize client, min: 10, max: 100, keepalive: 1800,
|
@@ -65,10 +69,10 @@ module Google
|
|
65
69
|
|
66
70
|
# Use LIFO to ensure sessions are used from backend caches, which
|
67
71
|
# will reduce the read / write latencies on user requests.
|
68
|
-
|
69
|
-
if
|
70
|
-
sessions_in_use
|
71
|
-
return
|
72
|
+
session = sessions_available.pop # LIFO
|
73
|
+
if session
|
74
|
+
sessions_in_use[session.session_id] = session
|
75
|
+
return session
|
72
76
|
end
|
73
77
|
|
74
78
|
if can_allocate_more_sessions?
|
@@ -85,7 +89,7 @@ module Google
|
|
85
89
|
if action == :new
|
86
90
|
session = new_session!
|
87
91
|
@mutex.synchronize do
|
88
|
-
sessions_in_use
|
92
|
+
sessions_in_use[session.session_id] = session
|
89
93
|
end
|
90
94
|
return session
|
91
95
|
end
|
@@ -95,12 +99,12 @@ module Google
|
|
95
99
|
|
96
100
|
def checkin_session session
|
97
101
|
@mutex.synchronize do
|
98
|
-
unless sessions_in_use.
|
102
|
+
unless sessions_in_use.key? session.session_id
|
99
103
|
raise ArgumentError, "Cannot checkin session"
|
100
104
|
end
|
101
105
|
|
102
106
|
sessions_available.push session
|
103
|
-
sessions_in_use.
|
107
|
+
sessions_in_use.delete session.session_id
|
104
108
|
|
105
109
|
@resource.signal
|
106
110
|
end
|
@@ -163,7 +167,7 @@ module Google
|
|
163
167
|
create_keepalive_task!
|
164
168
|
# init session stack
|
165
169
|
@sessions_available = @client.batch_create_new_sessions @min
|
166
|
-
@sessions_in_use =
|
170
|
+
@sessions_in_use = {}
|
167
171
|
end
|
168
172
|
|
169
173
|
def shutdown
|
@@ -176,9 +180,9 @@ module Google
|
|
176
180
|
# Delete all sessions
|
177
181
|
@mutex.synchronize do
|
178
182
|
sessions_available.each { |s| future { s.release! } }
|
179
|
-
sessions_in_use.
|
183
|
+
sessions_in_use.each_value { |s| future { s.release! } }
|
180
184
|
@sessions_available = []
|
181
|
-
@sessions_in_use =
|
185
|
+
@sessions_in_use = {}
|
182
186
|
end
|
183
187
|
# shutdown existing thread pool
|
184
188
|
@thread_pool.shutdown
|
@@ -640,20 +640,12 @@ module Google
|
|
640
640
|
|
641
641
|
request_options = build_request_options request_options
|
642
642
|
safe_execute do |seqno|
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
row_counts = batch_update_results.row_counts
|
650
|
-
@grpc ||= batch_update_results.transaction
|
651
|
-
return row_counts
|
652
|
-
rescue Google::Cloud::Spanner::BatchUpdateError
|
653
|
-
@grpc ||= batch_update_results.transaction
|
654
|
-
# Re-raise after extracting transaction
|
655
|
-
raise
|
656
|
-
end
|
643
|
+
response = session.batch_update tx_selector, seqno,
|
644
|
+
request_options: request_options,
|
645
|
+
call_options: call_options, &block
|
646
|
+
batch_update_results = BatchUpdateResults.new response
|
647
|
+
@grpc ||= batch_update_results.transaction
|
648
|
+
batch_update_results.row_counts
|
657
649
|
end
|
658
650
|
end
|
659
651
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-spanner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.18.
|
4
|
+
version: 2.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-09-
|
12
|
+
date: 2023-09-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|