feat(data-warehouse): add --only-stuck and duckgres sink to queue command - #69688
Conversation
|
Hey @estefaniarabadan! 👋 It looks like your git author email on this PR isn't your
You can fix it for this repo with: git config user.email "you@posthog.com"Or set it globally with |
|
danielcarletti
left a comment
There was a problem hiding this comment.
Approving with a small ask just to make sure
…mand Extends the manage_warehouse_queue management command: - fail-run gains --only-stuck to target only potentially bad runs (running past a grace period with no batches or only pending/stale batches) instead of failing every active sync - status, fail-run, and release-locks now support --sink duckgres via new sync ops helpers on DuckgresBatchQueue mirroring the postgres_queue interface - workflow cancellation reuses one Temporal client connection and honors the connect override flags Generated-By: PostHog Code Task-Id: 1286e56a-9b2e-4f08-9d53-bf83096dde00
0a5786a to
5a9d486
Compare
Problem
The
manage_warehouse_queuerunbook command works well for controlling the pipeline v3 queue, but itsfail-runsubcommand fails every active sync in scope. When operating the queue you usually only want to clear out the runs that are actually misbehaving, not healthy in-flight syncs. The command also only knew about the Postgres queue sink, so duckgres-backed runs couldn't be managed the same way.Changes
fail-run --only-stuck: targets only potentially bad runs, meaning runs that have been going longer than--stuck-grace-secondsand have either no queue batches or only pending/stale batches. Runs with recent batch activity are skipped and reported. Since this filter is inherently safe,--only-stuckalso lifts the scoping requirement, so it can sweep across teams in one pass (still dry-run by default).--sink duckgres:status,fail-run, andrelease-locksnow manage the duckgres queue too.DuckgresBatchQueuegains sync ops helpers (pending batch lookup, batch failing, lease release) mirroring the postgres_queue interface. Flags that only make sense for one sink (for example--cancel-workflowand--redis-onlywith duckgres) are rejected with a clear error.fail-run --cancel-workflownow opens one shared Temporal client connection for the batch, and the connect override flags (--temporal-host, certs, namespace) actually reach the client instead of being ignored.How did you test this code?
Automated tests only, run locally:
products/warehouse_sources/backend/tests/management/test_manage_warehouse_queue.py: 23 passed, including new coverage for--only-stuck(only inactive runs failed, unscoped use allowed), the duckgres sink (fail-run touches only pending duckgres batches, release-locks releases only duckgres leases, status sections), sink-specific flag validation, and a regression test asserting the Temporal connect overrides reach the client.test_jobs_db.pysuites: 83 passed.ruff checkandruff format --checkclean.No manual run against a live queue was performed by the agent.
Automatic notifications
Docs update
Internal operational command; no user-facing docs to update.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
/writing-tests.--only-stuckheuristic implements runbook feedback: a run is considered stuck when it exceeds a grace period with no batches or none progressing. We keptfail-runfailing everything by default and made stuck-detection opt-in, rather than changing the default behavior under operators' feet.--sinkswitch on the existing command instead of a separate command, so the runbook stays one entry point. The duckgres helpers were shaped to mirror the postgres_queue jobs_db interface to keep the command's code paths symmetric.Created with PostHog Code