Skip to content

[#13984] feat(tms): Expand policy-expand into cron-job rows (nearest-policy) - #13985

Closed
lasdf1234 wants to merge 6 commits into
apache:branch-tms-schedulerfrom
lasdf1234:feature/tms-expand-cron-enqueue-13984
Closed

lasdf1234 wants to merge 6 commits into
apache:branch-tms-schedulerfrom
lasdf1234:feature/tms-expand-cron-enqueue-13984

Conversation

@lasdf1234

@lasdf1234 lasdf1234 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

What changes were proposed in this pull request?

Implement expand-pool fan-out (§5.2.1) against branch-tms-scheduler — full policy → cron-job row path:

  • Replace the policy-expand no-op with PolicyExpandPipeline that loads the policy, validates timeTrigger before enqueue, lists tables, and enqueues one-shot cron-job rows (table:{tableId}:{policyId}) via scheduleIfNotExists
  • Nearest-policy enumeration: NearestPolicyTableEnumerator expands tag-bound catalog/schema/table attachments and keeps tables where this policy is the nearest winner of its BuiltInType (NearestMaintenancePolicyResolver)
  • Reschedule the expand lease to the next Quartz fire, or remove it when the policy is missing / disabled / blank or invalid timeTrigger / non-maintenance
  • Cron-pool callback still defers Spark submit but removes the one-shot row after pick so later expands can re-schedule
  • Autocommit wrapper for SchedulerClient against the entity-store DataSource (defaultAutoCommit=false)

Out of scope: policy-expand registration / PreCommitHook (#13897), cron-pool Spark submit, commit-job path.

Why are the changes needed?

Fix: #13984

Parent: #13760. Without a real expand pick handler, due policy-expand leases never produce cron-job rows.

Does this PR introduce any user-facing change?

No. Internal scheduler behavior only; uses existing gravitino.maintenance.expand.enqueueBatchSize.

How was this patch tested?

  • ./gradlew :plugins:tms:test -PskipITs --tests 'org.apache.gravitino.maintenance.scheduler.Test*'
  • Unit coverage: expand skip / enqueue / next-due, cron remove-after-pick, nearest-policy table vs ancestor, schema expand with override

Wire the expand-pool handler to resolve the policy, batch-list tag-bound
tables, enqueue idempotent cron-job rows, and reschedule or remove the
expand lease per design §5.2.1.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lasdf1234
lasdf1234 force-pushed the feature/tms-expand-cron-enqueue-13984 branch from cf19220 to 79721f8 Compare October 20, 2026 08:43
@lasdf1234
lasdf1234 marked this pull request as draft October 20, 2026 08:43
Complete policy→cron-job fan-out: expand catalog/schema tag attachments,
keep tables where this policy is the nearest BuiltInType winner, validate
crontab before enqueue, and remove one-shot cron rows after the deferred
submit callback so later expands can re-schedule.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lasdf1234 lasdf1234 changed the title [#13984] feat(tms): Expand policy-expand leases into cron-job rows [#13984] feat(tms): Expand policy-expand into cron-job rows (nearest-policy) Oct 20, 2026
lasdf1234 and others added 4 commits October 20, 2026 17:14
Skip cron-job row writes when OccupancyGate reports in-flight or within
the resolved cooldown (policy minIntervalMs → server conf → type default).

Co-authored-by: Cursor <cursoragent@cursor.com>
…icts

Treat multiple same BuiltInType policies on the nearest object as a
conflict: skip the table, log error, do not pick min(policy id).

Co-authored-by: Cursor <cursoragent@cursor.com>
Apply OccupancyGate while scanning nearest-policy winners so cooldown
or in-flight tables do not consume enqueueBatchSize and starve later
tables.

Co-authored-by: Cursor <cursoragent@cursor.com>
For ICEBERG_SNAPSHOT_EXPIRATION, merge enqueueable tables whose nearest
winner is schema/catalog into one batch:{hash}:{policyId} row with
CronJobData table ids; table-level winners stay per-table.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lasdf1234

Copy link
Copy Markdown
Collaborator Author

Superseded by #14019 — expand/cron enqueue (including snapshot-expiry batching and incomplete-batch fill) continues there.

@lasdf1234 lasdf1234 closed this Oct 20, 2026
@github-actions

Copy link
Copy Markdown

Code Coverage Report

Overall Project 71.81% 🟢
Files changed 71.84% 🟢

Module Coverage
aliyun 19.74% 🔴
api 54.37% 🟢
authorization-common 85.96% 🟢
authorization-ranger 14.44% 🔴
aws 53.54% 🟢
aws-bundle 0.0% 🔴
azure 32.1% 🔴
azure-bundle 0.0% 🔴
catalog-common 29.49% 🔴
catalog-fileset 82.37% 🟢
catalog-glue 73.24% 🟢
catalog-hive 83.63% 🟢
catalog-jdbc-common 57.98% 🟢
catalog-jdbc-doris 87.56% 🟢
catalog-jdbc-mysql 81.91% 🟢
catalog-jdbc-postgresql 84.02% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 75.21% 🟢
catalog-lakehouse-generic 84.58% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.93% 🟢
catalog-lakehouse-paimon 84.36% 🟢
catalog-model 77.99% 🟢
cli 44.62% 🟢
client-java 79.34% 🟢
client-java-runtime 0.0% 🔴
common 60.24% 🟢
core 87.51% 🟢
filesystem-hadoop3 76.89% 🟢
flink 55.44% 🟢
flink-common 32.2% 🔴
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 17.84% 🔴
hive-metastore-common 62.3% 🟢
hive-metastore3-libs 58.8% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 66.53% 🟢
iceberg-rest-server 77.08% 🟢
idp-basic 86.77% 🟢
integration-test-common 0.0% 🔴
jobs 71.35% 🟢
k8s-job-executor 99.81% 🟢
lance-common 39.9% 🔴
lance-rest-server 69.51% 🟢
lineage 59.39% 🟢
optimizer 84.27% 🟢
optimizer-api 46.58% 🟢
server 91.43% 🟢
server-common 83.85% 🟢
spark 61.79% 🟢
tencent 81.78% 🟢
tms 77.83% -7.28% 🟢
trino-connector 63.31% 🟢
Files
Module File Coverage
tms NearestPolicyDecision.java 100.0% 🟢
PolicyExpandPipeline.java 93.1% 🟢
CronJobIds.java 84.62% 🟢
PolicyExpandCrons.java 80.0% 🟢
NearestMaintenancePolicyResolver.java 77.46% 🟢
RelationalCronJobScheduler.java 76.81% 🟢
NearestPolicyTableEnumerator.java 76.8% 🟢
TableMaintenanceSchedulerPools.java 72.0% 🟢
ExpandTableCandidate.java 52.94% 🔴
CronJobData.java 33.33% 🔴
TableMaintenanceRESTFeature.java 26.32% 🔴
RelationalPolicyLookup.java 7.69% 🔴
CronJobScheduler.java 0.0% 🔴
ExpandOccupancyGate.java 0.0% 🔴
PolicyLookup.java 0.0% 🔴
PolicyTableEnumerator.java 0.0% 🔴

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