Skip to content

[flink] Stop lookup matches when dynamic partition selection is empty - #11355

Open
zhangyue19921010 wants to merge 2 commits into
apache:masterfrom
zhangyue19921010:contrib/fix-empty-dynamic-lookup-partitions
Open

zhangyue19921010 wants to merge 2 commits into
apache:masterfrom
zhangyue19921010:contrib/fix-empty-dynamic-lookup-partitions

Conversation

@zhangyue19921010

Copy link
Copy Markdown
Contributor

Purpose

Dynamic lookup joins keep returning cached rows after the last selected partition is removed. Return no matches when the refreshed partition selection is empty, while retaining the existing asynchronous cache switch for nonempty selections.

Fixes #11354.

Tests

  • Real-table regression for full, memory, and automatic lookup caches, including synchronous/asynchronous partition refresh and recreating the same partition with new values. All five cases fail on the unchanged master base and pass with the fix.
  • FileStoreLookupFunctionTest and PartitionRefresherTest (22 tests).
  • Existing asynchronous partition-refresh SQL integration test and writer, committer, config-refresh, and split-reader controls (65 tests total), with Checkstyle, Spotless, and Enforcer enabled.

@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 original stale lookup reproduces in all five cases with the base lookup class. The patch passes all 25 selected Flink tests, including three SQL lookup join cases. I found a separate stale result on the empty-to-nonempty transition.

if (partitionLoader.partitions().isEmpty()) {
return Collections.emptyList();
}
List<BinaryRow> partitions =

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.

[P2] Keep the pre-drop cache invalid after the selection becomes empty. I extended the existing real-table regression with a check on the first lookup after recreating pt=1. The join returned no matches after the truncate, but the first lookup after writing (1, 2, 4) then returned the deleted value 3 in both async FULL and async MEMORY modes. The partition loader becomes nonempty and schedules a rebuild, while currentPartitions() still refers to the pre-truncate cache. Preserve the empty lookup state until a cache built after that empty selection is installed. The existing test waits for 4, which misses this interval.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 4976a0d: when the selection becomes empty, the refresher now clears its current partitions and drops async refreshes started before that, so lookups stay empty until a cache built after the empty selection is installed (the test now checks the first lookup after recreating pt=1).

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] Dynamic lookup returns cached rows after all selected partitions are removed

2 participants