FoundationDB as backend for JanusGraph - Iterate through all vertices

I’m using JanusGraph 0.4.1 and FDB 6.2.22 as backend to store data. I’m using FDB-JG adaptor code to connect, store and fetch data

The problem comes when data size is more, for eg. 2M vertices, and we watch to iterate through all of them…


It fails in

public RecordIterator<KeyValueEntry> getSlice(KVQuery query, StoreTransaction txh) throws BackendException
        final FoundationDBTx tx = getTransaction(txh);
        final StaticBuffer keyStart = query.getStart();
        final StaticBuffer keyEnd = query.getEnd();
        final KeySelector selector = query.getKeySelector();
        final List<KeyValueEntry> result = new ArrayList<>();
        final byte[] foundKey = db.pack(;
        final byte[] endKey = db.pack(;


final List<KeyValue> results = tx.getRange(foundKey, endKey, query.getLimit());

with following error
Permanent failure in storage backend followed by Max transaction reset count exceeded

On further evaluation of error found below exception:

java.util.concurrent.ExecutionException: Transaction is too old to perform reads or be committed
        at java.util.concurrent.CompletableFuture.reportGet(
        at java.util.concurrent.CompletableFuture.get(
        at com.experoinc.janusgraph.diskstorage.foundationdb.FoundationDBTx.getRange(
        at com.experoinc.janusgraph.diskstorage.foundationdb.FoundationDBKeyValueStore.getSlice(
        at org.janusgraph.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreAdapter.getKeys(
        at org.janusgraph.diskstorage.keycolumnvalue.KCVSProxy.getKeys(
        at org.janusgraph.diskstorage.BackendTransaction$
        at org.janusgraph.diskstorage.BackendTransaction$
        at org.janusgraph.diskstorage.util.BackendOperation.executeDirect(
        at org.janusgraph.diskstorage.util.BackendOperation.execute(
        at org.janusgraph.diskstorage.BackendTransaction.executeRead(
        at org.janusgraph.diskstorage.BackendTransaction.edgeStoreKeys(
        at org.janusgraph.graphdb.database.StandardJanusGraph.getVertexIDs(
        at org.janusgraph.graphdb.transaction.VertexIterable$1.<init>(
        at org.janusgraph.graphdb.transaction.VertexIterable.iterator(
        at org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsTransaction.vertices(

What’s the best way to get the desired outcome?

See if this helps.

Thanks for the link. I tried few things which were mentioned there.

The idea is,

  1. I get the startKey, endKey and limit from query.limit() - then get Iterable<KeyValue> Range
  2. Start consuming keyValues
  3. Hit error -> create new txn -> get nextKey from where the error occured -> go to Step 1.
  4. When consumed all, then break

2 questions here:

  1. Is this idea okay?
  2. If yes, what would be the break condition here? How do I get that


The transaction will automatically complete successfully (.join() on transaction future will return success) when there are no more keys to be read in the given range.

Or you can add your own break conditions at the beginning of transation - like max time spent, max number of keys read, or max number of retries due to continuation etc.