use of com.palantir.atlasdb.transaction.api.TransactionSerializableConflictException in project atlasdb by palantir.
the class AbstractSerializableTransactionTest method testClassicWriteSkew.
@Test
public void testClassicWriteSkew() {
Transaction t0 = startTransaction();
put(t0, "row1", "col1", "100");
put(t0, "row2", "col1", "100");
t0.commit();
Transaction t1 = startTransaction();
Transaction t2 = startTransaction();
withdrawMoney(t1, true, false);
withdrawMoney(t2, false, false);
t1.commit();
try {
t2.commit();
fail();
} catch (TransactionSerializableConflictException e) {
// this is expectecd to throw because it is a write skew
}
}
use of com.palantir.atlasdb.transaction.api.TransactionSerializableConflictException in project atlasdb by palantir.
the class AbstractSerializableTransactionTest method testColumnRangeReadWriteEmptyRange.
@Test
public void testColumnRangeReadWriteEmptyRange() {
byte[] row = PtBytes.toBytes("row1");
Transaction t1 = startTransaction();
Map<byte[], BatchingVisitable<Map.Entry<Cell, byte[]>>> columnRange = t1.getRowsColumnRange(TEST_TABLE, ImmutableList.of(row), BatchColumnRangeSelection.create(PtBytes.toBytes("col"), PtBytes.toBytes("col0"), 1));
assertNull(BatchingVisitables.getFirst(Iterables.getOnlyElement(columnRange.values())));
// Write to avoid the read only path.
put(t1, "row1_1", "col0", "v0");
Transaction t2 = startTransaction();
put(t2, "row1", "col", "v0");
t2.commit();
try {
t1.commit();
fail();
} catch (TransactionSerializableConflictException e) {
// expected
}
}
use of com.palantir.atlasdb.transaction.api.TransactionSerializableConflictException in project atlasdb by palantir.
the class AbstractSerializableTransactionTest method testPhantomReadFail2.
@Test
public void testPhantomReadFail2() {
String initialValue = "100";
Transaction t0 = startTransaction();
put(t0, "row1", "col1", initialValue);
put(t0, "row2", "col1", initialValue);
t0.commit();
Transaction t1 = startTransaction();
BatchingVisitables.copyToList(t1.getRange(TEST_TABLE, RangeRequest.builder().build()));
put(t1, "row22", "col1", initialValue);
Transaction t2 = startTransaction();
put(t2, "row3", "col1", initialValue);
t2.commit();
try {
t1.commit();
fail();
} catch (TransactionSerializableConflictException e) {
// this is expectecd to throw because it is a write skew
}
}
use of com.palantir.atlasdb.transaction.api.TransactionSerializableConflictException in project atlasdb by palantir.
the class AbstractSerializableTransactionTest method testClassicWriteSkew2Cell.
@Test
public void testClassicWriteSkew2Cell() {
Transaction t0 = startTransaction();
put(t0, "row1", "col1", "100");
put(t0, "row2", "col1", "100");
t0.commit();
Transaction t1 = startTransaction();
Transaction t2 = startTransaction();
withdrawMoney(t1, true, true);
withdrawMoney(t2, false, true);
t2.commit();
try {
t1.commit();
fail();
} catch (TransactionSerializableConflictException e) {
// this is expectecd to throw because it is a write skew
}
}
use of com.palantir.atlasdb.transaction.api.TransactionSerializableConflictException in project atlasdb by palantir.
the class AbstractSerializableTransactionTest method testPhantomReadFail.
@Test
public void testPhantomReadFail() {
String initialValue = "100";
Transaction t0 = startTransaction();
put(t0, "row1", "col1", initialValue);
put(t0, "row2", "col1", initialValue);
t0.commit();
Transaction t1 = startTransaction();
RowResult<byte[]> first = BatchingVisitables.getFirst(t1.getRange(TEST_TABLE, RangeRequest.builder().build()));
put(t1, "row22", "col1", initialValue);
Transaction t2 = startTransaction();
put(t2, "row0", "col1", initialValue);
t2.commit();
try {
t1.commit();
fail();
} catch (TransactionSerializableConflictException e) {
// this is expectecd to throw because it is a write skew
}
}
Aggregations