Details
-
Bug
-
Status: Open
-
Blocker
-
Resolution: Unresolved
-
2.8.1
-
None
-
None
-
Docs Required, Release Notes Required
Description
This is actually an H2 1.4.197 Bug
When using distributed joins, SQL like this (table A and table B are not collocated, so distributed join is used here):
select * from table A left join table B on A.id = B.id left join table C on B.id = C.id where ...
has chance to error out at the second left join with a "java.lang.ClassCastException" when the first left join had an EmptyCursor
This is because, for distributed join, H2 JoinBatch is used - it seems JoinBatch is not used for collocated join.
In JoinBatch line 292:
It increases the filter ID to let the next fetchCurrent call resolve the "EMPTY_CURSOR" to a NullRow when a "JoinFilter.find" is not called.
Then, in the "find" call, the resolved NullRow will be updated to some cursor from the future - because only EmptyCursor is skipped in the find(), a NullRow will be updated again and the bitwise state goes wrong
This then causes the exception in "fetchCurrent" line: 358
The "x" is a Future, so it can't be cast to a Cursor - the state is wrong, the "isFuture" returns false while it is a Future.
I did a local fix in our server as a workaround in org.h2.table.JoinBatch, the changed code is attached.