Skip to content

PHOENIX-8086 MetaDataEndpointImpl.createTable reports failure after a successful commit - #2718

Merged
apurtell merged 5 commits into
apache:masterfrom
apurtell:PHOENIX-8086
Dec 5, 2026
Merged

apurtell merged 5 commits into
apache:masterfrom
apurtell:PHOENIX-8086

Conversation

@apurtell

@apurtell apurtell commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

A CREATE TABLE without IF NOT EXISTS failed in CI because the table already existed. The first attempt committed the table. The balancer then closed the catalog region before the endpoint read back the new table. The endpoint reported a failure, the HBase client retried, and the retry found the committed table.

The change catches a failure of that read after the commit. The endpoint then builds the new table from the catalog rows it has just committed, the same way schema export already does, and returns success with that table. Those rows hold the values that only the server generates, the DDL timestamp and the external schema id, so the client caches the same values as after a normal read. If that in-memory build also fails, the endpoint logs a warning and returns success with no table, and the client builds the table from its own metadata as it already can. Failures before the commit do not change.

New tests use a test hook to make the read after a create fail, and in a second case the in-memory build as well. They check that the create succeeds in both cases and that the client keeps the stored DDL timestamp when the response carries the table.

🤖 Generated with Claude Code

… successful commit

createTable commits the catalog rows and then reads the new table back.
If the region moves, this read can fail with NotServingRegionException.
The endpoint then reports a failure, and the client retry gets
TABLE_ALREADY_EXISTS for a table that the same statement created.
Now a failed read after the commit logs a warning and returns success
without the table. The client builds the table from its own metadata,
without LAST_DDL_TIMESTAMP and the external schema id. Views and indexes
get these values on the next refresh. A base table keeps them null in
the client cache until its next DDL or cache eviction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The fallback loses the generated external schema ID in client metadata, causing subsequent writes to omit it from WAL annotations even after a forced refresh.

1 open issue
What changed in this PR

Addresses PHOENIX-8086 by preventing a metadata read failure after a successful CREATE TABLE commit from triggering a misleading failure and retry.

Changes:

  • Catches post-commit metadata read exceptions and logs a warning.
  • Returns success without table metadata, allowing client reconstruction while leaving pre-commit failures unchanged.
File Description
phoenix-core-server/​src/​main/​java/​org/​apache/​phoenix/​coprocessor/​MetaDataEndpointImpl.java Adds a success fallback when the post-commit table read fails.

Review effort: Balanced

…failed read

When the read after the commit fails, the endpoint now builds the new
table from the catalog rows that it has just committed, the same way
schema export already does. These rows carry the server-generated DDL
timestamp and, with change detection, the external schema id, so the
client caches the same values as after a normal read. If this build also
fails, the endpoint returns success without the table, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

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

5 open issues

Review effort: Lite

A test hook makes the read after a create fail one time. It can also make
the build from mutations fail. New tests check that the create succeeds in
both cases. The client keeps the server DDL timestamp only when the
response carries the table. The fallback now catches only the I/O, SQL and
runtime exceptions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apurtell
apurtell requested a balanced review from Copilot December 4, 2026 03:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…allback

A static helper now clears the test flag, so the endpoint instance does
not write to a static field. The row filter names its child row test, so
it needs no parentheses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ilures

The read after the commit now catches the same failures as the build
from mutations, so an unchecked failure of the read also falls back to
that build. The comments now say that the build reads no region rows
only for a base table. For a view or an index it still reads parent
and link rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apurtell

apurtell commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Self-review (Claude Code, pr-review-toolkit) — Copilot could not review this PR because of a review quota limit, so this is an automated self-review in its place.

Suggestions

  • The in-memory build is complete only for base tables (MetaDataEndpointImpl.java:3061, :3003). The Javadoc says the build needs no read from the region. The block comment says the mutations give back the server-side values. For a view or an index, link rows and TTL inheritance still read the catalog, and the parent cache entry was just invalidated. So in the region-move case these creates usually take the second fallback, and a view with change detection has no external schema id in the client cache. This is still better than the base behavior, but the comments should say that the build is fully in memory only for a base table.
  • The two catches handle different exception types (MetaDataEndpointImpl.java:3017). The inner build catches runtime exceptions, but the read after the commit does not. An unchecked failure in that read still reports a failure for a committed create, and the retry then hits the "already exists" error again. Catching the same types in both places matches the stated rule.
  • No test checks the external schema id (MetaDataEndpointImplIT.java:411). That value was the reason for the build from mutations. Adding change detection to the DDL in the case where the build succeeds, and comparing the cached schema id with the stored one, would guard it. A view or index case would also test the row filter.

Strengths

  • Only the code after the commit changes. Failures before the commit still return their errors, so the fallback cannot hide a create that never happened.
  • The fallback reuses the schema-export build path. The row filter matches the scan range of a normal read and leaves out parent-row updates.
  • The table built from mutations is not put into the server metadata cache, so a partial build cannot affect later reads.
  • The test hook fires once, is keyed by table name and is reset in a finally block. The tests cover both fallback levels against the stored catalog value and then check that upserts and queries work.

Recommendation: merge after nits

🤖 Generated with Claude Code

@apurtell

apurtell commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Follow-up to the self-review (Claude Code). The latest commit, 9d42095, addresses the first two suggestions.

  • Base tables only. The comments now say that only a base table is built fully in memory. For a view or an index, the build still reads the catalog for the parent and the link rows, so in the region-move case those creates usually take the second fallback. That is still better than the old behavior, where the client got a failure for a create that was committed.
  • One set of failures. The read after the commit and the in-memory build now handle the same failures. So a failed read can no longer make a committed create report a failure.
  • Test for the external schema id. No new test. The existing WAL annotation tests cover the normal path, where the read succeeds. The fallback builds the table from the same committed catalog cells, so it gives the same value. A test of the fallback itself would need a schema registry in the test setup, and that is more than this small fix needs.

The metadata endpoint and WAL annotation integration tests pass on this commit in local docker.

🤖 Generated with Claude Code

@apurtell

apurtell commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

About the failures in the latest precommit run (Claude Code). None of them come from this change. Each one is a known test problem with its own fix under review.

Both failed test classes passed on this same commit in the local CI run described above.

🤖 Generated with Claude Code

@apurtell
apurtell merged commit b56529b into apache:master Dec 5, 2026
10 of 13 checks passed
@apurtell
apurtell deleted the PHOENIX-8086 branch December 5, 2026 18:39
asf-gitbox-commits pushed a commit that referenced this pull request Dec 5, 2026
… successful commit (#2718)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Andrew Purtell <apurtell@salesforce.com>
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.

2 participants