Zoltan Borok-Nagy has uploaded this change for review. ( 
https://gerrit.cloudera.org/25634


Change subject: IMPALA-15902: Fix crash on a stale scratch batch in late 
materialization
......................................................................

IMPALA-15902: Fix crash on a stale scratch batch in late materialization

With late materialization, FilterScratchBatch() stops when the output
batch is full, so the scratch batch can still have tuples left
(0 < tuple_idx < num_tuples). AssembleRows() then materializes the
complete scratch batch for the non-filter readers. If one of them
returns false there, FillScratchMicroBatches() releases the scratch
batch with FlushRowGroupResources(), which sets tuple_mem to nullptr,
but it only resets a local copy of num_tuples. The next
GetNextInternal() then transfers the remaining tuples from
'nullptr + tuple_idx * tuple_byte_size', and the impalad crashes while
evaluating the conjuncts in ProcessScratchBatch().

Since IMPALA-3841 a collection reader can be a non-filter reader, and
AssembleCollection() returns false without setting an error when the
scan is cancelled: the query was cancelled, another scanner thread of
the scan node failed, or a LIMIT above the scan closed it. So any of
these can crash an impalad that scans a Parquet table with a
collection column that the scan's conjuncts do not reference.

This patch:
 - resets tuple_idx, num_tuples and num_tuples_transferred in
   ScratchTupleBatch::ReleaseResources(), so a scratch batch without
   tuple memory is always at its end.
 - makes AssembleCollection() report a cancellation as
   CANCELLED_INTERNALLY in 'parse_status_', as the scalar readers do,
   instead of silently skipping the rest of the row group.
 - adds a DCHECK that the scratch batch still has its tuple memory
   before its remaining tuples are transferred.
 - adds the debug action PARQUET_COLLECTION_IN_PARTIAL_SCRATCH_BATCH
   to AssembleCollection(). It is evaluated once per scanner, while
   0 < tuple_idx < num_tuples. FAIL makes AssembleCollection() return
   false without an error; SLEEP@ms lets a cancellation arrive.

Testing:
 - Added tests to test_parquet_late_materialization.py: the FAIL
   variant with mt_dop 0 and 2, and the SLEEP variant with an
   execution time limit. Without the fix both crash impalads.
 - Ran test_parquet_late_materialization.py.

Change-Id: Ic023cb0cc751d7342a37f9e37ec27182a0ee1120
Assisted-by: Claude Opus 5.5 (Claude Code)
---
M be/src/exec/parquet/hdfs-parquet-scanner.cc
M be/src/exec/parquet/hdfs-parquet-scanner.h
M be/src/exec/scratch-tuple-batch.h
M tests/query_test/test_parquet_late_materialization.py
4 files changed, 104 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/34/25634/1
--
To view, visit https://gerrit.cloudera.org/25634
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic023cb0cc751d7342a37f9e37ec27182a0ee1120
Gerrit-Change-Number: 25634
Gerrit-PatchSet: 1
Gerrit-Owner: Zoltan Borok-Nagy <[email protected]>

Reply via email to