Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01fadd9

Browse files
fix #3508 - recheck min client count during idle callback (#3509)
1 parent 43b8692 commit 01fadd9

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

‎packages/pg-pool/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,10 @@ class Pool extends EventEmitter {
372372
let tid
373373
if (this.options.idleTimeoutMillis && this._isAboveMin()) {
374374
tid = setTimeout(() => {
375-
this.log('remove idle client')
376-
this._remove(client, this._pulseQueue.bind(this))
375+
if (this._isAboveMin()) {
376+
this.log('remove idle client')
377+
this._remove(client, this._pulseQueue.bind(this))
378+
}
377379
}, this.options.idleTimeoutMillis)
378380

379381
if (this.options.allowExitOnIdle) {

‎packages/pg-pool/test/sizing.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,19 @@ describe('pool size of 2', () => {
124124
})
125125
)
126126
})
127+
128+
describe('pool min size', () => {
129+
it(
130+
'does not drop below min when clients released at same time',
131+
co.wrap(function* () {
132+
const pool = new Pool({ max: 2, min: 1, idleTimeoutMillis: 10 })
133+
const client = yield pool.connect()
134+
const client2 = yield pool.connect()
135+
client.release()
136+
client2.release()
137+
yield new Promise((resolve) => setTimeout(resolve, 20))
138+
expect(pool.idleCount).to.equal(1)
139+
return yield pool.end()
140+
})
141+
)
142+
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /