Search code examples
ignite

Apache Ignite - Problem with Transactions including 20K objects


I would like to commit a transaction that included almost 20K objects with Apache Ignite. I've configured the IgniteCache with a CacheConfiguration in Transactional Mode:

CacheConfiguration<Long, CDonneeAffichage> ccda = new    
CacheConfiguration<>(CacheConstant.CST_CACHE_DONNEE_AFFICHAGE);
ccda.setIndexedTypes(Long.class, CDonneeAffichage.class);
ccda.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);

The transaction is created with IgniteTransactions:

IgniteTransactions transactions = igniteInstance.transactions();
try (Transaction tx = transactions.txStart()){
    //20K put in the Cache          
    tx.commit();
}


The update takes around 20 seconds and during this time it's possible to retrieve partial data for example after 12 seconds I can see 11k objects of the total.
I really need to be able to have a consistent data: Before the transaction commit, I should have 0 data return After the transaction commit, I should have the whole 20K.
Does anybody know if it's possible to do this kind of transactions with Apache Ignite?
Thanks,


Solution

  • Transactions in Ignite satisfy ACID requirements. But some operations are not transactional. There are no transactional operations, that involve all entries in the cache, because it would require locking all keys, which is quite a complex action. No other transactions would be able to perform their work, because all entries would be locked.

    So, when you call the IgniteCache#size() method, then transaction is not started, and partial results may be received. Transactions are only isolated from other transactions, and not from operations outsize transactions.

    To determine if an API method is transactional or not, you can check a list of exceptions, that it throws. If there is a TransactionException, then it means, that the method supports transactions.

    Also SQL is currently non-transactional. Release of transactional SQL in experimental mode is planned for version 2.7, which is about to be released.