Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-13443

distributed left joins errored with "java.lang.ClassCastException"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Blocker
    • Resolution: Unresolved
    • 2.8.1
    • None
    • h2-limitation, sql
    • 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:

      https://github.com/h2database/h2database/blob/c8a861bb1a3f04967ec40cb5e3336535c43af5fb/h2/src/main/org/h2/table/JoinBatch.java#L292

      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

      https://github.com/h2database/h2database/blob/c8a861bb1a3f04967ec40cb5e3336535c43af5fb/h2/src/main/org/h2/table/JoinBatch.java#L358

      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.

       

      Attachments

        1. JoinBatch.java
          35 kB
          Isaac Zhu

        Activity

          People

            Unassigned Unassigned
            nifeng2xing Isaac Zhu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: