TitanDB索引未更改状态 [英] TitanDB Index not changing state

查看:55
本文介绍了TitanDB索引未更改状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I wanted to drop an existing index and followed the steps in the documentation so far. I have no separate indexing backend configured for now. However, when I get to the step where you have to wait for the index status to change using m.awaitGraphIndexStatus it waits forever for the change and times out with the following error:

GraphIndexStatusReport[success=false, indexName='usernameComposite', targetStatus=DISABLED, notConverged={username=INSTALLED}, converged={}, elapsed=PT1M0.092S]

当我尝试创建一个新的时,也会发生同样的情况. 有什么想法会导致这种情况吗?

The very same happens when I try to create a new one. Any ideas what could cause this?

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

I'm creating indizes using the following code snippet:

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在 gremlin-users帖子,您需要确保没有针对该图的未清交易.请记住,这包括来自其他连接的事务,以防您有多个客户端或线程针对该图打开.

As Dan describes in this gremlin-users post, you need to make sure that there are no open transactions against the graph. Keep in mind this includes transactions from other connections, in case you have multiple clients or threads open against the graph.

您可以使用graph.getOpenTransactions()检查开放交易. html#getOpenTransactions--"rel =" nofollow> StandardTitanGraph ,如果没有,则返回null.如果有未结交易,则需要全部commit()rollback().

You can check for open transactions with graph.getOpenTransactions() defined in StandardTitanGraph which returns null if there are none. If there are open transactions, you would need to either commit() or rollback() them all.

这是我在Gremlin Console中成功使用的代码段.

Here's a snippet that I have used successfully in the Gremlin Console.

// 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()

这篇关于TitanDB索引未更改状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆