SQL Transactions are supported for the caches that use the
TRANSACTIONAL_SNAPSHOT atomicity mode. The
TRANSACTIONAL_SNAPSHOT mode is the implementation of multiversion concurrency control (MVCC) for Ignite caches. For more information about MVCC and current limitations, visit the Multiversion Concurrency Control page.
See the Transaction page for transaction syntax supported by Ignite and examples.
Support for SQL transactions is currently in the beta stage. For production use, consider key-value transactions.
To enable MVCC for a cache, use the
TRANSACTIONAL_SNAPSHOT atomicity mode in the cache configuration. If you create a table with the
CREATE TABLE command, specify the atomicity mode as a parameter in the
WITH part of the command:
CREATE TABLE Person WITH "ATOMICITY=TRANSACTIONAL_SNAPSHOT"
<bean class="org.apache.ignite.configuration.IgniteConfiguration"> ... <property name="cacheConfiguration"> <bean class="org.apache.ignite.configuration.CacheConfiguration"> <property name="name" value="myCache"/> <property name="atomicityMode" value="TRANSACTIONAL_SNAPSHOT"/> ... </bean> </property> </bean>
TRANSACTIONAL_SNAPSHOT mode is enabled per cache and does not permit caches with different atomicity modes within one transaction. As a consequence, if you want to cover multiple tables in one SQL transaction, all tables must be created with the
Ignite supports three modes of handling nested SQL transactions that can be enabled via JDBC/ODBC connection parameter.
When a nested transaction occurs within another transaction, the system behavior depends on the
ERROR— When the nested transaction is encountered, an error is thrown and the enclosing transaction is rolled back. This is the default behavior.
COMMIT— The enclosing transaction is committed; the nested transaction starts and is committed when its COMMIT statement is encountered. The rest of the statements in the enclosing transaction are executed as implicit transactions.
IGNORE— DO NOT USE THIS MODE. The beginning of the nested transaction is ignored, statements within the nested transaction will be executed as part of the enclosing transaction, and all changes will be committed with the commit of the nested transaction. The subsequent statements of the enclosing transaction will be executed as implicit transactions.
Updated 3 months ago