Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lock_timeout #2779

Merged
merged 1 commit into from Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/pg/lib/client.js
Expand Up @@ -403,6 +403,9 @@ class Client extends EventEmitter {
if (params.statement_timeout) {
data.statement_timeout = String(parseInt(params.statement_timeout, 10))
}
if (params.lock_timeout) {
data.lock_timeout = String(parseInt(params.lock_timeout, 10))
}
if (params.idle_in_transaction_session_timeout) {
data.idle_in_transaction_session_timeout = String(parseInt(params.idle_in_transaction_session_timeout, 10))
}
Expand Down
1 change: 1 addition & 0 deletions packages/pg/lib/connection-parameters.js
Expand Up @@ -103,6 +103,7 @@ class ConnectionParameters {
this.application_name = val('application_name', config, 'PGAPPNAME')
this.fallback_application_name = val('fallback_application_name', config, false)
this.statement_timeout = val('statement_timeout', config, false)
this.lock_timeout = val('lock_timeout', config, false)
this.idle_in_transaction_session_timeout = val('idle_in_transaction_session_timeout', config, false)
this.query_timeout = val('query_timeout', config, false)

Expand Down
4 changes: 4 additions & 0 deletions packages/pg/lib/defaults.js
Expand Up @@ -54,6 +54,10 @@ module.exports = {
// false=unlimited
statement_timeout: false,

// Abort any statement that waits longer than the specified duration in milliseconds while attempting to acquire a lock.
// false=unlimited
lock_timeout: false,

// Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds
// false=unlimited
idle_in_transaction_session_timeout: false,
Expand Down
3 changes: 3 additions & 0 deletions packages/pg/test/unit/connection-parameters/creation-tests.js
Expand Up @@ -28,6 +28,7 @@ var compare = function (actual, expected, type) {
assert.equal(actual.password, expected.password, type + ' password')
assert.equal(actual.binary, expected.binary, type + ' binary')
assert.equal(actual.statement_timeout, expected.statement_timeout, type + ' statement_timeout')
assert.equal(actual.lock_timeout, expected.lock_timeout, type + ' lock_timeout')
assert.equal(actual.options, expected.options, type + ' options')
assert.equal(
actual.idle_in_transaction_session_timeout,
Expand All @@ -51,6 +52,7 @@ suite.test('ConnectionParameters initializing from defaults with connectionStrin
host: 'foo.bar.net',
binary: defaults.binary,
statement_timeout: false,
lock_timeout: false,
idle_in_transaction_session_timeout: false,
options: '-c geqo=off',
}
Expand Down Expand Up @@ -78,6 +80,7 @@ suite.test('ConnectionParameters initializing from config', function () {
asdf: 'blah',
},
statement_timeout: 15000,
lock_timeout: 15000,
idle_in_transaction_session_timeout: 15000,
options: '-c geqo=off',
}
Expand Down