phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eli Levine (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (PHOENIX-1213) Upsert and delete do not work for multi-tenant tables using tenant-specific connections
Date Thu, 28 Aug 2014 01:23:57 GMT

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

Eli Levine updated PHOENIX-1213:
--------------------------------

    Description: 
Reported by [~janvanbesien@ngdata.com] on user mailing list:

Here is a first testcase which triggers what
looks like a bug to me. I would expect this to work, but the last
statement fails (upsert and commit) with
org.apache.phoenix.schema.TableNotFoundException: ERROR 1012 (42M03):
Table undefined. tableName=TEST

Note that just before, I execute a select query on the same table.

Thanks for looking into this,
Jan
{code}
    @Test
    public void phoenixMultiTenancyTest() throws Exception {
        HBaseTestingUtility testUtil = new HBaseTestingUtility();
        testUtil.startMiniCluster();

        String globalUrl = "jdbc:phoenix:localhost:" + testUtil.getConfiguration().get("hbase.zookeeper.property.clientPort");
        Connection globalConn = DriverManager.getConnection(globalUrl);

        Statement stmt = globalConn.createStatement();
        stmt.execute("CREATE TABLE test (tenant_id VARCHAR not null, id bigint not null, "
+  
   "first_name varchar constraint pk primary key(tenant_id, id)) MULTI_TENANT=true");

        stmt.execute("upsert into test values('jan', 1, 'a')");
        stmt.execute("upsert into test values('bruno', 1, 'b')");
        globalConn.commit();

        String tenantUrl = globalUrl + ";TenantId=jan";
        Connection tenantConn = DriverManager.getConnection(tenantUrl);
        Statement tenantStmt = tenantConn.createStatement();

        // this works and is correctly limited to only data for tenant "jan"
        ResultSet rs = tenantStmt.executeQuery("select id, first_name from test");
        Assert.assertTrue(rs.next());
        Assert.assertEquals("1", rs.getString(1));
        Assert.assertEquals("a", rs.getString(2));
        Assert.assertFalse(rs.next());

        // this fails with TableNotFoundException
        tenantStmt.execute("upsert into test values (2, 'b')");
        tenantConn.commit();
    }
{code}

  was:
Reported by [~janvanbesien@ngdata.com] on user mailing list:

Here is a first testcase which triggers what
looks like a bug to me. I would expect this to work, but the last
statement fails (upsert and commit) with
org.apache.phoenix.schema.TableNotFoundException: ERROR 1012 (42M03):
Table undefined. tableName=TEST

Note that just before, I execute a select query on the same table.

Thanks for looking into this,
Jan

    @Test
    public void phoenixMultiTenancyTest() throws Exception {
        HBaseTestingUtility testUtil = new HBaseTestingUtility();
        testUtil.startMiniCluster();

        String globalUrl = "jdbc:phoenix:localhost:" +
testUtil.getConfiguration().get("hbase.zookeeper.property.clientPort");
        Connection globalConn = DriverManager.getConnection(globalUrl);

        Statement stmt = globalConn.createStatement();
        stmt.execute("CREATE TABLE test (tenant_id VARCHAR not null,
id bigint not null, " +
                "first_name varchar constraint pk primary
key(tenant_id, id)) MULTI_TENANT=true");

        stmt.execute("upsert into test values('jan', 1, 'a')");
        stmt.execute("upsert into test values('bruno', 1, 'b')");
        globalConn.commit();

        String tenantUrl = globalUrl + ";TenantId=jan";
        Connection tenantConn = DriverManager.getConnection(tenantUrl);
        Statement tenantStmt = tenantConn.createStatement();

        // this works and is correctly limited to only data for tenant "jan"
        ResultSet rs = tenantStmt.executeQuery("select id, first_name
from test");
        Assert.assertTrue(rs.next());
        Assert.assertEquals("1", rs.getString(1));
        Assert.assertEquals("a", rs.getString(2));
        Assert.assertFalse(rs.next());

        // this fails with TableNotFoundException
        tenantStmt.execute("upsert into test values (2, 'b')");
        tenantConn.commit();
    }


> Upsert and delete do not work for multi-tenant tables using tenant-specific connections
> ---------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-1213
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1213
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Eli Levine
>            Assignee: Eli Levine
>
> Reported by [~janvanbesien@ngdata.com] on user mailing list:
> Here is a first testcase which triggers what
> looks like a bug to me. I would expect this to work, but the last
> statement fails (upsert and commit) with
> org.apache.phoenix.schema.TableNotFoundException: ERROR 1012 (42M03):
> Table undefined. tableName=TEST
> Note that just before, I execute a select query on the same table.
> Thanks for looking into this,
> Jan
> {code}
>     @Test
>     public void phoenixMultiTenancyTest() throws Exception {
>         HBaseTestingUtility testUtil = new HBaseTestingUtility();
>         testUtil.startMiniCluster();
>         String globalUrl = "jdbc:phoenix:localhost:" + testUtil.getConfiguration().get("hbase.zookeeper.property.clientPort");
>         Connection globalConn = DriverManager.getConnection(globalUrl);
>         Statement stmt = globalConn.createStatement();
>         stmt.execute("CREATE TABLE test (tenant_id VARCHAR not null, id bigint not null,
" +  
>    "first_name varchar constraint pk primary key(tenant_id, id)) MULTI_TENANT=true");
>         stmt.execute("upsert into test values('jan', 1, 'a')");
>         stmt.execute("upsert into test values('bruno', 1, 'b')");
>         globalConn.commit();
>         String tenantUrl = globalUrl + ";TenantId=jan";
>         Connection tenantConn = DriverManager.getConnection(tenantUrl);
>         Statement tenantStmt = tenantConn.createStatement();
>         // this works and is correctly limited to only data for tenant "jan"
>         ResultSet rs = tenantStmt.executeQuery("select id, first_name from test");
>         Assert.assertTrue(rs.next());
>         Assert.assertEquals("1", rs.getString(1));
>         Assert.assertEquals("a", rs.getString(2));
>         Assert.assertFalse(rs.next());
>         // this fails with TableNotFoundException
>         tenantStmt.execute("upsert into test values (2, 'b')");
>         tenantConn.commit();
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message