-
Notifications
You must be signed in to change notification settings - Fork 65
521 test robustness pgbouncer #522
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
Changes from 4 commits
6eeb949
20d1db7
5b65252
7277143
bf1d5bf
2afe845
942b007
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
# To make output dates deterministic | ||
export TZ='Europe/Rome' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
const { Client } = require('pg'); | ||
|
||
const dbConfig = { | ||
db_user: process.env.PGUSER || 'postgres', | ||
db_host: global.settings.db_host, | ||
db_port: global.settings.db_port, | ||
db_batch_port: global.settings.db_batch_port | ||
}; | ||
|
||
module.exports.resetPgBouncerConnections = function (callback) { | ||
// We assume there's no pgbouncer if db_port === db_batch_port | ||
if (dbConfig.db_port === dbConfig.db_batch_port) { | ||
return callback(); | ||
} | ||
|
||
const client = new Client({ | ||
database: 'pgbouncer', | ||
user: dbConfig.db_user, | ||
host: dbConfig.db_host, | ||
port: dbConfig.db_port | ||
}); | ||
|
||
// We just chain a PAUSE followed by a RESUME | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about |
||
client.connect(); | ||
client.query('PAUSE', (err, res) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, follow Node.js conventions: client.query('PAUSE', (err, res) => {
if (err) {
return callback(err);
}
client.query('RESUME', (err, res) => ...);
} If you inmediatly return after calling the callback, there is no need to wrap following sentences into a |
||
if (err) { | ||
return callback(err); | ||
} else { | ||
client.query('RESUME', (err, res) => { | ||
client.end(); | ||
return callback(err); | ||
}); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ei, what is the objective of pause - resume?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://pgbouncer.github.io/usage.html#admin-console
Wait for all the running queries to finish and let the new ones reconnect. This way you pick the changed session parameters such as
set statement_timeout
. Sames happens in production, BTW, but there the connections are refreshed usually more often.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks! :)