-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: vectorized stats collectors can finish prematurely #56928
Description
I am working on aggregating row counts for EXPLAIN ANALYZE (PLAN) and ran into some flaky plans. I traced it down to some vectorized stat collectors being finished (i.e. OutputStats() being called) early.
I managed to figure out a repro using this patch (repro instructions in there too).
In an instance of the repro, we have this plan.
According to various printf sprinkled around the code, I saw that the collector for TableReader/2 is called before we even emit a batch from that processor. The issue is that the collectors for TableReader/2 and HashJoiner/6 are in the same finishVectorizedStatsCollectors list and will finish together. In this case, it's possible that TableReader/3 finished without producing any rows that go to HashJoiner/6 which caused that processor to finish execution.