[catalog] Preserve exception cause when rethrowing catalog exceptions#3281
Merged
luoyuxia merged 1 commit intoapache:mainfrom May 9, 2026
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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
InvalidTableExceptioninCoordinatorService#createTable. - Preserve cause when wrapping Paimon catalog column exceptions into
InvalidAlterTableExceptioninPaimonLakeCatalog#alterTable. - Preserve cause when rethrowing lake-table-already-exist and invalid-table cases in
FlinkCatalog#createTableandFlinkCatalog#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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 andcause. This makes diagnosing failures harder because the root cause is lost
from the logs.
This PR preserves the cause by passing the original
Throwableas the secondargument 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 thelake-table-already-existbranch (
new CatalogException(t.getMessage(), t)) and theinvalid-tablebranch (
new InvalidTableException(t.getMessage(), t)).FlinkCatalog#alterTable: preserve cause in theinvalid-tablebranch(
new InvalidTableException(t.getMessage(), t)).PaimonLakeCatalog: preserve cause for theColumnAlreadyExistException | ColumnNotExistExceptionbranch inAddColumnhandling(
new InvalidAlterTableException(e.getMessage(), e)).CoordinatorService: preserve cause when wrappingUncheckedIOExceptionand 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
Throwableas 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
causefield of the thrown exceptions is now populated.Documentation
No documentation changes. This is an internal cleanup without any
user-facing behavior change.