summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/CarbonadoGuide.odtbin56032 -> 56398 bytes
-rw-r--r--docs/CarbonadoGuide.pdfbin417058 -> 432918 bytes
-rw-r--r--src/main/java/com/amazon/carbonado/IsolationLevel.java13
-rw-r--r--src/main/java/com/amazon/carbonado/OptimisticLockException.java2
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java6
5 files changed, 21 insertions, 0 deletions
diff --git a/docs/CarbonadoGuide.odt b/docs/CarbonadoGuide.odt
index d6b977b..3530801 100644
--- a/docs/CarbonadoGuide.odt
+++ b/docs/CarbonadoGuide.odt
Binary files differ
diff --git a/docs/CarbonadoGuide.pdf b/docs/CarbonadoGuide.pdf
index 20f763f..56414db 100644
--- a/docs/CarbonadoGuide.pdf
+++ b/docs/CarbonadoGuide.pdf
Binary files differ
diff --git a/src/main/java/com/amazon/carbonado/IsolationLevel.java b/src/main/java/com/amazon/carbonado/IsolationLevel.java
index 5f963b2..7571205 100644
--- a/src/main/java/com/amazon/carbonado/IsolationLevel.java
+++ b/src/main/java/com/amazon/carbonado/IsolationLevel.java
@@ -26,6 +26,7 @@ package com.amazon.carbonado;
* <li>{@link #READ_UNCOMMITTED}
* <li>{@link #READ_COMMITTED}
* <li>{@link #REPEATABLE_READ}
+ * <li>{@link #SNAPSHOT}
* <li>{@link #SERIALIZABLE}
* </ul>
*
@@ -35,6 +36,11 @@ package com.amazon.carbonado;
* iteration. It releases locks during iteration rather than holding on to them
* until the transaction exits.
*
+ * <p>{@code SNAPSHOT} isolation is special in that it uses multiversion
+ * concurrency control (MVCC). A commit may fail with an {@link
+ * OptimisticLockException}. Few repositories are expected to support this
+ * level, however.
+ *
* @author Brian S O'Neill
* @see Repository#enterTransaction(IsolationLevel)
* @see Transaction
@@ -73,6 +79,13 @@ public enum IsolationLevel {
/**
* Indicates that dirty reads, non-repeatable reads and phantom reads are
+ * prevented. Commits can still fail however, as snapshot isolation avoids
+ * using locks.
+ */
+ SNAPSHOT,
+
+ /**
+ * Indicates that dirty reads, non-repeatable reads and phantom reads are
* prevented. Phantoms are records returned as a result of a search, but
* which were not seen by the same transaction when the identical search
* criteria was previously used. For example, another transaction may have
diff --git a/src/main/java/com/amazon/carbonado/OptimisticLockException.java b/src/main/java/com/amazon/carbonado/OptimisticLockException.java
index 2a782d1..b4a43de 100644
--- a/src/main/java/com/amazon/carbonado/OptimisticLockException.java
+++ b/src/main/java/com/amazon/carbonado/OptimisticLockException.java
@@ -21,6 +21,8 @@ package com.amazon.carbonado;
/**
* An OptimisticLockException is thrown if the {@link Repository} is using
* optimistic locking for concurrency control, and lock aquisition failed.
+ * This exception may also be thrown if multiversion concurrency control (MVCC)
+ * is being used and the commit fails.
*
* @author Brian S O'Neill
*/
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java
index 6e53354..97be915 100644
--- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java
+++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java
@@ -92,6 +92,9 @@ public class JDBCRepository
return Connection.TRANSACTION_READ_COMMITTED;
case REPEATABLE_READ:
return Connection.TRANSACTION_REPEATABLE_READ;
+ case SNAPSHOT:
+ // TODO: not accurate for all databases.
+ return Connection.TRANSACTION_SERIALIZABLE;
case SERIALIZABLE:
return Connection.TRANSACTION_SERIALIZABLE;
}
@@ -117,6 +120,9 @@ public class JDBCRepository
case REPEATABLE_READ:
desiredLevel = IsolationLevel.SERIALIZABLE;
break;
+ case SNAPSHOT:
+ desiredLevel = IsolationLevel.SERIALIZABLE;
+ break;
case SERIALIZABLE: default:
return null;
}