Skip to content

[server] Add TableLifecycleThrottler to throttle drops in coordinator queue - #3174

Merged
swuferhong merged 7 commits into
apache:mainfrom
swuferhong:remove-drop-part-jett
Jun 11, 2026
Merged

swuferhong merged 7 commits into
apache:mainfrom
swuferhong:remove-drop-part-jett

Conversation

@swuferhong

@swuferhong swuferhong commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #3173

Cascading dropTable / dropPartition used to push DropPartitionEvent and DropTableEvent into the coordinator event queue directly from TableChangeWatcher (and via TableManager#resumeDeletions on startup).
A single drop spanning thousands of partitions / stale tables would flood the queue with drop events and starve unrelated coordinator work.

So this pr introduce ReplicaCleanupManager uses a FIFO queue with a per-batch bucket budget (coordinator.replica-cleanup.max-buckets-per-batch, default 10000). Drops are admitted as long as the running sum
of in-flight buckets stays within budget. A starvation guard ensures that when nothing is in-flight, even an over-budget drop is admitted alone. Completion callbacks from TableManager release the budget and trigger the next batch.

Two submission paths:

    1. Watcher path: TableChangeWatcher NODE_DELETED → submitPartitionDrop/submitTableDrop → buffers a DropPartitionEvent/DropTableEvent for the coordinator event queue
    1. Startup resume path: TableManager.resumeDeletions() → submitPartitionDropForResume/submitTableDropForResume → executes a Runnable that drives
      onDeletePartition/onDeleteTable directly (bypasses event queue since TableInfo may already be gone)

Brief change log

Tests

API and Format

Documentation

@swuferhong
swuferhong force-pushed the remove-drop-part-jett branch from 8369aee to af71f36 Compare May 20, 2026 11:59
@swuferhong swuferhong changed the title [server] Fix auto partition drop delayed by DAY creation jitter [server] Throttle auto-partition drop to protect coordinator queue May 20, 2026
@luoyuxia
luoyuxia requested a review from Copilot May 21, 2026 08:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #3173 by ensuring auto-partition retention cleanup is evaluated against the actual current time (not the DAY creation jitter), and adds throttling/backpressure to prevent large bursts of partition-drop work from flooding the coordinator event queue during rotation boundaries.

Changes:

  • Fix retention cleanup timing by using the real “now” instant for partition drops (decoupled from DAY creation jitter).
  • Add adaptive drop throttling: a queue-size backpressure gate plus a per-round shared drop budget (with a starvation guard).
  • Expose coordinator event queue size for backpressure, add tests for the new behavior, and document the new configuration options.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
website/docs/table-design/data-distribution/partitioning.md Documents cluster-level auto-partition drop throttling/backpressure behavior and new config knobs.
website/docs/maintenance/configuration.md Adds the new auto-partition drop throttling/backpressure configuration options to the config reference.
fluss-server/src/test/java/org/apache/fluss/server/coordinator/AutoPartitionManagerTest.java Adds tests covering “drop not delayed by jitter” and multiple throttle/budget scenarios.
fluss-server/src/main/java/org/apache/fluss/server/coordinator/event/CoordinatorEventManager.java Adds a queue size accessor used for queue-aware backpressure.
fluss-server/src/main/java/org/apache/fluss/server/coordinator/CoordinatorServer.java Wires AutoPartitionManager with a late-bound coordinator queue size probe.
fluss-server/src/main/java/org/apache/fluss/server/coordinator/AutoPartitionManager.java Implements queue-aware backpressure gate, per-round drop budget, and uses real-time “now” for drops.
fluss-common/src/main/java/org/apache/fluss/config/ConfigOptions.java Introduces new config options controlling drop backpressure threshold and per-round drop budget.
Comments suppressed due to low confidence (1)

fluss-server/src/main/java/org/apache/fluss/server/coordinator/AutoPartitionManager.java:606

  • In the PartitionNotExistException path, the code logs that the partition doesn't exist but then still proceeds as if it was deleted (iterator removal, incrementing dropped/bucketsConsumed, and logging "deleted"). This can incorrectly consume the per-round bucket budget and may stop further legitimate drops in the same round. Consider treating PartitionNotExistException as a no-op: remove it from the in-memory set/map but do not increment bucketsConsumed/dropped and do not log it as deleted.
                try {
                    metadataManager.dropPartition(
                            tablePath,
                            ResolvedPartitionSpec.fromPartitionName(partitionKeys, partitionName),
                            false);
                } catch (PartitionNotExistException e) {
                    LOG.info(
                            "Auto partitioning skip to delete partition {} for table [{}] as the partition is not exist.",
                            partitionName,
                            tablePath);
                }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@platinumhamburg platinumhamburg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the designed mechanism is somewhat complex and has quite a few configuration variables. Could we simplify the implementation so that doAutoPartition() maintains a PendingDeletePartition set, and an asynchronous deletion thread polls this set, following these rules:

Only delete one partition at a time;
Skip whenever CoordinatorEventQueue is not empty;
The thread can poll the event queue every few seconds to look for a deletion opportunity.

@swuferhong
swuferhong force-pushed the remove-drop-part-jett branch from af71f36 to abc8a62 Compare May 26, 2026 05:39
@swuferhong swuferhong changed the title [server] Throttle auto-partition drop to protect coordinator queue [server] Add ReplicaCleanupManager to throttle drops in coordinator queue May 26, 2026
@swuferhong
swuferhong force-pushed the remove-drop-part-jett branch from abc8a62 to 52b7716 Compare May 26, 2026 05:54
@swuferhong

Copy link
Copy Markdown
Contributor Author

It seems that the designed mechanism is somewhat complex and has quite a few configuration variables. Could we simplify the implementation so that doAutoPartition() maintains a PendingDeletePartition set, and an asynchronous deletion thread polls this set, following these rules:

Only delete one partition at a time; Skip whenever CoordinatorEventQueue is not empty; The thread can poll the event queue every few seconds to look for a deletion opportunity.

Hi @platinumhamburg. The previous design was a bit complex and not general enough (e.g. it didn't really cover user-submitted batch drops of tables or partitions), so the new PR abstracts a common class as a throttling queue for replica drop events. Mind taking another look when you have a moment? Thanks a lot!

@platinumhamburg platinumhamburg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The tableBucketCount cache might have a leak, but it is bounded, and its memory usage is not high, so it's acceptable.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

@swuferhong
swuferhong force-pushed the remove-drop-part-jett branch from 52b7716 to 36295be Compare June 2, 2026 01:41

@luoyuxia luoyuxia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swuferhong Thanks for the pr.
I feel this design is a bit complex and easy to get wrong. It introduces three new configs, and the semantics of these configs are not very intuitive for users/operators.

Most of the complexity seems to come from the bucket-based budget (coordinator.replica-cleanup.max-buckets-per-batch): we need to resolve bucket counts, track in-flight buckets, release budget on completion, handle timeout/abandonment, and make the resume path go through the same accounting.

Do we really need bucket-level throttling here? The main issue we want to solve is that a large cascading drop can enqueue too many DropTable/DropPartition events into the coordinator event processor. A simpler approach could be to limit the number of drop events admitted into the coordinator event processor per batch/drain. That would still address most event-queue flooding cases, while avoiding bucket-count lookup, bucket-budget accounting, timeout configs, and a lot of the lifecycle complexity.

@swuferhong
swuferhong force-pushed the remove-drop-part-jett branch 2 times, most recently from ea7d8f5 to 352b0b6 Compare June 3, 2026 12:17
@swuferhong

Copy link
Copy Markdown
Contributor Author

Hi @luoyuxia, comments addressed. I still exposed the timeout ms parameter as config option, because ITCases share a single coordinator, and some drop events do return slowly during tests, so the timeout interval needs to be reduced for testing purposes.

@wuchong wuchong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @swuferhong , I left some comments.

@swuferhong
swuferhong force-pushed the remove-drop-part-jett branch from d720536 to 9a787d4 Compare June 9, 2026 09:09
@swuferhong swuferhong changed the title [server] Add ReplicaCleanupManager to throttle drops in coordinator queue [server] Add TableLifecycleThrottler to throttle drops in coordinator queue Jun 9, 2026
@swuferhong
swuferhong force-pushed the remove-drop-part-jett branch from 9a787d4 to 005220d Compare June 9, 2026 11:46
@swuferhong

Copy link
Copy Markdown
Contributor Author

@wuchong comments addressed.

@swuferhong
swuferhong force-pushed the remove-drop-part-jett branch from 005220d to 13640bd Compare June 10, 2026 06:39

@wuchong wuchong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appended a commit to improve the code a bit, please take another look.

@swuferhong

Copy link
Copy Markdown
Contributor Author

LGTM +1

@swuferhong
swuferhong merged commit fa091e8 into apache:main Jun 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[server] Auto partition retention cleanup delayed by DAY partition creation jitter

5 participants