ETLMCPData Conveyance Works
Log in Start free
Guides

Connect etlmcp to Heroku Postgres: changing credentials, SSL and Essential-plan limits

Why Heroku Postgres loads start failing after a credential rotation or a plan overage, and what to re-enter in etlmcp when Heroku changes the database URL.

Heroku owns the connection details of a Heroku Postgres database and changes them when it needs to: after you rotate credentials, after it recovers the database onto new hardware, and after its staff rotate credentials for a security reason. It writes the new URL only into the config vars of the Heroku apps the database is attached to. etlmcp is not one of those apps, so it keeps the host, port, user and password you saved, and its loads fail until you paste in the new values. The other two things that break Heroku loads are SSL, which etlmcp already handles, and the limits of the Essential plans.

When Heroku changes the URL

A rotation you start yourself uses heroku pg:credentials:rotate. Heroku's advice for outside tools is to read the URL fresh from the app's config vars at startup rather than copying it. etlmcp holds a saved copy, so you have to update it by hand each time.

To read the current values, run heroku config:get DATABASE_URL -a <your-app> (or the name of the config var your add-on uses). The URL holds the user, password, host, port and database name in that order.

What you see in etlmcp

A run against stale details fails in one of two ways:

  • could not connect: authentication failed when the host still answers but the user or password is no longer valid. This is the usual result of a rotation.
  • host not allowed when the saved host name no longer resolves, which can happen after a move to new hardware. etlmcp checks that a host resolves to a public address before it connects, and refuses it otherwise.

Edit the destination, enter the new details and press Test. If the host, the port or the user changed, etlmcp asks for the password again, because it only ever sends a saved password to the server it was saved for.

The rotation window

Rotation does not cut off the old credential at once. Heroku lets it expire when no open connection still uses it, and waits up to 30 minutes for transactions in progress before it closes those connections. If you rotate with --force, connections are killed at once. A load that was running during a rotation may therefore finish, while the next one fails with the authentication error above.

SSL

Every connection to Heroku Postgres must use SSL, with TLS 1.2 or higher, and Heroku tells clients that do not default to SSL to set sslmode=require. etlmcp connects with sslmode=require unless the operator of your etlmcp server changed that setting, so you need to do nothing. Heroku also warns against adding the parameter to the config var itself, since failovers and rotations rewrite that var. Postgres SSL explains the modes.

Which user to give etlmcp

Essential databases have one credential, the owner, and it cannot create others, so etlmcp has to use the owner. On Advanced, Standard, Premium, Private and Shield plans you can create a separate credential for etlmcp. A new credential starts with the CONNECT privilege only, and Heroku removes default access to the public schema, so grant it usage and create rights on the target schema before you press Test. Postgres privileges lists the grants. A separate credential also means rotating the app's owner credential no longer breaks etlmcp.

Essential-plan limits

Essential-0 and Essential-1 allow 20 connections and Essential-2 allows 40, with 1 GB, 10 GB and 32 GB of storage. Heroku emails the owner at 90% of a limit. Once a database goes over a limit it gets a 7-day grace period, or none if it is ever above 200% of the limit. After that Heroku revokes INSERT, CREATE and UPDATE and allows a single connection. Reads, deletes and truncates still work, so your dashboards keep showing old data while every etlmcp load fails. Bring usage back under the limit or move to a larger plan; Heroku restores the privileges by itself, though not instantly. If it is still over the limit after the grace period, Heroku keeps access revoked for another 7 days, and you have to open a support ticket to get it back.

Private and Shield databases

Databases on the Common Runtime accept connections from any network. Private and Shield-tier databases restrict network access, so etlmcp cannot reach them from outside their space without the separate setup Heroku documents for those tiers.

Related

Sources

  1. Connecting to Common Runtime Heroku Postgres Databases from an External Resource — devcenter.heroku.com, checked
  2. Connecting to Heroku Postgres — devcenter.heroku.com, checked
  3. Heroku Postgres Credentials — devcenter.heroku.com, checked
  4. Choosing the Right Heroku Postgres Plan — devcenter.heroku.com, checked
  5. Heroku Postgres Over Plan Capacity — devcenter.heroku.com, checked