phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Wong (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-5262) Wrong Result on Salted table with Varbinary PK
Date Sat, 27 Apr 2019 00:36:00 GMT

    [ https://issues.apache.org/jira/browse/PHOENIX-5262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16827392#comment-16827392
] 

Daniel Wong commented on PHOENIX-5262:
--------------------------------------

The following E2E test shows a case I found while investigating a bug in our stats branch
work.  There is an incorrectly constructed scan upper range for the case of a Salted Table
with a Varbinary PK.  The is because ScanUtil does not properly check that this is the last
PK column since the slotSpan is > 0 for this case.
{code:java}
@Test
public void testSaltedVarbinaryUpperBoundQuery() throws Exception {
 String tableName = generateUniqueName();
 String ddl = "CREATE TABLE " + tableName + " ( k VARBINARY PRIMARY KEY, a INTEGER ) SALT_BUCKETS
= 3";
 String dml = "UPSERT INTO " + tableName + " values (?, ?)";
 String sql = "SELECT * FROM " + tableName ;

 //Weird this actually makes a server rowkey filter to handle this rather than resolve constants
client side =(
 //String sql2 = "SELECT * FROM " + tableName + " WHERE k = CAST('2' AS VARBINARY)";

 String sql2 = "SELECT * FROM " + tableName + " WHERE k = ?";

 try (Connection conn = DriverManager.getConnection(getUrl())) {
 conn.createStatement().execute(ddl);
 PreparedStatement stmt = conn.prepareStatement(dml);
 stmt.setInt(2,1);

 stmt.setBytes(1,new byte[]{5});
 stmt.executeUpdate();
 stmt.setBytes(1,new byte[]{5,0});
 stmt.executeUpdate();
 stmt.setBytes(1,new byte[]{5,1});
 stmt.executeUpdate();
 conn.commit();

 ResultSet rs = conn.createStatement().executeQuery(sql);
 while(rs.next()){
 System.out.println(String.format(" k = %s, a = %s",
 Arrays.toString(rs.getBytes(1)),Integer.toString(rs.getInt(2))));
 }
 stmt = conn.prepareStatement(sql2);
 stmt.setBytes(1, new byte[]{5});
 rs = stmt.executeQuery();
 while(rs.next()){
 System.out.println(String.format(" k = %s, a = %s",
 Arrays.toString(rs.getBytes(1)),Integer.toString(rs.getInt(2))));
 }
 //assertTrue(rs.next());
 //assertFalse(rs.next());
 }
}{code}

> Wrong Result on Salted table with Varbinary PK
> ----------------------------------------------
>
>                 Key: PHOENIX-5262
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5262
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Daniel Wong
>            Assignee: Daniel Wong
>            Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message