switchman 1.3.9 → 1.3.10

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
  SHA1:
3
- metadata.gz: c73ebcdb49c218c7550f44ec2087c7feb091ef45
4
- data.tar.gz: e3e8e34ff693c05204617ba9e2c747db0a5fbc39
3
+ metadata.gz: 7e276855b3c8456e699ac6b6c98acb63f7073651
4
+ data.tar.gz: 5bde98e540b07948028776ae6565e112847b6086
5
5
  SHA512:
6
- metadata.gz: 86b7f9cc5f2453465a963bf13c9252556e12750f91ee2a9474eea826a13bde2f7c04c271ad91d2fc3f97b0046deb5ce38c285914f62d3fa4bf9e94d617889076
7
- data.tar.gz: e365daa2f0fe7ba8de97d29a44d832200b7256dca79378bca1d341ea1696c32320ae06390c486bd25030081e8fe966f76115518a33a031a8c721c33b3d420d1d
6
+ metadata.gz: e83f34a2731eab5383632da988c0f0b72ee0b13c56db38d3ae94b3e93af3117ffc6b95a9886c11f5878b726520f19a7c2f1e074d0e4dd436b4a7e253866e8886
7
+ data.tar.gz: cb6cb6bb2ac31c99777c892e3af926be2c1c8480da0a9ccbb6e1b3fd05bc000deb7b7bdcef8b04b8a1bd641f89c8c690de3c932daadaaaab0c5e3e9b528c796c
@@ -39,21 +39,26 @@ module Switchman
39
39
  def release_connection_with_idle_timeout(with_id = current_connection_id)
40
40
  release_connection_without_idle_timeout(with_id)
41
41
 
42
- # TODO may need a synchronize (or to be included in a synchronize
43
- # inside release_connection_without_idle_timeout) when we make
44
- # switchman thread-safe
45
42
  if spec.config[:idle_timeout]
46
43
  clear_idle_connections!(Time.now - spec.config[:idle_timeout].to_i)
47
44
  end
48
45
  end
49
46
 
50
47
  def clear_idle_connections!(since_when)
51
- @connections.reject! do |conn|
52
- if conn.last_query_at < since_when && !conn.in_use?
53
- conn.disconnect!
54
- true
55
- else
56
- false
48
+ synchronize do
49
+ @connections.reject! do |conn|
50
+ if conn.last_query_at < since_when && !conn.in_use?
51
+ conn.disconnect!
52
+ true
53
+ else
54
+ false
55
+ end
56
+ end
57
+ if ::Rails.version >= '4'
58
+ @available.clear
59
+ @connections.each do |conn|
60
+ @available.add conn
61
+ end
57
62
  end
58
63
  end
59
64
  end
@@ -1,3 +1,3 @@
1
1
  module Switchman
2
- VERSION = "1.3.9"
2
+ VERSION = "1.3.10"
3
3
  end
@@ -356813,3 +356813,27 @@ Connecting to database specified by database.yml
356813
356813
   (0.1ms) ROLLBACK
356814
356814
   (0.1ms) BEGIN
356815
356815
   (0.1ms) ROLLBACK
356816
+  (2.7ms) SELECT * FROM unnest(current_schemas(false))
356817
+ Switchman::Shard Load (25.9ms) SELECT "switchman_shards".* FROM "switchman_shards" WHERE "switchman_shards"."default" = 't' ORDER BY "switchman_shards"."id" ASC LIMIT 1
356818
+  (0.1ms) BEGIN
356819
+  (0.1ms) SAVEPOINT active_record_1
356820
+ SQL (1.9ms) INSERT INTO "switchman_shards" ("database_server_id") VALUES ($1) RETURNING "id" [["database_server_id", "1"]]
356821
+  (0.1ms) RELEASE SAVEPOINT active_record_1
356822
+  (0.1ms) ROLLBACK
356823
+  (1.3ms) SELECT * FROM unnest(current_schemas(false))
356824
+ Switchman::Shard Load (0.6ms) SELECT "switchman_shards".* FROM "switchman_shards" WHERE "switchman_shards"."default" = 't' ORDER BY "switchman_shards"."id" ASC LIMIT 1
356825
+  (0.1ms) BEGIN
356826
+  (0.2ms) SAVEPOINT active_record_1
356827
+ SQL (0.8ms) INSERT INTO "switchman_shards" ("database_server_id") VALUES ($1) RETURNING "id" [["database_server_id", "1"]]
356828
+  (0.1ms) RELEASE SAVEPOINT active_record_1
356829
+  (0.1ms) ROLLBACK
356830
+  (0.4ms) SELECT * FROM unnest(current_schemas(false))
356831
+ Switchman::Shard Load (0.6ms) SELECT "switchman_shards".* FROM "switchman_shards" WHERE "switchman_shards"."default" = 't' ORDER BY "switchman_shards"."id" ASC LIMIT 1
356832
+  (0.1ms) BEGIN
356833
+  (0.2ms) SAVEPOINT active_record_1
356834
+ SQL (0.4ms) INSERT INTO "switchman_shards" ("database_server_id") VALUES ($1) RETURNING "id" [["database_server_id", "1"]]
356835
+  (0.1ms) RELEASE SAVEPOINT active_record_1
356836
+  (0.1ms) ROLLBACK
356837
+ Connecting to database specified by database.yml
356838
+  (0.4ms) SELECT * FROM unnest(current_schemas(false))
356839
+ Switchman::Shard Load (0.5ms) SELECT "switchman_shards".* FROM "switchman_shards" WHERE "switchman_shards"."default" = 't' LIMIT 1
@@ -37,6 +37,8 @@ module Switchman
37
37
  @pool.checkin(@conn)
38
38
  @pool.clear_idle_connections!(@conn.last_query_at + 1)
39
39
  expect(@pool.connections).to be_empty
40
+ # fresh connection
41
+ expect(@pool.connection).to_not eq @conn
40
42
  end
41
43
 
42
44
  it "should not affect idle but checked out connections" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.9
4
+ version: 1.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-10-28 00:00:00.000000000 Z
13
+ date: 2015-11-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties