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

Update from upstream #1

Merged
merged 13 commits into from
Mar 23, 2021
Merged

Update from upstream #1

merged 13 commits into from
Mar 23, 2021

Conversation

jnoconor
Copy link

@jnoconor jnoconor commented Mar 2, 2021

Our current version of this buildpack does not support Heroku-20 (or even Heroku-18 it looks like). We can't switch to the stock buildpack because we rely on a connect_query option to do statement timeouts on queries through pgbouncer. There is an open PR for this in the main repo (heroku#95), but the outlook for getting it merged does not look good.

This PR merges the upstream changes and add our patch back on top.

Diff between heroku/heroku-buildpack-pgbouncer/main and vhx/heroku-buildpack-pgbouncer/update-from-upstream.

diff --git a/README.md b/README.md
index bbe74bc..4943043 100644
--- a/README.md
+++ b/README.md
@@ -139,6 +139,7 @@ Some settings are configurable through app config vars at runtime. Refer to the
 - `PGBOUNCER_SERVER_RESET_QUERY` Default is empty when pool mode is transaction, and "DISCARD ALL;" when session.
 - `PGBOUNCER_IGNORE_STARTUP_PARAMETERS` Adds parameters to ignore when pgbouncer is starting. Some postgres libraries, like Go's pq, append this parameter, making it impossible to use this buildpack. Default is empty and the most common ignored parameter is `extra_float_digits`. Multiple parameters can be seperated via commas. Example: `PGBOUNCER_IGNORE_STARTUP_PARAMETERS="extra_float_digits, some_other_param"`
 - `PGBOUNCER_QUERY_WAIT_TIMEOUT` Default is 120 seconds, helps when the server is down or the database rejects connections for any reason. If this is disabled, clients will be queued infinitely.
+- `PGBOUNCER_CONNECT_QUERY` Query to be executed after a connection is established, but before allowing the connection to be used by any clients. If the query raises errors, they are logged but ignored otherwise.

 For more info, see [CONTRIBUTING.md](CONTRIBUTING.md)

diff --git a/bin/gen-pgbouncer-conf.sh b/bin/gen-pgbouncer-conf.sh
index 7a45a39..1308047 100644
--- a/bin/gen-pgbouncer-conf.sh
+++ b/bin/gen-pgbouncer-conf.sh
@@ -66,8 +66,13 @@ do
 "$DB_USER" "$DB_MD5_PASS"
 EOFEOF

+  CONNECT_QUERY_PARAM=''
+  if [[ "$PGBOUNCER_CONNECT_QUERY" ]]; then
+    CONNECT_QUERY_PARAM="connect_query='${PGBOUNCER_CONNECT_QUERY//\'/\'\'}'"
+  fi
+
   cat >> /app/vendor/pgbouncer/pgbouncer.ini << EOFEOF
-$CLIENT_DB_NAME= host=$DB_HOST dbname=$DB_NAME port=$DB_PORT
+$CLIENT_DB_NAME= host=$DB_HOST dbname=$DB_NAME port=$DB_PORT $CONNECT_QUERY_PARAM
 EOFEOF

   let "n += 1"

mfly and others added 13 commits September 13, 2019 14:44
* [changelog skip] Ensure PRs include a Changelog entry

The goal of this PR is to add a github action that checks for the presence of a changelog entry.

It is better to add entries as a PR is merged instead of having to remember what was merged and generate a changelog at release time.

By automating this check, it's one less thing the maintainer has to remember, and it's one less thing a change might be blocked on i.e. "Looks good, but please add a changelog entry".

Let me know if you have any questions and Happy Friday!

* [changelog skip] Fix Escaping in Changelog Script

The previous PR had a bug where the REGEX for grep was not properly escaped. This PR fixes that issue.

* Update check_changelog.yml
* add support for versioned patchfiles

* update pgbouncer url

* use -build image for make shell

* build pgbouncer 1.12 with heroku-18

* mv from 1.12 to 1.13

* run 1.13 on heroku-16

* add stack to archive name

* build 1.13 for heroku-16

* set default to 1.13

* move patch to 1.7 from default

* update changelog

* our changelog is lowercased
This adds support for the upcoming Heroku-20 stack.

The conditional in `bin/compile` has also been updated to handle being
run on an unsupported stack, since otherwise the compile would fail with
a less clear tar error when the stack-specific archive file does not
exist.

Fixes W-7584085.
* Add pgbouncer 1.14

* Update Changelog.md
* drop pgbouncer version from tar file

* use build_dir to fetch pgbouncer version

* Update Changelog

* Update message, we are not fetching anything here
* Change references to default branch

* Add to changelog
* add circleci config

* rename tests

* update Changelog
This commit adds the `connect_query` configuration option using a
`PGBOUNCER_CONNECT_QUERY` environment variable.
@jnoconor jnoconor self-assigned this Mar 2, 2021
@jnoconor jnoconor requested a review from a team March 2, 2021 20:56
@jnoconor jnoconor marked this pull request as ready for review March 2, 2021 20:56
Copy link

@elliterate elliterate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this includes an upgrade for pgbouncer itself from 1.7.2 to 1.14.0. Probably worth crafting a test plan and watching the rollout carefully.

@jnoconor jnoconor merged commit 355492f into master Mar 23, 2021
@jnoconor jnoconor mentioned this pull request Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants