ngbatis
ngbatis copied to clipboard
The session was released, couldn't use again.
批量插入边数据,大概跑了十几个小时,然后第二天看到日志,程序中断了。 2023-04-24 06:41:34.092 ERROR 19306 --- [nio-7788-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.nebula.contrib.ngbatis.exception.QueryException: 数据查询失败:The session was released, couldn't use again.] with root cause
com.vesoft.nebula.client.graph.exception.IOErrorException: The session was released, couldn't use again. at com.vesoft.nebula.client.graph.net.Session.executeWithParameter(Session.java:95) ~[client-3.0.0.jar!/:na] at org.nebula.contrib.ngbatis.proxy.MapperProxy.executeWithParameter(MapperProxy.java:223) ~[ngbatis-1.1.0.jar!/:1.1.0] at org.nebula.contrib.ngbatis.proxy.MapperProxy.invoke(MapperProxy.java:125) ~[ngbatis-1.1.0.jar!/:1.1.0] at org.nebula.contrib.ngbatis.proxy.MapperProxy.invoke(MapperProxy.java:160) ~[ngbatis-1.1.0.jar!/:1.1.0] at org.nebula.contrib.ngbatis.proxy.MapperProxy.pageSupport(MapperProxy.java:176) ~[ngbatis-1.1.0.jar!/:1.1.0] at org.nebula.contrib.ngbatis.proxy.MapperProxy.invoke(MapperProxy.java:85) ~[ngbatis-1.1.0.jar!/:1.1.0]
有说是网络中断,但是如果网络的话,xshell连接的服务器没有断开,还有就是Studio nebula graph服务断了,nebula graph没有断。
Hi @FeiUser 首先对花了这么长时间而没有获得好的体验这件事表示歉意。 可以升级下,使用 1.2.0-SNAPSHOT 试试,1.1.0 d的版本还没有使用 sessionPool。
另外,批量处理的方式,建议使用单次批量写入多条 nGQL 语句,整体上会节省很多时间。 但是要注意一次访问可传输长度的限制问题,差不多是 4294967295
最近正在开发批量写入的功能,从ngbatis层屏蔽长度限制问题,可以关注下。
批量写入可以是这样的形式:
<insert id="insertPersonList">
@for ( p in personList ) {
INSERT VERTEX `person` ( name, gender ) VALUES '${ p.name }' : ( '${ p.name }', '${ p.gender }' );
@}
</insert>
大概一次2000条,这个条数会根据单位数据的长度不同而有所差异。 稳妥起鉴,可以自己根据数据的情况把这个数值调小,分批多次写入。
我刚开始的时候用的就是1.2.0-SNAPSHOT,但是那时候好像项目起不来,所以就用这个了。再批处理中我也遇到了批量插入时nGQL长度问题了,这个我手动解决了,每次批量插入了30条数据。我今天再跑一下,看看还会不会出现这样的问题,如果还有的话,我就换1.2.0-SNAPSHOT版本再试试。
我自己用 Person 的结构测试 2000 ~ 3000 条的时候还是稳定的, 3000+ 会越来越不稳定,有时候会出错,有时候不会。
不太清楚你这边的单位数据长度怎么样,不过我感觉 30 条会偏小, 一次传输的量会比这个大得多,如果单位数据的属性不是特别多的话。
我刚开始的时候用的就是1.2.0-SNAPSHOT,但是那时候好像项目起不来,所以就用这个了。再批处理中我也遇到了批量插入时nGQL长度问题了,这个我手动解决了,每次批量插入了30条数据。我今天再跑一下,看看还会不会出现这样的问题,如果还有的话,我就换1.2.0-SNAPSHOT版本再试试。
关于1.2.0-SNAPSHOT 项目起不来的问题,随时欢迎提 issue,如果不是以下问题导致了的话。
初步判断可能是snapshot仓库地址跟release仓库地址不同导致的, 使用 snapshot 版本可以在项目里追加以下配置:
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<id>ossrh</id>
<name>Nexus Snapshot Repository</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
好的,感谢!!
刚刚翻了下记录,这个 在用连接被释放 的问题是早期版本的 bug 已经由 @soul-gin 解决,对应的 PR 是 #130 ,该版本最早发布在 1.1.2
刚刚翻了下记录,这个 在用连接被释放 的问题是早期版本的 bug 已经由 @soul-gin 解决,对应的 PR 是 #130 ,该版本最早发布在 1.1.2
ngbatis1.1.2中,可以用nebula graph3.2.1版本吧
用的是3.4.0版本的nebula-java,按官方文档看对3.x的都是支持的,我自己3.1的数据库没有问题