Skip to content

[catalog] Preserve exception cause when rethrowing catalog exceptions#3281

Merged
luoyuxia merged 1 commit intoapache:mainfrom
XuQianJin-Stars:fix/preserve-exception-cause
May 9, 2026
Merged

[catalog] Preserve exception cause when rethrowing catalog exceptions#3281
luoyuxia merged 1 commit intoapache:mainfrom
XuQianJin-Stars:fix/preserve-exception-cause

Conversation

@XuQianJin-Stars
Copy link
Copy Markdown
Contributor

Several places in the catalog code rethrow caught exceptions by passing only getMessage() to the new exception, which drops the original stack trace and cause. This makes diagnosing failures harder because the root cause is lost.

Preserve the cause by passing the original Throwable as the second argument to the exception constructor in:

  • FlinkCatalog (createTable: lake-table-already-exist and invalid-table branches; alterTable: invalid-table branch)
  • PaimonLakeCatalog (AddColumn ColumnAlready/NotExistException branch)
  • CoordinatorService (UncheckedIOException and generic validate branches when wrapping into InvalidTableException)

No behavior change other than richer exception chaining.

Purpose

Linked issue: none (minor code cleanup, no GitHub issue filed)

Several places in the catalog code rethrow caught exceptions by passing only
getMessage() to the new exception, which drops the original stack trace and
cause. This makes diagnosing failures harder because the root cause is lost
from the logs.

This PR preserves the cause by passing the original Throwable as the second
argument to the exception constructor, so that exception chaining is kept
intact and the root cause is visible in logs.

Brief change log

  • FlinkCatalog#createTable: preserve cause in the lake-table-already-exist
    branch (new CatalogException(t.getMessage(), t)) and the invalid-table
    branch (new InvalidTableException(t.getMessage(), t)).
  • FlinkCatalog#alterTable: preserve cause in the invalid-table branch
    (new InvalidTableException(t.getMessage(), t)).
  • PaimonLakeCatalog: preserve cause for the
    ColumnAlreadyExistException | ColumnNotExistException branch in
    AddColumn handling
    (new InvalidAlterTableException(e.getMessage(), e)).
  • CoordinatorService: preserve cause when wrapping UncheckedIOException
    and generic validation errors into InvalidTableException.

Tests

No new tests are added. This is a trivial rework that only changes the
exception-construction call to additionally pass the original Throwable
as the cause. Behavior of existing tests is unaffected.

API and Format

No API or storage format changes. The exception types thrown remain the
same; only the cause field of the thrown exceptions is now populated.

Documentation

No documentation changes. This is an internal cleanup without any
user-facing behavior change.

Several places in the catalog code rethrow caught exceptions by passing
only getMessage() to the new exception, which drops the original stack
trace and cause. This makes diagnosing failures harder because the root
cause is lost.

Preserve the cause by passing the original Throwable as the second
argument to the exception constructor in:
  - FlinkCatalog (createTable: lake-table-already-exist and invalid-table
    branches; alterTable: invalid-table branch)
  - PaimonLakeCatalog (AddColumn ColumnAlready/NotExistException branch)
  - CoordinatorService (UncheckedIOException and generic validate
    branches when wrapping into InvalidTableException)

No behavior change other than richer exception chaining.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves debuggability of catalog-related failures by preserving the original exception cause (and therefore stack trace) when rethrowing/wrapping exceptions in several catalog and coordinator code paths. This keeps exception chaining intact without changing the exception types thrown.

Changes:

  • Preserve cause when wrapping parsing/validation exceptions into InvalidTableException in CoordinatorService#createTable.
  • Preserve cause when wrapping Paimon catalog column exceptions into InvalidAlterTableException in PaimonLakeCatalog#alterTable.
  • Preserve cause when rethrowing lake-table-already-exist and invalid-table cases in FlinkCatalog#createTable and FlinkCatalog#alterTable.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
fluss-server/src/main/java/org/apache/fluss/server/coordinator/CoordinatorService.java Adds the caught exception as the cause when wrapping parse/validation failures into InvalidTableException.
fluss-lake/fluss-lake-paimon/src/main/java/org/apache/fluss/lake/paimon/PaimonLakeCatalog.java Preserves the original Paimon exception as the cause when rethrowing as InvalidAlterTableException.
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/catalog/FlinkCatalog.java Preserves the original throwable as the cause when rethrowing CatalogException/InvalidTableException in specific branches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

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

+1

@luoyuxia luoyuxia merged commit de693bc into apache:main May 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants