Skip to content

[core] Validate watermark-based tag names before publishing snapshots - #11302

Open
taoran92 wants to merge 1 commit into
apache:masterfrom
taoran92:fix/automatic-tag-watermark-11301
Open

taoran92 wants to merge 1 commit into
apache:masterfrom
taoran92:fix/automatic-tag-watermark-11301

Conversation

@taoran92

@taoran92 taoran92 commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Fixes #11301.

Purpose

With tag.automatic-creation=watermark, a Flink batch write can publish a snapshot before tag creation fails. For example, passing epoch microseconds to end-input.watermark can produce an hourly tag in year 56664. Later writes inherit that watermark even when they supply the correct millisecond value.

When a write first sets or advances the watermark, the Java commit path rejects it before publishing the snapshot if it could produce a tag whose year cannot be formatted. The error message asks for epoch milliseconds. The first tag for that watermark must have a four-digit year under the configured period and time zone, even if an existing tag would let a running maintainer apply its creation delay. With automatic completion enabled, the latest tag that could be due after the delay must also fit. The check covers write-only writers with a separate tag maintainer. The Flink option description also specifies epoch milliseconds.

Scope

This PR covers the decision to publish a snapshot and documents the unit of Flink's end-input.watermark option. Changes to manual tag operations (create, rename, replace, or delete), automatic tag creation and backfilling, retention and expiration policies, and recovery after a restart belong in separate PRs.

For example, accepting a watermark because an existing tag makes the delayed boundary printable would require the writer to know which tags and snapshots will survive until a separate maintainer runs. That would couple snapshot publication to retention and recovery. Likewise, resuming a custom period at the exact second or fraction of a second after a restart would require storing progress more precisely than the minute recorded in the tag name.

Tests

Two core regression tests cover recovery on the next valid write and the completion boundary for a write-only writer with a separate maintainer. With Flink 1.20.3 batch SQL, the rejected input 1726000000000000 left the table without a snapshot. The next input, 1726003600000, created snapshot 1 and the UTC hourly tag 2024-09-10 20.

@taoran92
taoran92 marked this pull request as ready for review November 20, 2026 11:55
@taoran92
taoran92 force-pushed the fix/automatic-tag-watermark-11301 branch from 2a5a535 to bb0f4fe Compare November 20, 2026 12:57
@taoran92 taoran92 changed the title [core] A microsecond end-input.watermark can cause automatic tag creation to fail on later writes [core] Validate watermark-based tag names before publishing snapshots Nov 20, 2026

@JingsongLi JingsongLi 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.

The primary fix has end-to-end value. All 27 Core tag tests and four existing Flink 1.20.1 watermark tests passed locally. An additional Flink SQL case confirmed that the default writer rejects the invalid first watermark before publishing a snapshot and creates the expected tag on the next valid write. Two supported configurations still reproduce the poisoned watermark in Flink SQL.

@taoran92
taoran92 force-pushed the fix/automatic-tag-watermark-11301 branch 3 times, most recently from 6cd7c55 to 42eeb06 Compare November 21, 2026 03:58
@taoran92

Copy link
Copy Markdown
Member Author

@JingsongLi CI is green and comments are addressed. Another look when you have a chance? Thanks!

@JingsongLi JingsongLi 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.

The two previous cases pass on this revision. All 46 cases in TagAutoManagerTest and TagPeriodHandlerTest passed locally.

@taoran92
taoran92 force-pushed the fix/automatic-tag-watermark-11301 branch from 9ceffaf to 5aeb6fa Compare November 23, 2026 03:36

@JingsongLi JingsongLi 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.

The revised head passed 51 Core tag tests and four Flink end-input watermark tests, including the two previously reported restored-boundary and first-usable-watermark cases. I found one remaining write-only configuration where the validator accepts a snapshot the separate tag maintainer cannot process.

@taoran92
taoran92 force-pushed the fix/automatic-tag-watermark-11301 branch 4 times, most recently from a16f7b1 to 3f7fc7d Compare November 24, 2026 04:07
@taoran92

taoran92 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member Author

@JingsongLi

This PR is limited to validating new or advancing watermarks before snapshot publication. With watermark-based automatic tags enabled, the writer rejects a value that could produce an unformattable tag year and asks for epoch milliseconds. This fix stands on its own because it prevents later writes from inheriting a bad watermark and addresses reported cases.

Changes to tag creation, expiration, retention, and restart recovery belong in separate PRs, including exact recovery of custom periods to the second or higher precision (Without that scope boundary, interactions among these features would bring many additional concerns into the review and leave the PR without a clear completion criterion.).

If you have time, PTAL, thanks!

@taoran92
taoran92 force-pushed the fix/automatic-tag-watermark-11301 branch from a388232 to 129e39b Compare November 24, 2026 05:25
@taoran92
taoran92 force-pushed the fix/automatic-tag-watermark-11301 branch from 129e39b to c1afc41 Compare November 24, 2026 10:15
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.

[Bug] An out-of-range tag year can prevent automatic tag creation on later writes

2 participants