Skip to content

[#13760] feat(tms): Register policy timeTrigger on the expand scheduler - #13897

Draft
lasdf1234 wants to merge 2 commits into
apache:branch-tms-schedulerfrom
lasdf1234:feature/tms-policy-timetrigger-scheduler
Draft

lasdf1234 wants to merge 2 commits into
apache:branch-tms-schedulerfrom
lasdf1234:feature/tms-policy-timetrigger-scheduler

Conversation

@lasdf1234

Copy link
Copy Markdown
Collaborator

What changes were proposed in this pull request?

Follow-up on the TMS scheduler pools from Epic #13760.

When a maintenance policy carries timeTrigger, create, alter, enable, disable, and delete keep a matching policy-expand row in scheduled_expand_tasks:

  • Enabled policy with a non-blank cron: insert or move the row. The task instance id is the policy id, and the due time is the next Quartz cron fire time.
  • Disabled policy, blank timeTrigger, or a successful delete: remove the row.
  • Non-maintenance policies are ignored.

The expand handler is still a no-op. This change only registers the row. The db-scheduler client forces auto-commit, and the pools commit when auto-commit is off, so writes survive the entity-store connection pool.

Why are the changes needed?

Policy content stores timeTrigger, but nothing was writing that schedule into db-scheduler. Without this, a created or updated maintenance policy never becomes an expand lease, and a deleted or disabled policy would leave a stale row.

Fix: #13760

Does this PR introduce any user-facing change?

No new REST API or configuration key. Creating, altering, enabling, disabling, or deleting a maintenance policy that has timeTrigger now inserts, moves, or deletes the corresponding policy-expand row while TMS scheduler pools are running.

How was this patch tested?

  • TestPolicyTimeTriggerEventListener covers create, alter, enable, disable, delete, a failed delete, and non-maintenance policies.
  • TestPolicyExpandScheduler inserts, reschedules, and removes the expand row on the H2 entity-store schema.
  • ./gradlew :plugins:tms:test --tests org.apache.gravitino.maintenance.scheduler.TestPolicyTimeTriggerEventListener --tests org.apache.gravitino.maintenance.scheduler.TestPolicyExpandScheduler --tests org.apache.gravitino.maintenance.scheduler.TestTableMaintenanceSchedulerPools -PskipITs

Made with Cursor

…cheduler

Keep the policy-expand row aligned when a maintenance policy with timeTrigger is created, altered, enabled, disabled, or deleted.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lasdf1234 lasdf1234 self-assigned this Oct 16, 2026
@lasdf1234
lasdf1234 marked this pull request as draft October 16, 2026 11:49
…uler transaction

Write the policy-expand row in the same transaction as the policy change so a failed schedule rolls the policy write back.

Co-authored-by: Cursor <cursoragent@cursor.com>
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