|
211 | 211 | FakeJob.enqueue(1) |
212 | 212 |
|
213 | 213 | expect(Que). |
214 | | - to receive(:execute).with(:lock_job, ["default", 0, "-infinity"]).and_raise(PG::Error) |
| 214 | + to receive(:execute).with(:lock_job, ["default", 0, nil]).and_raise(PG::Error) |
215 | 215 | expect(work).to eq(:postgres_error) |
216 | 216 | end |
217 | 217 | end |
218 | 218 |
|
219 | 219 | context "when postgres raises a bad connection error while processing a job" do |
220 | 220 | before do |
221 | 221 | allow(Que).to receive(:execute). |
222 | | - with(:lock_job, ["default", 0, "-infinity"]). |
| 222 | + with(:lock_job, ["default", 0, nil]). |
223 | 223 | and_raise(PG::ConnectionBad) |
224 | 224 |
|
225 | 225 | # Ensure we don't have any currently leased connections, since in a thread |
|
246 | 246 | FakeJob.enqueue(1) |
247 | 247 |
|
248 | 248 | expect(Que). |
249 | | - to receive(:execute).with(:lock_job, ["default", 0, "-infinity"]). |
| 249 | + to receive(:execute).with(:lock_job, ["default", 0, nil]). |
250 | 250 | and_raise(ActiveRecord::ConnectionTimeoutError) |
251 | 251 | expect(work).to eq(:postgres_error) |
252 | 252 | end |
|
257 | 257 | FakeJob.enqueue(1) |
258 | 258 |
|
259 | 259 | expect(Que). |
260 | | - to receive(:execute).with(:lock_job, ["default", 0, "-infinity"]). |
| 260 | + to receive(:execute).with(:lock_job, ["default", 0, nil]). |
261 | 261 | and_raise(ActiveRecord::ConnectionNotEstablished) |
262 | 262 | expect(work).to eq(:postgres_error) |
263 | 263 | end |
|
286 | 286 | it "is false after a postgres error" do |
287 | 287 | FakeJob.enqueue(1) |
288 | 288 | expect(Que). |
289 | | - to receive(:execute).with(:lock_job, ["default", 0, "-infinity"]).and_raise(PG::Error) |
| 289 | + to receive(:execute).with(:lock_job, ["default", 0, nil]).and_raise(PG::Error) |
290 | 290 | worker.work |
291 | 291 | expect(worker).to_not be_healthy |
292 | 292 | end |
293 | 293 |
|
294 | 294 | it "recovers once work succeeds after a postgres error" do |
295 | 295 | expect(Que). |
296 | | - to receive(:execute).with(:lock_job, ["default", 0, "-infinity"]).and_raise(PG::Error) |
| 296 | + to receive(:execute).with(:lock_job, ["default", 0, nil]).and_raise(PG::Error) |
297 | 297 | worker.work |
298 | 298 | expect(worker).to_not be_healthy |
299 | 299 |
|
300 | | - allow(Que).to receive(:execute).with(:lock_job, ["default", 0, "-infinity"]).and_return([]) |
| 300 | + allow(Que).to receive(:execute).with(:lock_job, ["default", 0, nil]).and_return([]) |
301 | 301 | worker.work # no job found, returns :job_not_found |
302 | 302 | expect(worker).to be_healthy |
303 | 303 | end |
|
0 commit comments