Search in sources :

Example 31 with TemporaryBackendException

use of org.janusgraph.diskstorage.TemporaryBackendException in project janusgraph by JanusGraph.

the class ConsistentKeyLockerTest method testCheckLocksThrowsExceptionAfterMaxTemporaryStorageExceptions.

/**
 * The checker will throw a TemporaryStorageException if getSlice() throws
 * fails with a TemporaryStorageException as many times as there are
 * configured lock retries.
 *
 * @throws InterruptedException shouldn't happen
 * @throws org.janusgraph.diskstorage.BackendException     shouldn't happen
 */
@Test
public void testCheckLocksThrowsExceptionAfterMaxTemporaryStorageExceptions() throws InterruptedException, BackendException {
    // Setup a LockStatus for defaultLockID
    ConsistentKeyLockStatus lockStatus = makeStatusNow();
    currentTimeNS = currentTimeNS.plusNanos(1);
    expect(lockState.getLocksForTx(defaultTx)).andReturn(ImmutableMap.of(defaultLockID, lockStatus));
    expectSleepAfterWritingLock(lockStatus);
    // Three successive getSlice calls, each throwing a distinct TSE
    recordExceptionalLockGetSlice(new TemporaryBackendException("Storage cluster is having me-time"));
    recordExceptionalLockGetSlice(new TemporaryBackendException("Storage cluster is in a dissociative fugue state"));
    recordExceptionalLockGetSlice(new TemporaryBackendException("Storage cluster has gone to Prague to find itself"));
    ctrl.replay();
    TemporaryBackendException tse = null;
    try {
        locker.checkLocks(defaultTx);
    } catch (TemporaryBackendException e) {
        tse = e;
    }
    assertNotNull(tse);
}
Also used : TemporaryBackendException(org.janusgraph.diskstorage.TemporaryBackendException) ConsistentKeyLockStatus(org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLockStatus) Test(org.junit.jupiter.api.Test)

Example 32 with TemporaryBackendException

use of org.janusgraph.diskstorage.TemporaryBackendException in project janusgraph by JanusGraph.

the class ConsistentKeyLockerTest method testWriteLockRetriesOnTemporaryStorageException.

/**
 * Test the locker retries a lock write after the initial store mutation
 * fails with a {@link org.janusgraph.diskstorage.TemporaryBackendException}. The retry should both
 * attempt to write the and delete the failed mutation column.
 *
 * @throws org.janusgraph.diskstorage.BackendException shouldn't happen
 */
@Test
public void testWriteLockRetriesOnTemporaryStorageException() throws BackendException {
    TemporaryBackendException tse = new TemporaryBackendException("Storage cluster is waking up");
    expect(lockState.has(defaultTx, defaultLockID)).andReturn(false);
    recordSuccessfulLocalLock();
    StaticBuffer firstCol = recordExceptionLockWrite(tse);
    LockInfo secondLI = recordSuccessfulLockWrite(1, ChronoUnit.NANOS, firstCol);
    recordSuccessfulLocalLock(secondLI.tsNS);
    lockState.take(eq(defaultTx), eq(defaultLockID), eq(secondLI.stat));
    ctrl.replay();
    // SUT
    locker.writeLock(defaultLockID, defaultTx);
}
Also used : TemporaryBackendException(org.janusgraph.diskstorage.TemporaryBackendException) StaticBuffer(org.janusgraph.diskstorage.StaticBuffer) Test(org.junit.jupiter.api.Test)

Aggregations

TemporaryBackendException (org.janusgraph.diskstorage.TemporaryBackendException)32 IOException (java.io.IOException)13 PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)13 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)11 ArrayList (java.util.ArrayList)8 BackendException (org.janusgraph.diskstorage.BackendException)7 List (java.util.List)6 Test (org.junit.jupiter.api.Test)6 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)5 HashMap (java.util.HashMap)5 IndexSearcher (org.apache.lucene.search.IndexSearcher)5 BaseTransaction (org.janusgraph.diskstorage.BaseTransaction)5 Duration (java.time.Duration)4 Map (java.util.Map)4 BooleanQuery (org.apache.lucene.search.BooleanQuery)4 DocValuesFieldExistsQuery (org.apache.lucene.search.DocValuesFieldExistsQuery)4 FuzzyQuery (org.apache.lucene.search.FuzzyQuery)4 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)4 MatchNoDocsQuery (org.apache.lucene.search.MatchNoDocsQuery)4 NormsFieldExistsQuery (org.apache.lucene.search.NormsFieldExistsQuery)4