Skip to content

refactor: get rid of pg queue app name env var#959

Open
TylerHillery wants to merge 3 commits intomasterfrom
tyler/refactor/pg-app-name
Open

refactor: get rid of pg queue app name env var#959
TylerHillery wants to merge 3 commits intomasterfrom
tyler/refactor/pg-app-name

Conversation

@TylerHillery
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Refactor , to remove the redundant PG_QUEUE_APPLICATION_NAME.

What is the current behavior?

Currently there are two variables set that determine the application name that is used when connecting to postgres

  • PG_QUEUE_APPLICAITON_NAME which was used during the connection to the internal pg pool and MT DB
  • DB_APPLICATION_NAME which was used to connect to the tenant DB

What is the new behavior?

PG_QUEUE_APPLICATION_NAME is redundant for what we are trying to accomplish which is distinguishing the worker connections from the API connections, we only need the DB_APPLICATION_NAME to do this.

@TylerHillery TylerHillery requested a review from a team as a code owner April 1, 2026 11:48
Copilot AI review requested due to automatic review settings April 1, 2026 11:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors Postgres connection tagging by removing the dedicated PG_QUEUE_APPLICATION_NAME configuration and reusing DATABASE_APPLICATION_NAME for the pg-boss/queue connection pool, simplifying how application names are set across DB clients.

Changes:

  • Wire databaseApplicationName into the queue (pg-boss) pg.Pool config as application_name.
  • Remove pgQueueApplicationName from getConfig() and its related env var (PG_QUEUE_APPLICATION_NAME).
  • Drop the QueueDB constructor fallback that previously injected pgQueueApplicationName.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/internal/queue/queue.ts Passes databaseApplicationName as application_name for the queue pool.
src/internal/queue/database.ts Removes implicit config defaulting for application_name.
src/config.ts Removes pgQueueApplicationName from config type and env parsing.
.env.sample Removes PG_QUEUE_APPLICATION_NAME from the sample environment file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 441 to 443
databaseApplicationName:
getOptionalConfigFromEnv('DATABASE_APPLICATION_NAME') ||
`Supabase Storage API ${getOptionalConfigFromEnv('VERSION') || '0.0.0'}`,
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

Removing PG_QUEUE_APPLICATION_NAME is a breaking configuration change for existing deployments that currently set it to tag PgBoss/queue connections. Consider supporting PG_QUEUE_APPLICATION_NAME as a deprecated fallback/alias (e.g., only if DATABASE_APPLICATION_NAME is unset) or emitting a clear startup warning so operators understand why connection tagging changed.

Suggested change
databaseApplicationName:
getOptionalConfigFromEnv('DATABASE_APPLICATION_NAME') ||
`Supabase Storage API ${getOptionalConfigFromEnv('VERSION') || '0.0.0'}`,
databaseApplicationName: (() => {
const databaseApplicationName = getOptionalConfigFromEnv('DATABASE_APPLICATION_NAME')
if (databaseApplicationName) {
return databaseApplicationName
}
const legacyQueueApplicationName = getOptionalConfigFromEnv('PG_QUEUE_APPLICATION_NAME')
if (legacyQueueApplicationName) {
console.warn(
'PG_QUEUE_APPLICATION_NAME is deprecated; please migrate to DATABASE_APPLICATION_NAME. ' +
'Support for PG_QUEUE_APPLICATION_NAME may be removed in a future release.'
)
return legacyQueueApplicationName
}
return `Supabase Storage API ${getOptionalConfigFromEnv('VERSION') || '0.0.0'}`
})(),

Copilot uses AI. Check for mistakes.
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 1, 2026

Pull Request Test Coverage Report for Build 23847839555

Details

  • 0 of 2 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 80.428%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/internal/queue/queue.ts 0 2 0.0%
Totals Coverage Status
Change from base Build 23838947774: 0.04%
Covered Lines: 29789
Relevant Lines: 36858

💛 - Coveralls

"type": "prometheus",
"uid": "local_prometheus"
},
"expr": "pgbouncer_up{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}",
Copy link
Copy Markdown
Member

@ferhatelmas ferhatelmas Apr 2, 2026

Choose a reason for hiding this comment

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

this won't work here because job name isn't matching

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it seems we're also running different version of exporter

@ferhatelmas
Copy link
Copy Markdown
Member

I think env changes are fine. If you can want, we can merge it and add the setup/dashboard separately.

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.

4 participants