Apache Ignite SQL Documentation

The Apache Ignite SQL Developer Hub

Welcome to the Apache Ignite SQL developer hub. You'll find comprehensive guides and documentation to help you start working with Apache Ignite SQL as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

SQL Transactions - 2.7

Overview

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.

Enabling MVCC

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>
 

Limitations

Cross-Cache Transactions

The 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 TRANSACTIONAL_SNAPSHOT mode.

Nested Transactions

Ignite supports three modes of handling nested SQL transactions that can be enabled via JDBC/ODBC connection parameter.

jdbc:ignite:thin://127.0.0.1/?nestedTransactionsMode=COMMIT

When a nested transaction occurs within another transaction, the system behavior depends on the nestedTransactionsMode parameter:

  • 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.