You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by F21 <f2...@gmail.com> on 2016/04/04 08:42:28 UTC

Non-transactional table has transaction-like behavior

I am using HBase 1.1.3 with Phoenix 4.8.0-SNAPSHOT. To talk to phoenix, 
I am using the phoenix query server with serialization set to JSON.

First, I create a non-transactional table:
CREATE TABLE my_table3 (k BIGINT PRIMARY KEY, v VARCHAR) 
TRANSACTIONAL=false;

I then send the following requests to the query server using curl:
curl localhost:8765 -XPOST --data '{"request": 
"openConnection","connectionId": "my-conn"}'

curl localhost:8765 -XPOST --data '{"request": 
"connectionSync","connectionId": "my-conn","connProps": {"connProps": 
"connPropsImpl","autoCommit": false,"transactionIsolation": 8}}'

curl localhost:8765 -XPOST --data '{"request": 
"createStatement","connectionId": "my-conn"}'
curl localhost:8765 -XPOST --data '{"request": 
"prepareAndExecute","connectionId": "my-conn","statementId": 
12345,"sql": "UPSERT INTO my_table3 VALUES (1,\'A\')","maxRowCount": 
100}' #Update the statement id

curl localhost:8765 -XPOST --data '{"request": 
"createStatement","connectionId": "my-conn"}'
curl localhost:8765 -XPOST --data '{"request": 
"prepareAndExecute","connectionId": "my-conn","statementId": 
12345,"sql": "UPSERT INTO my_table3 VALUES (2,\'B\')","maxRowCount": 
100}' #Update the statement id

Connect to the phoenix query server using Squirrel SQL and see no rows 
exist for the my_table3 table.

curl localhost:8765 -XPOST --data '{"request": 
"createStatement","connectionId": "my-conn"}'
curl localhost:8765 -XPOST --data '{"request": 
"prepareAndExecute","connectionId": "my-conn","statementId": 
12345,"sql": "SELECT * FROM my_table3","maxRowCount": 100}' # Shows no 
results

curl localhost:8765 -XPOST --data '{"request": "commit","connectionId": 
"my-conn"}'

Connect to the phoenix query server using Squirrel SQL and see 2 rows 
for the my_table3 table.

It seems a bit strange that the table exhibits some properties where it 
supports transactions to some extent. Is this something that should be 
fixed?

Ideally, if a connectionSync request turns off autocommit for a given 
connection, reading and writing to a non-transactional table using that 
connection should return an error.


Re: Non-transactional table has transaction-like behavior

Posted by Josh Elser <jo...@gmail.com>.
Let's think back to before transactions where added to Phoenix.

With autoCommit=false, updates to HBase will be batched in the Phoenix 
driver, eventually flushing on their own or whenever you invoked 
commit() on the connection.

With autoCommit=true, updates to HBase are flushed with every executed 
statement.

For what you're describing here, not being able to see the table 
contents via Squirrel makes sense to make. I don't believe the 
introduction of transactions to Phoenix would be intended to change 
these semantics.

(QueryServer in the mix also doesn't affect any of this).

Does that make sense?

F21 wrote:
> I am using HBase 1.1.3 with Phoenix 4.8.0-SNAPSHOT. To talk to phoenix,
> I am using the phoenix query server with serialization set to JSON.
>
> First, I create a non-transactional table:
> CREATE TABLE my_table3 (k BIGINT PRIMARY KEY, v VARCHAR)
> TRANSACTIONAL=false;
>
> I then send the following requests to the query server using curl:
> curl localhost:8765 -XPOST --data '{"request":
> "openConnection","connectionId": "my-conn"}'
>
> curl localhost:8765 -XPOST --data '{"request":
> "connectionSync","connectionId": "my-conn","connProps": {"connProps":
> "connPropsImpl","autoCommit": false,"transactionIsolation": 8}}'
>
> curl localhost:8765 -XPOST --data '{"request":
> "createStatement","connectionId": "my-conn"}'
> curl localhost:8765 -XPOST --data '{"request":
> "prepareAndExecute","connectionId": "my-conn","statementId":
> 12345,"sql": "UPSERT INTO my_table3 VALUES (1,\'A\')","maxRowCount":
> 100}' #Update the statement id
>
> curl localhost:8765 -XPOST --data '{"request":
> "createStatement","connectionId": "my-conn"}'
> curl localhost:8765 -XPOST --data '{"request":
> "prepareAndExecute","connectionId": "my-conn","statementId":
> 12345,"sql": "UPSERT INTO my_table3 VALUES (2,\'B\')","maxRowCount":
> 100}' #Update the statement id
>
> Connect to the phoenix query server using Squirrel SQL and see no rows
> exist for the my_table3 table.
>
> curl localhost:8765 -XPOST --data '{"request":
> "createStatement","connectionId": "my-conn"}'
> curl localhost:8765 -XPOST --data '{"request":
> "prepareAndExecute","connectionId": "my-conn","statementId":
> 12345,"sql": "SELECT * FROM my_table3","maxRowCount": 100}' # Shows no
> results
>
> curl localhost:8765 -XPOST --data '{"request": "commit","connectionId":
> "my-conn"}'
>
> Connect to the phoenix query server using Squirrel SQL and see 2 rows
> for the my_table3 table.
>
> It seems a bit strange that the table exhibits some properties where it
> supports transactions to some extent. Is this something that should be
> fixed?
>
> Ideally, if a connectionSync request turns off autocommit for a given
> connection, reading and writing to a non-transactional table using that
> connection should return an error.
>