IMPALA-15076: Fix JDBC scan duplication in UNION ALL and ResultSet race

After IMPALA-14523 patch (shared JDBC cursor fetching), UNION ALL
queries with JDBC tables produced incorrect results due to
duplicate table scans. The scheduler assigned each JDBC scan node to a
different executor based on node_id, causing UNPARTITIONED union
fragments to spawn instances on multiple executors. Each instance would
execute all scan nodes in the union, but only one had assigned ranges,
leading to 3x result duplication in queries.

The fix changes JDBC executor selection to hash fragment_idx instead of
node_id, ensuring all JDBC scans within a union fragment are co-located
on the same executor. This preserves the shared connection optimization
while preventing duplicate reads.

Additionally, fixed a race condition in JdbcRecordIterator where multiple
threads could call ResultSet.next() after end-of-stream. Per JDBC spec,
this behavior is vendor-specific for TYPE_FORWARD_ONLY result sets and
may throw SQLException. Added an endOfStream flag guarded by fetchLock
to prevent post-EOS next() calls.

Testing:
- Core TPC-DS JDBC tests now pass
- All tests passed with exhaustive exploration strategy using release build
- Added JDBC UNION ALL planner tests

Change-Id: I60ed011faa2177af67ea681c2cd2967648e4a963
Reviewed-on: http://gerrit.cloudera.org:8080/24464
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
7 files changed
tree: 80e9f6895c748676675eddb9a783a692d00c3dad
  1. .devcontainer/
  2. be/
  3. bin/
  4. cmake_modules/
  5. common/
  6. docker/
  7. docs/
  8. fe/
  9. helm/
  10. infra/
  11. java/
  12. lib/
  13. package/
  14. security/
  15. shell/
  16. ssh_keys/
  17. testdata/
  18. tests/
  19. www/
  20. .asf.yaml
  21. .clang-format
  22. .clang-tidy
  23. .gitattributes
  24. .gitignore
  25. .isort.cfg
  26. AGENTS.md
  27. buildall.sh
  28. CMakeLists.txt
  29. EXPORT_CONTROL.md
  30. LICENSE.txt
  31. LOGS.md
  32. NOTICE.txt
  33. README-build.md
  34. README.md
  35. SECURITY.md
  36. setup.cfg
README.md

Welcome to Impala

Lightning-fast, distributed SQL queries for petabytes of data stored in open data and table formats.

Impala is a modern, massively-distributed, massively-parallel, C++ query engine that lets you analyze, transform and combine data from a variety of data sources:

More about Impala

The fastest way to try out Impala is a quickstart Docker container. You can try out running queries and processing data sets in Impala on a single machine without installing dependencies. It can automatically load test data sets into Apache Kudu and Apache Parquet formats and you can start playing around with Apache Impala SQL within minutes.

To learn more about Impala as a user or administrator, or to try Impala, please visit the Impala homepage. Detailed documentation for administrators and users is available at Apache Impala documentation.

If you are interested in contributing to Impala as a developer, or learning more about Impala's internals and architecture, visit the Impala wiki.

Supported Platforms

Impala only supports Linux at the moment. Impala supports x86_64 and arm64 (as of Impala 4.4). Impala Requirements contains more detailed information on the minimum CPU requirements.

Supported OS Distributions

Impala runs on Linux systems only. The supported distros are

  • Ubuntu 20.04/22.04/24.04
  • Rocky/RHEL 8/9

Other systems, e.g. SLES15, may also be supported but are not tested by the community.

Export Control Notice

This distribution uses cryptographic software and may be subject to export controls. Please refer to EXPORT_CONTROL.md for more information.

Build Instructions

See Impala's developer documentation to get started.

Detailed build notes has some detailed information on the project layout and build.