Skip to content

Tag replication connections with per-worker application_name#882

Open
jmqd wants to merge 10 commits into
mainfrom
jm/per-worker-application-name
Open

Tag replication connections with per-worker application_name#882
jmqd wants to merge 10 commits into
mainfrom
jm/per-worker-application-name

Conversation

@jmqd

@jmqd jmqd commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

All ETL replication connections currently report the same application_name, so from the server's side the apply worker and every table-sync copy connection are indistinguishable.

This tags each worker connection with its identity:

supabase_etl_replicator_replication:apply:{pipeline_id}
supabase_etl_replicator_replication:tsync:{pipeline_id}:{table_oid}

Two motivations:

  1. Deterministic fault injection. Upcoming chaos tests need to kill one specific connection: the copy connection for table X mid-COPY, or the apply walsender while a destination write is in flight. With distinct names, a test finds its target with one exact-match query against pg_stat_activity and pg_terminate_backends it. Without them, tests have to guess by PID heuristics, which flakes.
  2. Operational attribution. pg_stat_activity and pg_stat_replication now show which worker (and which table) owns each connection, lock wait, and terminated backend.

jmqd added 3 commits July 7, 2026 15:35
Apply and table sync replication connections now report
{base}:apply:{pipeline_id} and {base}:tsync:{pipeline_id}:{table_oid}
in pg_stat_activity. Child copy connections inherit the parent worker's
name. Overlong names clamp the base and keep the worker suffix intact.
Rename budget to max_allowed_len, use floor_char_boundary instead of a
manual boundary loop, and trim connect_for_* doc comments.
@coveralls

coveralls commented Jul 8, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 72.923% (+0.08%) from 72.841% — jm/per-worker-application-name into main

@jmqd jmqd marked this pull request as ready for review July 8, 2026 09:32
@jmqd jmqd requested a review from a team as a code owner July 8, 2026 09:32
Comment thread crates/etl-postgres/src/application_name.rs Outdated
jmqd added 2 commits July 9, 2026 11:35
The longer tag narrows the no-clamp bound to 15 combined digits of
pipeline id and table oid; beyond that the base clamps and the suffix
survives. Length tests restated around the new bound.
Clamping is expected with long pipeline ids and table oids, not an
anomaly worth a warning.
@jmqd jmqd requested a review from iambriccardo July 9, 2026 03:49

@iambriccardo iambriccardo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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.

3 participants