TitanDB索引未更改状态

TitanDB索引未更改状态,titan,gremlin,tinkerpop,Titan,Gremlin,Tinkerpop,我想删除一个现有的索引,并按照文档中的步骤进行操作。我现在没有单独配置索引后端。但是,当我到达必须使用m.waitgraphindexstatus等待索引状态更改的步骤时,它将永远等待更改并超时,出现以下错误: GraphIndexStatusReport[success=false, indexName='usernameComposite', targetStatus=DISABLED, notConverged={username=INSTALLED}, converged={}, ela

我想删除一个现有的索引,并按照文档中的步骤进行操作。我现在没有单独配置索引后端。但是,当我到达必须使用
m.waitgraphindexstatus
等待索引状态更改的步骤时,它将永远等待更改并超时,出现以下错误:

GraphIndexStatusReport[success=false, indexName='usernameComposite', targetStatus=DISABLED, notConverged={username=INSTALLED}, converged={}, elapsed=PT1M0.092S]
当我尝试创建一个新的时,也会发生同样的情况。 你知道这是什么原因吗

我正在使用以下代码段创建indizes:

graph.tx().rollback()
mgmt = graph.openManagement()
name = mgmt.getPropertyKey('username')
mgmt.buildIndex('username-composite', Vertex.class).addKey(name).unique().buildCompositeIndex()
mgmt.commit()
mgmt.awaitGraphIndexStatus(graph, 'username-composite').call()
正如Dan在本文中所描述的,您需要确保图中没有打开的事务。请记住,这包括来自其他连接的事务,以防有多个客户端或线程针对该图打开

您可以使用定义的
graph.getOpenTransactions()
检查打开的事务,如果没有,则返回
null
。如果存在打开的事务,则需要将它们全部提交到
commit()
rollback()

下面是我在Gremlin控制台中成功使用的一个片段

// Disable the index. Once the able is DISABLED, it cannot be re-enabled again!
// Instead, you could build a new index with the same properties.
future = null
if (graph.getOpenTransactions()) graph.tx().rollback()
mgmt = graph.openManagement()
name = mgmt.getPropertyKey('name')
nameIndex = mgmt.getGraphIndex('nameIndex')
nameIndexStatus = nameIndex.getIndexStatus(name) // must be ENABLED, INSTALLED, or REGISTERED
if (nameIndexStatus == SchemaStatus.INSTALLED || nameIndexStatus == SchemaStatus.ENABLED) future = mgmt.updateIndex(nameIndex, SchemaAction.DISABLE_INDEX)
nameIndexStatus = nameIndex.getIndexStatus(name) // should be INSTALLED here
mgmt.commit()

// Block until disabling index is complete (ENABLED -> INSTALLED -> DISABLED), no metrics are reported (null)
if (graph.getOpenTransactions()) graph.tx().rollback()
t = System.currentTimeMillis(); metrics = future.get(); 'disabled in '+(System.currentTimeMillis()-t)+' ms'
if (nameIndexStatus == SchemaStatus.ENABLED) mgmt.awaitGraphIndexStatus(graph, 'nameIndex').status(SchemaStatus.INSTALLED).call()
if (nameIndexStatus == SchemaStatus.INSTALLED) mgmt.awaitGraphIndexStatus(graph, 'nameIndex').status(SchemaStatus.DISABLED).call()

当我尝试创建一个新的时也会发生这种情况。我使用脚本在包含一些数据的属性下创建一个新索引。剧本来自

经过几次实验,我发现它的
graph.tx().rollback()
工作不正常

gremlin> :> graph.getOpenTransactions()
==>standardtitantx[0x1e14c346]
==>standardtitantx[0x7a0067f2]
==>standardtitantx[0x0de3ee40]
==>standardtitantx[0x47e19812]
==>standardtitantx[0x27b20549]
==>standardtitantx[0x0ee46d99]
gremlin> :> graph.tx().rollback()
==>null
gremlin> :> graph.getOpenTransactions()
==>standardtitantx[0x1e14c346]
==>standardtitantx[0x7a0067f2]
==>standardtitantx[0x0de3ee40]
==>standardtitantx[0x47e19812]
==>standardtitantx[0x093ac20f]
==>standardtitantx[0x27b20549]
==>standardtitantx[0x0ee46d99]
这就是我无法创建新索引的原因。因此,我将
graph.tx().rollback()
替换为

// rollback all exist transactions
int size = graph.getOpenTransactions().size();
for(i=0;i<size;i++) {graph.getOpenTransactions().getAt(0).rollback()}
//回滚所有存在的事务
int size=graph.getOpenTransactions().size();

对于(i=0;我可以发布您用来更改索引的步骤/代码吗?我在上面编辑了我的帖子。因此,换句话说,如果我运行多个gremlin服务器来支持大量并发事务,我需要在对任何Indizies进行维护之前将它们全部取下,对吗?还有一个后续问题:我还需要停止所有机器吗如果我在创建索引时使用的同一管理事务中创建属性?如果在同一管理事务中创建新属性键及其索引,我认为应该在提交后立即启用索引。
// rollback all exist transactions
int size = graph.getOpenTransactions().size();
for(i=0;i<size;i++) {graph.getOpenTransactions().getAt(0).rollback()}