Skip to content

activity_stream partition maintenance is never scheduled — no retention, all rows land in the catch-all partition #30333

Open

Description

@sonika-shah

Affected module

Backend (2.0 / main)

Describe the bug

The 2.0 activity feed refactor introduced activity_stream as a time-partitioned table (PARTITION BY RANGE (timestamp), monthly buckets) and shipped ActivityStreamPartitionManager to manage its lifecycle:

maintainPartitions(int monthsAhead, int retentionDays)
  ├── createPartitionIfNotExists(month)   // pre-create next N monthly partitions
  └── dropPartitionIfExists(oldMonth)     // drop partitions past retention (looks back 24 months)

maintainPartitions() has zero callers — no scheduled job, app hook, or startup path invokes it. Consequences:

  1. No retention for activity data. ActivityStreamPublisher converts every entity change event into activity rows, making this one of the fastest-growing tables on a busy instance, and nothing ever ages rows out. The Data Retention app does not cover this table either (by design — partition-drop is the intended mechanism, not row DELETEs).
  2. The partitioning is inert. The 2.0 migration only creates catch-all partitions — activity_stream_default on PostgreSQL, p_max VALUES LESS THAN MAXVALUE on MySQL. Since monthly partitions are never created, every row lands in the catch-all, so even once maintainPartitions is wired up, dropping monthly partitions will not remove any existing data.
  3. Remediation cost grows over time. On PostgreSQL, CREATE TABLE ... PARTITION OF ... FOR VALUES FROM x TO y fails when the default partition already holds rows in that range, so accumulated rows must first be detached/moved out of activity_stream_default. On MySQL, splitting p_max requires an increasingly expensive REORGANIZE PARTITION. The longer this stays unwired, the larger that one-off migration becomes.

To Reproduce

  1. Run a 2.0 instance with normal entity activity (ingestion, edits).
  2. SELECT COUNT(*) FROM activity_stream_default; (Postgres) — all rows accumulate in the default partition indefinitely.
  3. Observe no monthly activity_stream_y* partitions exist and none are ever created or dropped.

Expected behavior

  • Monthly partitions are pre-created ahead of time and expired partitions are dropped on a schedule, per the design documented in ActivityStreamPartitionManager.
  • Activity retention period is configurable (e.g., alongside the Data Retention app's other periods, or activity_stream_config).

Proposed fix

  1. Wire maintainPartitions(monthsAhead, retentionDays) into a scheduled path — either as a step in the Data Retention app run or a dedicated Quartz job — with a configurable retention period.
  2. Add a one-time remediation for instances that have accumulated rows in the catch-all partition (move rows into their monthly partitions, or accept dropping the default partition's contents past retention).

Additional context

Found while root-causing the Data Retention failure on 2.0 (#30332): that PR fixes the conversation-thread cleanup crash and intentionally leaves this partition-maintenance gap as a separate piece of work.

Version

  • OpenMetadata version: 2.0.0-SNAPSHOT (main @ b4bc7a5)

Metadata

Metadata

Assignees

Labels

area:feeds-tasks-activityFeeds, threads, tasks, announcements, activity, conversations, suggestions, websockets.backendbugSomething isn't working

Type

Projects

  • Status
    Release Backlog 🚧

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions