[ 
https://issues.apache.org/jira/browse/HBASE-30585?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

mazhengxuan updated HBASE-30585:
--------------------------------
    Description: 
A write can succeed and overwrite another HBase row if a fixed-length component 
is shorter than the catalog declares.

To reproduce, define a composite row key {{a:b}} with two string fields. Set 
{{length}} to {{2}} for {{a and leave b}} variable-length. Write {{("ab", 
"c")}} with {{{}cf:value = "first"{}}}, then write {{("a", "bc")}} with 
{{{}cf:value = "second"{}}}.

*Expected:* The second write fails because {{"a"}} encodes to one byte. Reading 
{{{}("ab", "c") still returns "first"{}}}.

*Actual:* Both writes succeed and produce the physical row key {{{}abc{}}}. 
Reading the table returns one row, {{{}("ab", "c", "second"){}}}.

I suggest checking the encoded byte length of each fixed-length component 
before building the {{{}Put{}}}. The error should name the field and give the 
expected and actual lengths. A regression test should also verify that the 
first row keeps its original value after the second write is rejected.

  was:
A write can succeed and overwrite another HBase row if a fixed-length component 
is shorter than the catalog declares.

To reproduce, define a composite row key {{a:b}} with two string fields. Set 
{{length}} to {{2}} for {{a }}and leave {{b}} variable-length. Write {{("ab", 
"c")}} with {{{}cf:value = "first"{}}}, then write {{("a", "bc")}} with 
{{{}cf:value = "second"{}}}.

*Expected:* The second write fails because {{"a"}} encodes to one byte. Reading 
{{("ab", "c") }}still returns {{{}"first"{}}}.

*Actual:* Both writes succeed and produce the physical row key {{{}abc{}}}. 
Reading the table returns one row, {{{}("ab", "c", "second"){}}}.

I suggest checking the encoded byte length of each fixed-length component 
before building the {{{}Put{}}}. The error should name the field and give the 
expected and actual lengths. A regression test should also verify that the 
first row keeps its original value after the second write is rejected.


> Reject composite row keys whose fixed-length components have the wrong byte 
> length
> ----------------------------------------------------------------------------------
>
>                 Key: HBASE-30585
>                 URL: https://issues.apache.org/jira/browse/HBASE-30585
>             Project: HBase
>          Issue Type: Sub-task
>          Components: hbase-connectors
>            Reporter: mazhengxuan
>            Assignee: mazhengxuan
>            Priority: Major
>
> A write can succeed and overwrite another HBase row if a fixed-length 
> component is shorter than the catalog declares.
> To reproduce, define a composite row key {{a:b}} with two string fields. Set 
> {{length}} to {{2}} for {{a and leave b}} variable-length. Write {{("ab", 
> "c")}} with {{{}cf:value = "first"{}}}, then write {{("a", "bc")}} with 
> {{{}cf:value = "second"{}}}.
> *Expected:* The second write fails because {{"a"}} encodes to one byte. 
> Reading {{{}("ab", "c") still returns "first"{}}}.
> *Actual:* Both writes succeed and produce the physical row key {{{}abc{}}}. 
> Reading the table returns one row, {{{}("ab", "c", "second"){}}}.
> I suggest checking the encoded byte length of each fixed-length component 
> before building the {{{}Put{}}}. The error should name the field and give the 
> expected and actual lengths. A regression test should also verify that the 
> first row keeps its original value after the second write is rejected.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to