Repository navigation
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Fuzzer failed during an unrelated change - https://github.com/apache/datafusion/actions/runs/15741542523/job/44367876525?pr=16449.
Not sure how long GitHub retains logs, so I'm also adding the actual output:
---- fuzz_cases::sort_query_fuzz::sort_query_fuzzer_runner stdout ----
[SortQueryFuzzer] Round 0, Query 0 (Config 0)
Seeds:
init_seed = 10313160656544581998
query_seed = 9760675044397831413
config_seed = 2456252688354296803
Dataset schema:
[u8_low:UInt8;N, binary:Binary;N, timestamp_us:Timestamp(Microsecond, None);N, time64_ns:Time64(Nanosecond);N, u8:UInt8;N, i32:Int32;N, duration_nanosecond:Duration(Nanosecond);N, utf8_low:Utf8;N, duration_milliseconds:Duration(Millisecond);N]
Query:
SELECT * FROM sort_fuzz_table ORDER BY time64_ns ASC
Config:
Dataset size: 286.6 KB
Number of partitions: 3
Batch size: 6
Memory limit: Unbounded
Per partition memory limit: Unbounded
Sort spill reservation bytes: 48.4 KB
Sort in place threshold bytes: 2.3 KB
[SortQueryFuzzer] Round 0, Query 0 (Config 1)
Seeds:
init_seed = 10313160656544581998
query_seed = 9760675044397831413
config_seed = 13112719340419033750
Dataset schema:
[u8_low:UInt8;N, binary:Binary;N, timestamp_us:Timestamp(Microsecond, None);N, time64_ns:Time64(Nanosecond);N, u8:UInt8;N, i32:Int32;N, duration_nanosecond:Duration(Nanosecond);N, utf8_low:Utf8;N, duration_milliseconds:Duration(Millisecond);N]
Query:
SELECT * FROM sort_fuzz_table ORDER BY time64_ns ASC
Config:
Dataset size: 286.6 KB
Number of partitions: 3
Batch size: 6
Memory limit: Unbounded
Per partition memory limit: Unbounded
Sort spill reservation bytes: 42.3 KB
Sort in place threshold bytes: 3.7 KB
[SortQueryFuzzer] Round 0, Query 0 (Config 2)
Seeds:
init_seed = 10313160656544581998
query_seed = 9760675044397831413
config_seed = 11553131583763959573
Dataset schema:
[u8_low:UInt8;N, binary:Binary;N, timestamp_us:Timestamp(Microsecond, None);N, time64_ns:Time64(Nanosecond);N, u8:UInt8;N, i32:Int32;N, duration_nanosecond:Duration(Nanosecond);N, utf8_low:Utf8;N, duration_milliseconds:Duration(Millisecond);N]
Query:
SELECT * FROM sort_fuzz_table ORDER BY time64_ns ASC
Config:
Dataset size: 286.6 KB
Number of partitions: 3
Batch size: 6
Memory limit: Unbounded
Per partition memory limit: Unbounded
Sort spill reservation bytes: 21.4 KB
Sort in place threshold bytes: 486.0 B
[SortQueryFuzzer] Round 0, Query 0 (Config 3)
Seeds:
init_seed = 10313160656544581998
query_seed = 9760675044397831413
config_seed = 7181[2061](https://github.com/apache/datafusion/actions/runs/15741542523/job/44367876525?pr=16449#step:4:2062)06220866377
Dataset schema:
[u8_low:UInt8;N, binary:Binary;N, timestamp_us:Timestamp(Microsecond, None);N, time64_ns:Time64(Nanosecond);N, u8:UInt8;N, i32:Int32;N, duration_nanosecond:Duration(Nanosecond);N, utf8_low:Utf8;N, duration_milliseconds:Duration(Millisecond);N]
Query:
SELECT * FROM sort_fuzz_table ORDER BY time64_ns ASC
Config:
Dataset size: 286.6 KB
Number of partitions: 3
Batch size: 6
Memory limit: Unbounded
Per partition memory limit: Unbounded
Sort spill reservation bytes: 43.8 KB
Sort in place threshold bytes: 3.2 KB
[SortQueryFuzzer] Round 0, Query 0 (Config 4)
Seeds:
init_seed = 10313160656544581998
query_seed = 9760675044397831413
config_seed = 17269272874247070475
Dataset schema:
[u8_low:UInt8;N, binary:Binary;N, timestamp_us:Timestamp(Microsecond, None);N, time64_ns:Time64(Nanosecond);N, u8:UInt8;N, i32:Int32;N, duration_nanosecond:Duration(Nanosecond);N, utf8_low:Utf8;N, duration_milliseconds:Duration(Millisecond);N]
Query:
SELECT * FROM sort_fuzz_table ORDER BY time64_ns ASC
Config:
Dataset size: 286.6 KB
Number of partitions: 3
Batch size: 6
Memory limit: Unbounded
Per partition memory limit: Unbounded
Sort spill reservation bytes: 45.0 KB
Sort in place threshold bytes: 2.3 KB
[SortQueryFuzzer] Round 0, Query 1 (Config 0)
Seeds:
init_seed = 10313160656544581998
query_seed = 15004039071976572201
config_seed = 11807432710583113300
Dataset schema:
[u8_low:UInt8;N, binary:Binary;N, timestamp_us:Timestamp(Microsecond, None);N, time64_ns:Time64(Nanosecond);N, u8:UInt8;N, i32:Int32;N, duration_nanosecond:Duration(Nanosecond);N, utf8_low:Utf8;N, duration_milliseconds:Duration(Millisecond);N]
Query:
SELECT * FROM sort_fuzz_table ORDER BY timestamp_us DESC LIMIT 3
Config:
Dataset size: 286.6 KB
Number of partitions: 3
Batch size: 6
Memory limit: Unbounded
Per partition memory limit: Unbounded
Sort spill reservation bytes: 25.8 KB
Sort in place threshold bytes: 2.8 KB
[SortQueryFuzzer] Round 0, Query 1 (Config 1)
Seeds:
init_seed = 10313160656544581998
query_seed = 15004039071976572201
config_seed = 759937414670321802
Dataset schema:
[u8_low:UInt8;N, binary:Binary;N, timestamp_us:Timestamp(Microsecond, None);N, time64_ns:Time64(Nanosecond);N, u8:UInt8;N, i32:Int32;N, duration_nanosecond:Duration(Nanosecond);N, utf8_low:Utf8;N, duration_milliseconds:Duration(Millisecond);N]
Query:
SELECT * FROM sort_fuzz_table ORDER BY timestamp_us DESC LIMIT 3
Config:
Dataset size: 286.6 KB
Number of partitions: 3
Batch size: 6
Memory limit: Unbounded
Per partition memory limit: Unbounded
Sort spill reservation bytes: 47.4 KB
Sort in place threshold bytes: 2.5 KB
thread 'fuzz_cases::sort_query_fuzz::sort_query_fuzzer_runner' panicked at datafusion/core/tests/fuzz_cases/sort_query_fuzz.rs:232:71:
called `Result::unwrap()` on an `Err` value: InconsistentResult { row_idx: 0, lhs_row: "+--------+--------------------------------------+--------------+---------------------------------------------------------------------------------------------+-----+-----------+-------------------------+-------------+-------------------------+", rhs_row: "+--------+------------------------------------------------+--------------+---------------------------------------------------------------------------------------------+-----+-------------+--------------------------+-------------+--------------------------+" }
To Reproduce
No response
Expected behavior
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
2010YOUY01 commentedon Jun 19, 2025
Thanks for reporting!
This failure should be reproducable byI didn't check it carefully and this reproducer is incorrect...See #16452 (comment) for the correct reproducer.However, I’ve run it several times and it always passes.
This could be either:
AdamGS commentedon Jun 19, 2025
I got a very similar failure in #16447 - https://github.com/apache/datafusion/actions/runs/15744174093/job/44376646866?pr=16447
Thanks for the repro! I'll try and spend some time hacking on it to see if I can reproduce it, maybe trying out
loomwill help[-]SortQueryFuzzer found a failing case[/-][+]SortQueryFuzzer found a failing case on main[/+]alamb commentedon Jun 19, 2025
Perhaps this is related to the recent work from @adriangb with topk limit pushdown (once we figure out how to reliably reproduce it, we can verify by turning off the feature)
AdamGS commentedon Jun 19, 2025
I've built a repro that fails consistently, and the most interesting part of it is that when using the default test runtime (which is a tokio current thread variant), the test passes.
It only fails with the multithreaded runtime which makes me think this is indeed a tokio futures interleaving issue. I'll give it some more time later tonight.
adriangb commentedon Jun 19, 2025
Btw to disable the new topk changes you can set
datafusion.optimizer.enable_dynamic_filter_pushdown = falseAdamGS commentedon Jun 19, 2025
Some more findings:
datafusion.optimizer.enable_dynamic_filter_pushdowndoesn't seem to make a differencequery_seed, it doesn't reproduce every time with it but changing it seems to make it to not reproduce in a reasonable time. The query it generates is:with
interval_month_day_nano's being a nullableInterval(MonthDayNano).I also took a deeper look at the actual data and noticed some surprising things that might explain the failure:
null, which makes me think there's a sort stability issue here (the implementation ofcheck_equality_of_batchesalso points in that direction).Cast error: Failed to convert -6727098022243200000 to temporal for Date64I wonder if what's happening all comes down to an unstable sort + when running on a multithreaded runtime events interleave in different ways which result in different overall outcomes.
adriangb commentedon Jun 19, 2025
I think this is a reproducer? https://github.com/apache/datafusion/actions/runs/15764484967/job/44438090077?pr=16461
adriangb commentedon Jun 19, 2025
@Dandandan I wonder if it's the filtering being done inside of the TopK?
@AdamGS could you try commenting out these lines?
datafusion/datafusion/physical-plan/src/topk/mod.rs
Lines 217 to 251 in 2d7ae09
AdamGS commentedon Jun 19, 2025
that indeed makes the failure to go away
adriangb commentedon Jun 19, 2025
Let's merge that ASAP. I'm AFK for the next two hours? Could you prepare a PR by chance?
Fuzzer-based reproduction and a temporary fix for apache#16452
AdamGS commentedon Jun 19, 2025
done - https://github.com/apache/datafusion/pull/16465/files
blaginin commentedon Jun 20, 2025
For transparency, @alamb noticed another failure: https://github.com/apache/datafusion/actions/runs/15780623790/job/44485106315
alamb commentedon Jun 20, 2025
Right -- so in summary
sort_query_fuzzer_runner(#16462)" #16470sort_query_fuzzer_runneragain: Reapply "Ignoresort_query_fuzzer_runner(#16462)" (#16470) #16485adriangb commentedon Jun 20, 2025
I'm continuing to investigate. Unfortunately this is very flaky and slow to test and I've run out of time for today. I will continue tomorrow morning.
adriangb commentedon Jun 21, 2025
I can confirm it's related to #15770. It seems like there may be multiple errors. This is one I found tonight:
But if I comment out
update_filters()there are no failures. I think theupdate_filters()function may be the culprit of all of the evils and it's manifesting via some sort of unstable sort / mishandling of nulls and this other random bug with Display for Date64.Bizarre... will keep pushing to find a root cause and see if we can address it. If I can't get it sorted over the weekend @alamb I'd propose we revert the TopK specific part of that PR to unblock the rest of the project.
alamb commentedon Jun 21, 2025
Sounds good -- thank you for the investigation @adriangb
adriangb commentedon Jun 21, 2025
So yeah that's a trivially reproducible bug that is completely unrelated to this mess but I guess just happens to be hit by the new code paths:
Panics because it calls:
https://github.com/apache/arrow-rs/blob/1ededfe024e6da1dd08bd0aee9411d1fb04523ac/arrow-array/src/types.rs#L1036
Which by as per the documentation will panic:
https://github.com/chronotope/chrono/blob/bab97905ccfa5aa7ceae1ee131b41b7113ea4f6a/src/naive/date/mod.rs#L1876-L1877
adriangb commentedon Jun 21, 2025
This is actually the same error that @blaginin reported in #16452 (comment): https://github.com/apache/datafusion/actions/runs/15780623790/job/44485106315#step:4:1382
adriangb commentedon Jun 21, 2025
#16491 now has the fix!
alamb commentedon Jun 22, 2025
We think we have fixed this in
sort_query_fuzzer_runner#16491Let's keep this PR open until
adriangb commentedon Jun 22, 2025
I think that part may have its own issues!