Skip to content

fix(analytics): bound scheduled DDL steps under RDS Proxy (no statement_timeout) #1073

Description

@cristim

Problem

The scheduled analytics_collect pipeline (internal/server/analytics_collect.go::handleCollectAnalytics) runs partition provisioning, retention, and materialized-view refresh as long-running DDL statements on the context handed in by the scheduled-task entrypoint (http.go / lambda.go). That context carries no per-step DB deadline.

Under RDS Proxy a session-level statement_timeout is not honoured, so a runaway DDL step (for example a REFRESH MATERIALIZED VIEW CONCURRENTLY blocked on a lock) could hang the entire scheduled run indefinitely.

Evidence

Finding 06-N3 from the data-layer review (docs/code-review source 06-data-layer.md), folded into PR #1049:

analytics/postgres_analytics.go:352,364,396 - Ensure callers pass bounded ctx to CreatePartition/DropOldPartitions/RefreshMaterializedViews (no statement_timeout under RDS Proxy).

Fix

Bound each DDL step in handleCollectAnalytics with a per-step child context (analyticsDDLTimeout, 5m) so the pipeline makes forward progress or fails fast rather than hanging. Implemented in PR #1049.

Files

  • internal/server/analytics_collect.go

Verification

Regression test TestHandleCollectAnalytics_DDLStepsAreBounded runs the pipeline under a deadline-free parent context and asserts each DDL step observes a deadline (so the bound can only have come from the pipeline itself). Pre-fix the steps inherited the unbounded parent and the assertion fails.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/xsTrivial / one-linerimpact/internalTeam-internal onlypr-createdA PR has been opened for this issue (dedup guard for the auto-PR loop)pr-mergedThe PR for this issue has been mergedpriority/p2Backlog-worthyseverity/mediumModerate harmtriagedItem has been triagedtype/bugDefecturgency/this-sprintWithin the current sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions