Skip to content

[CORE] Preserve original Java exceptions across JNI (combined reference) - #13133

Merged
zhztheplayer merged 3 commits into
apache:mainfrom
felipepessoto:felipepessoto-jni-exception-preservation
Nov 26, 2026
Merged

zhztheplayer merged 3 commits into
apache:mainfrom
felipepessoto:felipepessoto-jni-exception-preservation

Conversation

@felipepessoto

@felipepessoto felipepessoto commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Historical reference — reverted. This combined PR was merged accidentally and reverted by #13812. The reviewed iterator changes landed separately in #13561 and are on main. The memory-callback changes have not landed; they are tracked in #13563.

What changes are proposed in this pull request?

Preserve original Java throwables through native execution instead of replacing them with exceptions reconstructed from text.

The reference and #13563 have the same commit 68cb0f83d673dab0129c781d5c788a0eb8086ceb and same complete tree c5682df7701327f0dd90a61c3262f4611b107f2c. The iterator dependency is 2bf1181f1177b683733ff7d22fd60dfbad7900fd; the chain is based on upstream main at 2011f60b96bb54164d76092bb5d2df9c6c01e3ac. This reference follows the reviewed layers rather than independently rebasing beyond them.

  • Inherit the merged backend-neutral JNI carrier, original-object restoration, worker-safe capture cleanup, pending-exception/fallback handling, and Java boundary tests from [CORE] Preserve Java throwables at the JNI boundary #13560.
  • Protect CPU/cuDF input callbacks, lazy output, and Velox/Arrow memory callbacks before native handlers can flatten Java exceptions. Runtime/system wrapping prevents TRY from suppressing callback failures; native-only errors and memory metrics retain their existing behavior.
  • Include native regressions, the Velox-only JNI suite, and six strict Delta CHECK/NOT NULL/replaceWhere cases. These verify original classes, structured metadata and causes, native execution, and no committed table changes after failed writes. JNI restores the original object; public iterator wrappers may retain it in their cause chain.
  • Match main's existing-GlutenException reuse policy in the nested-iterator regression: retain the bare throwable case, also exercise an already-translated wrapper, require the exact direct original cause in both, and require the same wrapper object for the translated input. No production behavior or metadata assertions were weakened.

The remaining upstream diff is 11 files, +1025/-22, containing the iterator and memory layers plus their tests/documentation. Merged core/CI code and the Delta known-failure baseline are not changed by this diff. No native cast classification from #13135, assertion weakening, missing-error ARRAY/MAP changes, partition-materialization dependency, or hybrid Java/C++ stack merging is included; this does not resolve #9642.

How was this patch tested?

This reference reuses #13563's evidence for the identical commit/tree; no separate reference runtime run was performed. Commit/tree equality and the unchanged memory-layer patch were verified before publication.

On the final memory-layer head, 18 current-source Delta cases passed with zero failures, errors, or skips: three GlutenDeltaStatsLifecycleSuite cases plus six strict GlutenDeltaNativeConstraintSuite cases on each of Spark 3.5/Scala 2.12 and Spark 4.1/Scala 2.13. These cover the newly inherited Delta statistics lifecycle changes, including cancellation/worker cleanup, aborted and multi-file statistics, alongside exact native-constraint exception identity and unchanged table commits.

The 16 JNI integration cases from the previous memory head, plus 22 native exception cases and 14 core JUnit bridge cases from earlier verified component runs, are reused evidence—not new executions. The unchanged JNI suite includes both memory callbacks and exact direct-cause/same-translated-wrapper assertions. Native/bridge inputs, dependency pin, and library hashes were unchanged; the native build check reported no work before Maven. Current Java builds, bundles, and required formatting/Scalastyle/license checks passed, and both bundles match the verified native hashes. All upstream Delta lifecycle, harness, CI, and known-failure baseline changes were retained.

The integration runs used Linux x86_64/JDK 17, normal two-library loading with -Xcheck:jni, the Maven wrapper, and IBM/velox dft-2026_11_10 (67fa1bbee62e9f8752b3c34cc92f179022cd2ac6). Existing JNI/thread warnings remain; older injected-failure and Surefire diagnostics belong to the reused bridge evidence. No new full Delta matrix, GPU, ARM/Kafka, or ClickHouse/Bolt runtime run, or green remote CI, is claimed.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: GitHub Copilot 1.0.102-0.unstable.r40949665530.gab1eef5 (GPT-6 Astra, model ID: gpt-6-astra)

@github-actions github-actions Bot added CORE works for Gluten Core VELOX DOCS labels Sep 25, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@felipepessoto

Copy link
Copy Markdown
Contributor Author

Regarding the bot comment: this is the automatically generated ClickHouse x86 CI trigger, not a code-review request, so no code change is needed. The trigger workflow already completed successfully for 7e977538f; I am avoiding a duplicate trigger and am not treating that workflow result as proof that the downstream tests passed.

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

1 similar comment
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Sep 25, 2026
Merge the exact lower-layer test corrections from apache#13133 (28f72ef), preserving the separate cast implementation and lint corrections without rewriting either draft history.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Sep 25, 2026
Merge exact lower-layer commit85fdfff8 from apache#13133 without rewriting history. The lazy-output test now supplies a valid UTC session timezone while retaining all throwable identity and lazy-loading assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@felipepessoto
felipepessoto force-pushed the felipepessoto-jni-exception-preservation branch from 85fdfff to fe9157e Compare October 30, 2026 22:49
@github-actions github-actions Bot added the BOLT label Oct 30, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Oct 30, 2026
Carry structured native cast attribution and UTF-8 diagnostics through the existing Java exception transport, then translate recognized cast reasons with Spark error factories. Preserve original causes, schema translation, unknown errors, and cast evaluation modes.

Add focused JVM, native-attribution, iterator, and Velox cast regressions. Depends on apache#13133 for the shared JNI throwable carrier.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Oct 31, 2026
Merge the verified apache#13133 dependency c272939, preserving backend-specific source registration and lint coverage without changing production code or rewriting either draft history.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

1 similar comment
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Oct 31, 2026
Merge exact lower-layer corrections through 0b6431d from apache#13133. Retain captured Java throwables after native diagnostic allocation failures and preserve memory callbacks through Velox and direct JNI boundaries. Cast classification and cast regression contents remain unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@felipepessoto

Copy link
Copy Markdown
Contributor Author

/delta-test

@github-actions

Copy link
Copy Markdown

🔄 Delta Spark UT started by @felipepessoto (~2.5 h). View run

@github-actions github-actions Bot added the INFRA label Oct 31, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions

Copy link
Copy Markdown

🔄 Delta Spark UT started by @felipepessoto (~2.5 h). View run

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Oct 31, 2026
Merge exact lower-layer baseline commit 684f7df from apache#13133. Remove only the 34 tests confirmed passing in Delta run 41188486128 and retain all 451 observed failures, including unresolved native casts and ARRAY/MAP no-throw cases.

Replaying the original eight JUnit shards with fail-on-fixed enabled passes every gate. This is baseline verification against lower-only results, not execution evidence for the upper native cast implementation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@felipepessoto
felipepessoto force-pushed the felipepessoto-jni-exception-preservation branch from 684f7df to f88c269 Compare October 31, 2026 21:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the Java throwable-preservation changes across Velox iterators and memory callbacks.

No open issues 🎉

Review effort: Balanced

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Nov 14, 2026
Split layer 2 of apache#13133, depending on apache#13560. Preserve the Java carrier through Velox input streams and lazy output loading, with focused native, real-JVM, and Delta constraint regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@felipepessoto
felipepessoto force-pushed the felipepessoto-jni-exception-preservation branch from 8ea3b66 to ddd98ec Compare November 14, 2026 21:00
Copilot AI balanced review requested due to automatic review settings November 14, 2026 21:00
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the changes preserving original Java throwables through Velox execution.

No open issues 🎉

Review effort: Balanced

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Nov 14, 2026
Carry structured native cast attribution and UTF-8 diagnostics through the existing Java exception transport, then translate recognized cast reasons with Spark error factories. Preserve original causes, schema translation, unknown errors, and cast evaluation modes.

Add focused JVM, native-attribution, iterator, and Velox cast regressions. Depends on apache#13133 for the shared JNI throwable carrier.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
felipepessoto and others added 3 commits November 17, 2026 11:55
Split layer 2 of apache#13133, depending on apache#13560. Preserve the Java carrier through Velox input streams and lazy output loading, with focused native, real-JVM, and Delta constraint regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the bare Java throwable case and verify the exact direct cause. Also exercise an already-translated GlutenException and require the same wrapper object through nested iterators, matching the upstream no-rewrap policy.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Wrap both Velox and Arrow allocation callbacks with the existing Java throwable carrier. Cover reserve/unreserve identity, allocator behavior, and delegated metrics without introducing a backend dependency into core JNI.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@felipepessoto
felipepessoto force-pushed the felipepessoto-jni-exception-preservation branch from ddd98ec to 68cb0f8 Compare November 17, 2026 20:34
Copilot AI balanced review requested due to automatic review settings November 17, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues

Review effort: Lite

Comment on lines +213 to +217
used -= size
if (failUnreserve) {
failures += 1
throw original
}
Comment on lines +260 to +262
val actual = intercept[Exception] {
out.hasNext0()
}
import java.io.PrintWriter
import java.util.{Collections, Iterator => JIterator}

import scala.collection.JavaConverters._
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Nov 23, 2026
Split layer 2 of apache#13133, depending on apache#13560. Preserve the Java carrier through Velox input streams and lazy output loading, with focused native, real-JVM, and Delta constraint regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Nov 24, 2026
Split layer 2 of apache#13133, depending on apache#13560. Preserve the Java carrier through Velox input streams and lazy output loading, with focused native, real-JVM, and Delta constraint regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@zhztheplayer
zhztheplayer merged commit fb443ac into apache:main Nov 26, 2026
88 checks passed
@felipepessoto

felipepessoto commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @zhztheplayer. This combined reference wasn't updated with the latest changes from #13561.

Can we quickly revert (before changes are made on top of it) and merge #13561 instead?

@felipepessoto

Copy link
Copy Markdown
Contributor Author

The revert PR: #13812

@zhztheplayer

Copy link
Copy Markdown
Member

@felipepessoto No problem. Would suggest converting to draft next time when a PR is in progress

@felipepessoto

Copy link
Copy Markdown
Contributor Author

@felipepessoto No problem. Would suggest converting to draft next time when a PR is in progress

Yeah, my bad. Thanks

@felipepessoto
felipepessoto deleted the felipepessoto-jni-exception-preservation branch November 26, 2026 17:57
@zhztheplayer

Copy link
Copy Markdown
Member

@felipepessoto No problem. Would suggest converting to draft next time when a PR is in progress

Yeah, my bad. Thanks

Not necessarily just because I am a lazy reviewer and not always going through the PR again before merging, Althought I am supposed to gather context torwards merging as well XD

@zhztheplayer

Copy link
Copy Markdown
Member

Not necessarily just because I am a lazy reviewer and not always going through the PR again before merging, Althought I am supposed to gather context torwards merging as well XD

Yeah, my bad just found I merged the wrong PR, so let's use draft next time so it helps reviewer make fewer mistakes.

felipepessoto added a commit to felipepessoto/gluten that referenced this pull request Nov 27, 2026
Carry structured native cast attribution and UTF-8 diagnostics through the existing Java exception transport, then translate recognized cast reasons with Spark error factories. Preserve original causes, schema translation, unknown errors, and cast evaluation modes.

Add focused JVM, native-attribution, iterator, and Velox cast regressions. Depends on apache#13133 for the shared JNI throwable carrier.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core DOCS VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VL] Hybrid stacktrace for exceptions with all Java and C++ stack frames included

3 participants