[ASTERIXDB-2800] Added exception for in-mem join

    - user model changes: no
    - storage format changes: no
    - interface changes: no

    Details:
    - Exception is thrown if the record insertion in
    hash table of the in-memory hash join fails after
    compacting it.

Change-Id: I37e4b7209b5e9e31b9082f0ad04fbe611354da5f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/9045
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoin.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoin.java
index 4b1e4aa..cb63b6a 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoin.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoin.java
@@ -32,6 +32,7 @@
 import org.apache.hyracks.api.dataflow.value.ITuplePairComparator;
 import org.apache.hyracks.api.dataflow.value.ITuplePartitionComputer;
 import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
+import org.apache.hyracks.api.exceptions.ErrorCode;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
@@ -124,8 +125,10 @@
             storedTuplePointer.reset(bIndex, i);
             // If an insertion fails, then tries to insert the same tuple pointer again after compacting the table.
             if (!table.insert(entry, storedTuplePointer)) {
-                // TODO(ali): should check if insertion failed even after compaction and take action
-                compactTableAndInsertAgain(entry, storedTuplePointer);
+                if (!compactTableAndInsertAgain(entry, storedTuplePointer)) {
+                    throw HyracksDataException.create(ErrorCode.ILLEGAL_STATE,
+                            "Record insertion failed in in-memory hash join even after compaction.");
+                }
             }
         }
     }