Support Questions
Find answers, ask questions, and share your expertise

Enabling transaction in Phoenix issue

Enabling transaction in Phoenix issue

New Contributor

Hello,

I'm trying to enable transaction in Phoenix. I have created the properties listed here in the hbase-site.xml

https://phoenix.apache.org/transactions.html

and the java code looks like

stmt.executeUpdate("create table greeting (mykey integer not null primary key, mycolumn varchar) TRANSACTIONAL=true;");

stmt.executeUpdate("upsert into greeting values (1,'Hello')");

stmt.executeUpdate("upsert into greeting values (2,'World!')");

con.commit();

PreparedStatement statement = con.prepareStatement("select * from greeting");

rset = statement.executeQuery();

while (rset.next()) { System.out.println(rset.getString("mycolumn")); }

statement.close(); c

on.close();

The error I get is:

2017-07-12 15:33:57,898 (main) [INFO - com.tibco.test.PhoenixMain.testQueryTransaction(PhoenixMain.java:94)] Connection failed

java.sql.SQLException: ERROR 1078 (44A09): Cannot create a transactional table if transactions are disabled. tableName=GREETING

at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:422)

at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:145)

Taking out the TRANSACTIONAL=true in the create table, the test is successful.

Transactions have been introduced in phoenix 4.7 that is in HDP 2.6.1 (the version we use).

Any pointers?

Kind regards

Biagio

5 REPLIES 5
Highlighted

Re: Enabling transaction in Phoenix issue

You need to add hbase-site.xml updated with transactions related configs to application classpath.

Highlighted

Re: Enabling transaction in Phoenix issue

@Biagio Zampogna

Phoenix uses Tephra for transactional Read/Write operations.

Setting up a system to use transactions in Phoenix requires two steps:

  1. Add the following config to your client side hbase-site.xml file to enable transactions:
    <property>
      <name>phoenix.transactions.enabled</name>
      <value>true</value>
    </property>
    
  2. Add the following config to your server side hbase-site.xml file to configure the transaction manager: The “Transaction Server Configuration” section of Tephra describes the available configuration options.
    <property>
      <name>data.tx.snapshot.dir</name>
      <value>/tmp/tephra/snapshots</value>
    </property>
    

    Also set the transaction timeout (time after which open transactions become invalid) to a reasonable value.

    <property>
      <name>data.tx.timeout</name>
      <value>60</value>
    </property>
    
  3. Set $HBASE_HOME and start the transaction manager:
    ./bin/tephra
    

The transaction manager would typically be configured to run on one or more of the master nodes in your HBase cluster.

Once this setup is done, transactions may then be enabled on a table by table basis by using the TRANSACTIONAL=true property when you create your table:

CREATE TABLE my_table (k BIGINT PRIMARY KEY, v VARCHAR) TRANSACTIONAL=true;

An existing table may also be altered to be transactional, but be careful because you cannot switch a transactional table back to being non transactional:

ALTER TABLE my_other_table SET TRANSACTIONAL=true;

Follow the official documentation for more details : https://phoenix.apache.org/transactions.html

Update:

As far as I know, HDP stacks do not have Tephra in them as yet. If you still want to add the transactions support, you must add Tephra manually into your HDP stack until Hortonworks releases a patch or includes it in future versions.

To add Tephra to your stack refer the "Getting Started" link.

Highlighted

Re: Enabling transaction in Phoenix issue

New Contributor

@Dinesh Chitlangia

Thanks for the reply. I did add the above properties (following the phoenix doc) adding them as custom hbase_site properties in Ambari (and obviously saved and restarted the components)

However there is no tephra in the $HBASE_HOME/bin in any of my master nodes.

We use HDP 2.6.

Any clue?

Highlighted

Re: Enabling transaction in Phoenix issue

@Biagio Zampogna - As far as I know, HDP stacks do not have Tephra in them as yet. If you still want to add the transactions support, you must add Tephra manually into your HDP stack until Hortonworks releases a patch or includes it in future versions.

To add Tephra to your stack refer the "Getting Started" link.

Highlighted

Re: Enabling transaction in Phoenix issue

New Contributor

We do understand the distributed transaction manager has to be started. The problem is that the tephra binary is not provided by HDP 2.6.x repositories and we cannot find any recipe to add it manually. All the other settings are already applied.

Check:

[centos@gateway ~]$ yum provides '*/bin/hbase'
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.rackspeed.de
 * epel: mirror.23media.de
 * extras: mirror.alpix.eu
 * updates: mirror.alpix.eu
ambari-metrics-collector-2.5.0.3-7.x86_64 : Ambari Metrics Assembly
Repo        : ambari-2.5.0.3
Matched from:
Filename    : /usr/lib/ams-hbase/bin/hbase
hbase_2_6_1_0_129-1.1.2.2.6.1.0-129.noarch : HBase is the Hadoop database. Use it when you need random, realtime read/write access to your Big Data. This project's goal is the hosting of very large tables -- billions of rows X millions
                                           : of columns -- atop clusters of commodity hardware.
Repo        : HDP-2.6.1.0
Matched from:
Filename    : /usr/hdp/2.6.1.0-129/hbase/bin/hbase
[centos@gateway ~]$ yum provides '*/bin/tephra'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.rackspeed.de
 * epel: mirror.23media.de
 * extras: mirror.alpix.eu
 * updates: mirror.alpix.eu
No matches found
Don't have an account?