我无法创建索引。我的 Gremlin 代码如下:
usernameProperty = mgmt.getPropertyKey('username')
usernameIndex = mgmt.buildIndex('byUsernameUnique', Vertex.class).addKey(usernameProperty).unique().buildCompositeIndex()
mgmt.setConsistency(usernameIndex, ConsistencyModifier.LOCK)
mgmt.commit()
我收到两个错误:
18:04:57 ERROR com.thinkaurelius.titan.graphdb.database.management.ManagementLogger - 将[1@0a00009d2537-ip-10-0-0-1572]从高速缓存中删除,但等待事务关闭的时间太长。 在以下内容上过期的事务提醒:[standardtitantx [0x6549ce71]] 18:04:57 ERROR com.thinkaurelius.titan.graphdb.database.management.ManagementLogger - 将[1@0a00009d2537-ip-10-0-0-1572]从高速缓存中删除,但等待事务关闭的时间太长。 在以下内容上过期的事务提醒:[standardtitantx [0x2a2815cc],standardtitantx [0x025dc2c0]]
索引状态卡在已安装
:
usernameIndex.getIndexStatus(usernameProperty)
==>INSTALLED
我读到说一个失败的实例可能会导致这个问题,但是运行实例的检查只显示了一个:
mgmt.getOpenInstances()
==>0a00009d3011-ip-10-0-0-1572(current)
我还尝试了发出REGISTER_INDEX
操作,但是也出现了类似的错误消息并从事务缓存中删除:
mgmt.updateIndex(usernameIndex, SchemaAction.REGISTER_INDEX).get()
mgmt.commit()
我也尝试了多次重新启动服务器。
看起来注册过程只是超时了,导致从事务缓存中"逐出"。我等了48个小时,只是为了确保这不是一个缓慢的过程。正常的读取,写入和关联提交到Titan的操作似乎都能正常工作,我只是不能创建这个索引。我被卡住了,还有其他我可以尝试的东西吗?是否有一种方法可以延长事务的超时时间?
我正在使用DynamoDB后端运行Titan 1.0.0(使用AWS提供的CloudFormation模板进行设置)。
编辑:
这是完整的命令,我将它粘贴到Gremlin中,并添加了@M-T-A建议的awaitGraphStatus
步骤:
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();
这导致了以下错误:
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)
我还需要注意的是,禁用和删除索引的例程也失败了。
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()
19:26:26 ERROR com.thinkaurelius.titan.graphdb.database.management.ManagementLogger - 将[1@ac1f3fa810472-ip-172-31-63-1681]从缓存中驱逐,但等待事务关闭的时间太长。在以下事务上出现过期事务警报:[standardtitantx [0x2314cd97],standardtitantx [0x39f8adc0],standardtitantx [0x09de1b85]]
编辑2: 尝试在同一事务中创建新属性键和索引是可行的!但这是否意味着我不能在现有属性键上创建索引??
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();
暂停一段时间后,结果为:
此管理系统实例已关闭
尝试获取新索引会导致:
mgmt = graph.openManagement();
index = mgmt.getGraphIndex('byUsernameTest2');
propkey = mgmt.getPropertyKey('testPropertyName2');
index.getIndexStatus(propkey);
==>已启用