zk 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -42,7 +42,7 @@ end
42
42
  group :test do
43
43
  gem 'rspec', '~> 2.8.0'
44
44
  gem 'flexmock', '~> 0.8.10'
45
- gem 'zk-server', '~> 1.0.1'
45
+ gem 'zk-server', '~> 1.1.4'
46
46
  end
47
47
 
48
48
  # Specify your gem's dependencies in zk.gemspec
@@ -65,6 +65,11 @@ In addition to all of that, I would like to think that the public API the ZK::Cl
65
65
  [zk-eventmachine]: https://github.com/slyphon/zk-eventmachine
66
66
 
67
67
  ## NEWS ##
68
+
69
+ ### v1.7.1 ###
70
+
71
+ * Fixes nasty bug "LockWaitTimeout causes lock to be forever unusable" (#49)
72
+
68
73
  ### v1.7.0 ###
69
74
 
70
75
  * Added Locker timeout feature for blocking calls. (issue #40)
@@ -1,5 +1,11 @@
1
1
  This file notes feature differences and bugfixes contained between releases.
2
2
 
3
+ ### v1.7.1 ###
4
+
5
+ * Fixes nasty bug "LockWaitTimeout causes lock to be forever unusable" (#49)
6
+
7
+ The code path in the case of a LockWaitTimeout would skip the lock node cleanup, so a given lock name would become unusable until the timed-out-locker's session went away. This fixes that case and adds specs.
8
+
3
9
  ### v1.7.0 ###
4
10
 
5
11
  * Added Locker timeout feature for blocking calls. (issue #40)
@@ -198,7 +198,7 @@ module ZK
198
198
  # @option opts [Object] :context (nil) an object passed to the `:callback`
199
199
  # given as the `context` param
200
200
  #
201
- # @option opts [:create,nil] :or (nil) syntactic sugar to say 'if this
201
+ # @option opts [:set,nil] :or (nil) syntactic sugar to say 'if this
202
202
  # path already exists, then set its contents.' Note that this will
203
203
  # also create all intermediate paths as it delegates to
204
204
  # {ZK::Client::Unixisms#mkdir_p}. Note that this option can only be
@@ -233,7 +233,7 @@ module ZK
233
233
  # @option opts [Object] :context (nil) an object passed to the `:callback`
234
234
  # given as the `context` param
235
235
  #
236
- # @option opts [:create,nil] :or (nil) syntactic sugar to say 'if this
236
+ # @option opts [:set,nil] :or (nil) syntactic sugar to say 'if this
237
237
  # path already exists, then set its contents.' Note that this will
238
238
  # also create all intermediate paths as it delegates to
239
239
  # {ZK::Client::Unixisms#mkdir_p}. Note that this option can only be
@@ -92,6 +92,13 @@ module ZK
92
92
 
93
93
  @node_deletion_watcher.block_until_deleted(opts)
94
94
  rescue WeAreTheLowestLockNumberException
95
+ rescue ZK::Exceptions::LockWaitTimeoutError
96
+ # in the case of a timeout exception, we need to ensure the lock
97
+ # path is cleaned up, since we're not interested in acquisition
98
+ # anymore
99
+ logger.warn { "got ZK::Exceptions::LockWaitTimeoutError, cleaning up lock path" }
100
+ cleanup_lock_path!
101
+ raise
95
102
  ensure
96
103
  logger.debug { "block_until_deleted returned" }
97
104
  end
@@ -109,6 +109,12 @@ module ZK
109
109
  end
110
110
 
111
111
  @node_deletion_watcher.block_until_deleted(opts)
112
+ rescue ZK::Exceptions::LockWaitTimeoutError
113
+ # in the case of a timeout exception, we need to ensure the lock
114
+ # path is cleaned up, since we're not interested in acquisition
115
+ # anymore
116
+ cleanup_lock_path!
117
+ raise
112
118
  rescue NoWriteLockFoundException
113
119
  # next_lowest_write_lock_name may raise NoWriteLockFoundException,
114
120
  # which means we should not block as we have the lock (there is nothing to wait for)
@@ -1,3 +1,3 @@
1
1
  module ZK
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  end
@@ -82,7 +82,8 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
82
82
  end
83
83
 
84
84
  describe 'blocking' do
85
- let(:read_lock_path_template) { "/_zklocking/#{path}/#{ZK::Locker::SHARED_LOCK_PREFIX}" }
85
+ let(:lock_path_base) { File.join(ZK::Locker.default_root_lock_node, path) }
86
+ let(:read_lock_path_template) { File.join(lock_path_base, ZK::Locker::SHARED_LOCK_PREFIX) }
86
87
 
87
88
  before do
88
89
  zk.mkdir_p(root_lock_path)
@@ -139,6 +140,8 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
139
140
  it %[should time out waiting for the lock] do
140
141
  ary = []
141
142
 
143
+ zk.children(lock_path_base).length.should == 1
144
+
142
145
  locker.lock.should be_false
143
146
 
144
147
  th = Thread.new do
@@ -157,6 +160,8 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
157
160
 
158
161
  th.join(2).should == th
159
162
 
163
+ zk.children(lock_path_base).length.should == 1
164
+
160
165
  ary.should be_empty
161
166
  @exc.should_not be_nil
162
167
  @exc.should be_kind_of(ZK::Exceptions::LockWaitTimeoutError)
@@ -148,6 +148,10 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
148
148
  it %[should raise LockWaitTimeoutError] do
149
149
  ary = []
150
150
 
151
+ write_lock_dir = File.dirname(@write_lock_path)
152
+
153
+ zk.children(write_lock_dir).length.should == 1
154
+
151
155
  locker.lock.should be_false
152
156
 
153
157
  th = Thread.new do
@@ -166,6 +170,8 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
166
170
 
167
171
  th.join(2).should == th
168
172
 
173
+ zk.children(write_lock_dir).length.should == 1
174
+
169
175
  ary.should be_empty
170
176
  @exc.should be_kind_of(ZK::Exceptions::LockWaitTimeoutError)
171
177
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 7
9
- - 0
10
- version: 1.7.0
9
+ - 1
10
+ version: 1.7.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonathan D. Simms
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-08-29 00:00:00 Z
19
+ date: 2012-09-22 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: zookeeper
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  requirements: []
187
187
 
188
188
  rubyforge_project:
189
- rubygems_version: 1.8.24
189
+ rubygems_version: 1.8.17
190
190
  signing_key:
191
191
  specification_version: 3
192
192
  summary: A high-level wrapper around the zookeeper driver