Repository navigation
[flink] Stop lookup matches when dynamic partition selection is empty - #11355
zhangyue19921010 wants to merge 4 commits into
Conversation
JingsongLi
left a comment
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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).
JingsongLi
left a comment
There was a problem hiding this comment.
The five real-table cases for dropping and recreating the selected partition passed. I reproduced one more case with an asynchronous cache build still in flight when the partition selection became empty.
| if (refreshResult == null) { | ||
| return null; | ||
| } | ||
| if (refreshResult.generation != generation) { |
There was a problem hiding this comment.
[P2] Discard failures from obsolete refresh generations
The generation check covers completed caches. Exceptions still enter the shared partitionRefreshException slot without their generation and are thrown on the next lookup. I paused an async FULL cache rebuild on a real partitioned table, truncated both partitions, and verified the join returned no matches. I then injected FileNotFoundException in the obsolete rebuild. The next lookup threw that exception even though its selection was already empty. Carry the generation on the failure path as well, so current-generation failures still propagate and superseded rebuilds cannot fail a later lookup.
There was a problem hiding this comment.
Fixed in 76eaeb0: obsolete refresh errors are ignored; current-generation errors still propagate.
Purpose
Fixes #11354.
Dynamic lookup joins can keep returning cached rows after the last selected partition is removed. Keep lookups empty until a cache built after that empty selection is installed. Tag both asynchronous cache results and failures with their refresh generation, so an obsolete rebuild cannot restore stale rows or fail a later lookup. Current-generation failures still propagate.
Tests
Real-table regressions cover full, memory and automatic caches, synchronous/asynchronous partition refresh, and recreating the same partition. Four additional async FULL/MEMORY cases cover a rebuild failing after the selection is cleared and current-generation failures. The two obsolete-failure cases fail before the follow-up fix; both propagation controls pass.
FileStoreLookupFunctionTestandPartitionRefresherTest: 26 tests passed with the normal Maven quality checks (JDK 11, Flink 1.20.1).