Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

Are gigaspaces transactions performed in Isolation?

I am facing issues with Gigaspaces transactions. Here is what My issue is:

  • write(obj1); write(obj2); write(obj3); write(obj4);
  • Commit
  • Begin new transaction
  • Start 4 threads with 4 different transactions.
  • Do a take, all threads are aware of previous takes. Why?
  • What I mean by this is that each takes fetches me obj1 or obj2 or obj3 or obj4
  • instead of all taking obj1, as would be in a perfect Isolated transaction
  • BTW I use READ_REPEATABLE, is there something I am missing?

asked 2017-05-22 21:35:27 -0500

akacoder007 gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

XAP implements a spring contract for PlatformTransactionManager that spans all distributed compute nodes (GSCs). All of the usual spring contracts work - for example, the @Transactional annotation and AOP point-cutting.

Transactions and Isolation levels are described in the following two links: https://docs.gigaspaces.com/xap121/th... https://docs.gigaspaces.com/xap121/tr...

To your specific question, each Thread connects to the same transaction manager which puts the operations in the order in which they arrive.

answered 2017-05-23 10:41:08 -0500

edit flag offensive delete link more

I am not sure I understand this, if you are doing a take, how are you able to use REPEATABLE_READ? Are you doing a read first, then a take? In the case of doing a transaction with ReadModifier.REPEATABLE_READ, once you read that object in a transaction other transactions would not be able write, update or delete until the first transaction was committed or rolled back. See: https://docs.gigaspaces.com/xap121/tr...

Can you please provide brief code snippet?

answered 2017-05-23 11:21:47 -0500

Dixson Huie gravatar image
edit flag offensive delete link more


Here is some code:

    while(--i >= 0) {
                all.add(CompletableFuture.runAsync(() -> {
                    Person p3 = new Person();
                    p3 = gigaSpaceWrapper.take(p3);
                    assertEquals(persons.get(0), p3);
                    // 3 different object here
                    // System.out.println("From Thread: " +p3 + " "+ Thread.currentThread().getId());
                }, executorService));

The wrapper manages transaction by using a thread local, it check if a transaction already exists or is in progress, If yes it then it does nothing, if not it creates a new transaction as follows:

if(transactionStatusThreadLocal.get() == null || transactionStatusThreadLocal.get().status.isCompleted() ) {
        DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
        TransactionStatus status = platformTransactionManager.getTransaction(definition);
        transactionStatusThreadLocal.set(new Transactions(definition.getName(), status));

Even in the xap-ui(bin/gs-ui) I see 3 Transactions when I debug my code. I have played a lot with the Isolation and Propagation methods, the behavior does change, but having isolated takes never works.

I wonder how rollback with take works, This behavior seems a bit weird to me since If one of the take related operation fails, Do I have to rollback all takes? Please provide a solution for isolated takes and provide some links or information to understand how transaction works with takes.

akacoder007 gravatar imageakacoder007 ( 2017-05-23 18:24:49 -0500 )edit

Sorry and also I use platformaTransactionManager to commit and rollback as follows:


akacoder007 gravatar imageakacoder007 ( 2017-05-23 18:31:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-05-22 21:35:27 -0500

Seen: 164 times

Last updated: May 23