Andrew Kyle Purtell created PHOENIX-8086:
--------------------------------------------
Summary: MetaDataEndpointImpl.createTable reports failure after a
successful commit
Key: PHOENIX-8086
URL: https://issues.apache.org/jira/browse/PHOENIX-8086
Project: Phoenix
Issue Type: Bug
Affects Versions: 5.3.2
Reporter: Andrew Kyle Purtell
Assignee: Andrew Kyle Purtell
Fix For: 5.4.0, 5.3.3
{{UpsertSelectWithRegionMovesIT.testUpsertSelectWithIndex[UpsertSelecttIT_allowServerSideMutations=false]}}
failed in the job "Unit check (NeedsOwnMiniClusterTest Q-Z)". The test creates
a table with no {{{}IF NOT EXISTS{}}}. The client got this error:
{{org.apache.phoenix.schema.TableAlreadyExistsException: ERROR 1013 (42M04):
Table already exists. tableName=N000088
at
org.apache.phoenix.schema.MetaDataClient.handleCreateTableMutationCode(MetaDataClient.java:4005)
at
org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:3812)
at
org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:1070)
...
at
org.apache.phoenix.end2end.UpsertSelectWithRegionMovesIT.testUpsertSelect(UpsertSelectWithRegionMovesIT.java:173)
at
org.apache.phoenix.end2end.UpsertSelectWithRegionMovesIT.testUpsertSelectWithIndex(UpsertSelectWithRegionMovesIT.java:135)}}
The server log shows the first attempt of the same {{{}CREATE TABLE{}}}:
{{2026-11-21T12:54:19,209 ERROR [RpcServer.Metadata.Fifo.handler=3,...]
coprocessor.MetaDataEndpointImpl(3003): createTable failed
org.apache.hadoop.hbase.NotServingRegionException:
SYSTEM.CATALOG,,1795293219505.9a87c3376e703d3fba0999bbb518e22b. is closing
at
org.apache.hadoop.hbase.regionserver.HRegion.startRegionOperation(HRegion.java:8111)
...
at
org.apache.phoenix.coprocessor.MetaDataEndpointImpl.buildTable(MetaDataEndpointImpl.java:806)
at
org.apache.phoenix.coprocessor.MetaDataEndpointImpl.createTable(MetaDataEndpointImpl.java:2990)}}
The balancer chore moved SYSTEM.CATALOG ({{{}balance hri=9a87c337...{}}},
pid=3705) at 12:54:19,055. The log has 19 balancer moves. Retries at
12:54:19,313 and 12:54:19,526 failed in {{buildTable}} from {{loadTable}} (line
2337) and {{createTable}} (line 2526). These line numbers are on 5.3. At
12:54:23,366 a retry on the new region server found N000088 with the timestamp
of the first attempt, 1795294459207. The first attempt had committed the table.
This is a product defect in {{{}MetaDataEndpointImpl.createTable{}}}. Line
numbers are on master {{{}81e0d02fdf{}}}.
*The commit comes before the read.* {{createTable}} writes the catalog rows
with {{{}mutateRowsWithLocks{}}}. Then it invalidates the server cache and sets
the mutation time. Then it calls {{buildTable}} to return the new table to the
client. {{buildTable}} calls {{startRegionOperation}} on the SYSTEM.CATALOG
region. It puts the table in the {{GlobalCache}} only on success.
*A region close in that window gives a false failure.* If the region is
closing, {{startRegionOperation}} throws {{{}NotServingRegionException{}}}. The
{{catch (Throwable t)}} block logs {{createTable failed}} and returns the
exception. The rows are already committed. The HBase client retries the
endpoint call. A later retry reaches the region at its new location.
*The retry sees the committed table.* The retry finds the header row in the
existence check and returns {{{}TABLE_ALREADY_EXISTS{}}}. On the client,
{{handleCreateTableMutationCode}} throws {{TableAlreadyExistsException}} when
the statement has no {{{}IF NOT EXISTS{}}}. Thus a successful {{CREATE TABLE}}
reports failure.
Any close of the SYSTEM.CATALOG region in this window has the same effect. The
window is a few milliseconds.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)