Andrew Kyle Purtell created PHOENIX-8017:
--------------------------------------------

             Summary: Writes fail on a table with both a local index and a CDC 
index
                 Key: PHOENIX-8017
                 URL: https://issues.apache.org/jira/browse/PHOENIX-8017
             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


A write to a data table fails when the table has both a LOCAL index and a CDC 
index. The region server rejects the batch with an 
IndexBuildingFailureException with root
exception:

{noformat}
  java.lang.IllegalArgumentException: Encoded region name is required
      for a CDC index
    at IndexMaintainer.buildRowKey(IndexMaintainer.java:769)
    at IndexMaintainer.buildDeleteMutation(IndexMaintainer.java:1725)
    at IndexMaintainer.buildDeleteMutation(IndexMaintainer.java:1718)
    at PhoenixIndexCodec.getIndexDeletes(PhoenixIndexCodec.java:144)
    at NonTxIndexBuilder.addDeleteUpdatesToMap(
        NonTxIndexBuilder.java:225)
    at NonTxIndexBuilder.addCleanupForCurrentBatch(
        NonTxIndexBuilder.java:157)
    ...
    at IndexBuildManager.getIndexUpdates(IndexBuildManager.java:102)
    at IndexRegionObserver.handleLocalIndexUpdates(
        IndexRegionObserver.java:1128)
{noformat}

An insert of a new row fails at a different frame with the same
exception:

{noformat}
    at IndexMaintainer.buildRowKey(IndexMaintainer.java:769)
    at IndexMaintainer.buildUpdateMutation(IndexMaintainer.java:1325)
    at IndexMaintainer.buildUpdateMutation(IndexMaintainer.java:1318)
    at PhoenixIndexCodec.getIndexUpserts(PhoenixIndexCodec.java:113)
    ...
{noformat}

Steps to reproduce

{noformat}
  CREATE TABLE T (K INTEGER PRIMARY KEY, V1 INTEGER, V2 INTEGER);
  UPSERT INTO T VALUES (1, 10, 100);
  CREATE LOCAL INDEX T_IDX ON T (V1) INCLUDE (V2);
  CREATE CDC T_CDC ON T;
  UPSERT INTO T VALUES (1, 11, 101);   -- fails
  UPSERT INTO T VALUES (2, 20, 200);   -- fails
  DELETE FROM T WHERE K = 1;           -- fails
{noformat}

IndexRegionObserver.handleLocalIndexUpdates passes the entire batch's 
PhoenixIndexMetaData to the index builder, including all client-provided 
maintainers (local, covered/uncovered global, CDC, and transform). 
PhoenixIndexCodec generates delete and upsert mutations for every maintainer in 
the set, even though handleLocalIndexUpdates ultimately discards everything 
except local index updates (non-local updates are handled elsewhere in the 
observer). Since PHOENIX-7425, a CDC index requires the encoded region name as 
its leading row key column. When the codec calls IndexMaintainer.buildRowKey 
without it, this throws an exception, and all write operations fail during 
local index preparation simply trying to construct CDC updates that would be 
discarded anyway.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to