title: Unable to create a composite index, stuck at INSTALLED
body: <p>I'm unable to create an index. My Gremlin code is as follows:</p>
  
  <pre><code>usernameProperty = mgmt.getPropertyKey('username')
  usernameIndex = mgmt.buildIndex('byUsernameUnique', Vertex.class).addKey(usernameProperty).unique().buildCompositeIndex()
  mgmt.setConsistency(usernameIndex, ConsistencyModifier.LOCK)
  mgmt.commit()
  </code></pre>
  
  <p>Shortly after I receive two errors:</p>
  
  <blockquote>
    <p>18:04:57 ERROR com.thinkaurelius.titan.graphdb.database.management.ManagementLogger  - Evicted [1@0a00009d2537-ip-10-0-0-1572] from cache but waiting too long for transactions to close. Stale transaction alert on: [standardtitantx[0x6549ce71]]
    18:04:57 ERROR com.thinkaurelius.titan.graphdb.database.management.ManagementLogger  - Evicted [1@0a00009d2537-ip-10-0-0-1572] from cache but waiting too long for transactions to close. Stale transaction alert on: [standardtitantx[0x2a2815cc], standardtitantx[0x025dc2c0]]</p>
  </blockquote>
  
  <p>The status of the index is stuck at <code>INSTALLED</code>:</p>
  
  <pre><code>usernameIndex.getIndexStatus(usernameProperty)
  ==&gt;INSTALLED
  </code></pre>
  
  <p>I read that a failed instance could cause the issue, but a check of running instances shows just one:</p>
  
  <pre><code>mgmt.getOpenInstances()
  ==&gt;0a00009d3011-ip-10-0-0-1572(current)
  </code></pre>
  
  <p>I've also tried issuing a <code>REGISTER_INDEX</code> action, which also gets evicted from the transaction cache with a similar error message:</p>
  
  <pre><code>mgmt.updateIndex(usernameIndex, SchemaAction.REGISTER_INDEX).get()
  mgmt.commit()
  </code></pre>
  
  <p>I've also tried restarting the server multiple times.</p>
  
  <p>It seems like the registration process is simply timing out, causing an "eviction" from the transaction cache. I've waited 48 hours just to be sure it wasn't a slow process. Normal reads, writes, and associated commits to Titan do seem to be working correctly, I'm just not able to create this index. I'm stuck, is there something else I can try? Is there a way to extend the timeout on that transaction?</p>
  
  <p>I'm running Titan 1.0.0 using a DynamoDB backend (setup with the AWS provided <a href="https://github.com/awslabs/dynamodb-titan-storage-backend">CloudFormation template</a>). </p>
  
  <p>EDIT:
  Here is the complete command I'm pasting into Gremlin with the addition of the <code>awaitGraphStatus</code> step suggested by @M-T-A:</p>
  
  <pre><code>mgmt = graph.openManagement();
  usernameIndex = mgmt.getPropertyKey('usernameIndex');
  mgmt.buildIndex('byUsername',Vertex.class).addKey(usernameIndex).unique().buildCompositeIndex();
  // I have tried with and without a commit here: mgmt.commit();
  mgmt.awaitGraphIndexStatus(graph, 'byUsername').status(SchemaStatus.REGISTERED).timeout(10, java.time.temporal.ChronoUnit.MINUTES).call();
  </code></pre>
  
  <p>This results in the following error:</p>
  
  <blockquote>
    <p>java.lang.NullPointerException
        at com.thinkaurelius.titan.graphdb.database.management.GraphIndexStatusWatcher.call(GraphIndexStatusWatcher.java:52)
        at com.thinkaurelius.titan.graphdb.database.management.GraphIndexStatusWatcher.call(GraphIndexStatusWatcher.java:18)
        at java_util_concurrent_Callable$call.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:114)
        at groovysh_evaluate.run(groovysh_evaluate:3)
        at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:215)
        at org.codehaus.groovy.tools.shell.Interpreter.evaluate(Interpreter.groovy:69)
        at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:185)
        at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:119)
        at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:94)</p>
  </blockquote>
  
  <p>I will also note that the routine to disable and delete an index is also failing.</p>
  
  <pre><code>mgmt = graph.openManagement()
  theIndex = mgmt.getGraphIndex('byUsername')
  mgmt.updateIndex(theIndex, SchemaAction.DISABLE_INDEX).get()
  mgmt.commit()
  mgmt.awaitGraphIndexStatus(graph, 'byUsername').status(SchemaStatus.DISABLED).timeout(10, java.time.temporal.ChronoUnit.MINUTES).call();
  m = graph.openManagement()
  i = m.getGraphIndex('byUsername')
  m.updateIndex(i, SchemaAction.REMOVE_INDEX).get()
  m.commit()
  </code></pre>
  
  <blockquote>
    <p>19:26:26 ERROR com.thinkaurelius.titan.graphdb.database.management.ManagementLogger  - Evicted [1@ac1f3fa810472-ip-172-31-63-1681] from cache but waiting too long for transactions to close. Stale transaction alert on: [standardtitantx[0x2314cd97], standardtitantx[0x39f8adc0], standardtitantx[0x09de1b85]]</p>
  </blockquote>
  
  <p>EDIT 2:
  Attempting to create a new property key and index within the same transaction DOES WORK! But does this mean that I can't create indexes on existing property keys??</p>
  
  <pre><code>graph.tx().rollback();
  mgmt = graph.openManagement();
  indexName = 'byUsernameTest2';
  propertyKeyName = 'testPropertyName2';
  propertyKey = mgmt.makePropertyKey(propertyKeyName).dataType(String.class).cardinality(Cardinality.SINGLE).make();
  mgmt.buildIndex(indexName,Vertex.class).addKey(propertyKey).buildCompositeIndex();
  mgmt.commit();
  graph.tx().commit();
  mgmt.awaitGraphIndexStatus(graph, indexName).status(SchemaStatus.REGISTERED).timeout(10, java.time.temporal.ChronoUnit.MINUTES).call();
  mgmt.commit();
  </code></pre>
  
  <p>After a pause, this results in:</p>
  
  <blockquote>
    <p>This management system instance has been closed</p>
  </blockquote>
  
  <p>Trying to fetch the new index results in:</p>
  
  <pre><code>mgmt = graph.openManagement();
  index = mgmt.getGraphIndex('byUsernameTest2');
  propkey = mgmt.getPropertyKey('testPropertyName2');
  index.getIndexStatus(propkey);
  </code></pre>
  
  <blockquote>
    <p>==>ENABLED</p>
  </blockquote>