Skip to content

fix(clickhouse): connect to the persons queue inside the sweep op - #92072

Open
eli-r-ph wants to merge 1 commit into
masterfrom
fix/dagster-persons-connect
Open

fix(clickhouse): connect to the persons queue inside the sweep op#92072
eli-r-ph wants to merge 1 commit into
masterfrom
fix/dagster-persons-connect

Conversation

@eli-r-ph

Copy link
Copy Markdown
Contributor

Problem

The first prod dry run of clickhouse_deletion_sweep_job failed on a Postgres connection a dry run never uses. The persons_database resource opens its connection at resource init, so persist_deleted_persons dialed the persons writer before its dry-run check ran, and the closed network path timed out after two silent minutes. A resource-init failure emits no STEP_FAILURE, so drop_assets_on_failure never fired and the run's two dictionaries (about 18 GiB on each of 24 hosts) survived until dropped by hand.

Changes

  • A dry run of the sweep no longer touches Postgres at all.
  • A failed connect now fails the step, so the failure hook drops the run's dictionaries instead of stranding them.
  • persist_deleted_persons receives the connection URL (new PostgresURL resource, persons_database_url) and connects inside the op body, after the dry-run return, closing the connection in a finally.
  • The shared PostgresResource gains connect_timeout=10, so a blackholed route fails in seconds with a clear error instead of hanging for the OS TCP timeout. This is the one part of the diff that touches other jobs; the rest is confined to the sweep.
  • No user-visible change; this is all Dagster job plumbing.

How did you test this code?

  • New test: a run whose Postgres connect fails ends with zero dictionaries left for that run, which is exactly the cleanup the prod failure skipped.
  • New test: a dry-run invocation of the op with psycopg2.connect patched to raise never calls it.
  • The existing handoff tests (queueing, paging, requeue, retry-idempotence) run through the new connect path unchanged.
  • Not run: hogli review (the local Greptile CLI fails to install in this environment).

🤖 Agent context

Authored with Claude Code in an interactive session with Eli, from the failed prod-eu run's debug log (RESOURCE_INIT_FAILURE on persons_database, psycopg2 connection timeout to the persons writer). Skills invoked: /writing-tests, /writing-code-comments, /writing-pr-descriptions. Companion charts PR PostHog/charts#14920 attaches the persons client security group to the Dagster node class, which is the network half of the fix. Kept the existing eager persons_database resource for its other consumers; only the sweep op moved to the lazy URL resource.

A dry run of the deletion sweep failed at Postgres resource init on a
network path a dry run never uses, and a resource-init failure fires no
failure hook, so the run's dictionaries survived on every host. The op
now receives the connection URL and connects after the dry-run return,
inside the step, with a ten-second connect timeout on the shared
Postgres resources.
@trunk-io

trunk-io Bot commented Aug 31, 2026

Copy link
Copy Markdown

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

Playwright — all passed

All tests passed.

View test results →

@eli-r-ph
eli-r-ph requested review from a team September 1, 2026 00:11
@eli-r-ph
eli-r-ph marked this pull request as ready for review September 1, 2026 00:12
@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(clickhouse): connect to the persons ..." | Re-trigger Greptile

@trunk-io

trunk-io Bot commented Sep 1, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

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.

1 participant