GemFire Cache Transaction Semantics

GemFire Cache Transaction Semantics

GemFire transaction semantics differ in some ways from the semantics of traditional relational databases.


Atomicity is “all or nothing” behavior: a transaction completes successfully only when all of the operations it contains complete successfully. If problems occur during a transaction, perhaps due to other transactions with overlapping changes, the transaction cannot successfully complete until the problems are resolved.

GemFire transactions provide atomicity and realize speed by using a reservation system, instead of using the traditional relational database technique of a two-phase locking of rows. The reservation prevents other, intersecting transactions from completing , allowing the commit to check for conflicts and to reserve resources in an all-or-nothing fashion prior to making changes to the data. After all changes have been made, locally and remotely, the reservation is released. With the reservation system, an intersecting transaction is simply discarded. The serialization of obtaining locks is avoided. See Committing Transactions for details on the two-phase commit protocol that implements the reservation system.


Consistency requires that data written within a transaction must observe the key and value constraints established for the affected region. Note that validity of the transaction is the responsibility of the application.


GemFire transactions support repeatable read isolation, so once the committed value is read for a given key, it always returns that same value. If a transaction write, such as put or invalidate, deletes a value for a key that has already been read, subsequent reads return the transactional reference.

GemFire isolates transactions at the process thread level, so while a transaction is in progress, its changes are visible only inside the thread that is running the transaction. Threads inside the same process and in other processes cannot see changes until after the commit operation begins. At this point the changes are visible in the cache, but other threads that access the changing data might see only partial results of the transaction.

Isolation assures that read operations will see either the pre-transaction state of the system or its post-transaction state, but not the transitional state that occurs while a transaction is in progress. As a distributed cache-based system optimized for performance, GemFire in its default configuration does not enforce isolation. It allows transactional writes to proceed without being slowed down by in-progress reads.

Applications can emulate the slow conventional isolation model by doing the extra work of encapsulating their read operations within transactions. The application sets the gemfire.detectReadConflicts parameter to ‘true’:


This causes read operations to succeed only when they read a consistent pre- or post-transactional state.


Relational databases provide durability by using disk storage for recovery and transaction logging. As a distributed cache-based system optimized for performance, GemFire does not support on-disk or in-memory durability for transactions.

Applications can emulate the conventional disk-based durability model by setting the gemfire.ALLOW_PERSISTENT_TRANSACTIONS parameter to ‘true’.


This allows permanent regions to participate in transactions, thus providing disc-based durability. See Transactions and Persistent Regions for more detail on the use of this parameter.