Phoenix Transactions

本文介绍如何在Phoenix中配置并使用跨行及跨表事务,包括设置客户端和服务端配置、启动事务管理器等步骤,并说明了在创建或修改表时启用事务的方法及限制条件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Phoenix Transactions

Above and beyond the row-level transactional semantics of HBase, Phoenix adds cross row and cross table transaction support with full ACID semantics by integrating with Tephra, now an Apache incubator project. Tephra provides snapshot isolation of concurrent transactions by implementing multi-versioned concurrency control.

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>
  2.   <name>phoenix.transactions.enabled</name>
  3.   <value>true</value>
  4.   </property>

  5.  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>
  6.       <name>data.tx.snapshot.dir</name>
  7.      <value>/tmp/tephra/snapshots</value>
  8.    </property>
  9.   Also set the transaction timeout (time after which open transactions become invalid) to a reasonable value.
    <property>
  10.       <name>data.tx.timeout</name>
  11.       <value>60</value> 
  12.     </property>

  13. 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;


Limitations

  1. Starting a transaction on a connection with an SCN set is not allowed.
  2. Setting the maximum number of versions property while creating a transactional table limits the number of snapshots available for concurrent transactions.
  3. When a transaction times out or if it cannot be rolled back by the client, it is added to an invalid list. This list can potentially grow if there are a lot of failed or timed out transactions. For now, an adminstrator can manually clear transactions from this list after a major compaction has occurred. TEPHRA-35 describes ongoing work to automatically remove transactions from the invalid list once all data associated with the transaction has been removed.
  4. If adding an index asynchronously to an existing transactional table, make sure to run a major compaction before issuing the CREATE INDEX ASYNC command as otherwise invalid and/or uncommitted transactions may appear in your index PHOENIX-2154.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值