java-client写入nebula operator一段时间后报错

提问参考模版:

  • nebula 版本:2.0.1
  • 部署方式(分布式 / 单机 / Docker / DBaaS):分布式nebula operator
  • 是否为线上版本:Y

使用java-client,获取一个session ,持续的写入了三个半小时,后报错,
ps:这一套java-client写入代码,如果是持续写入物理机rpm安装的集群,没有任何问题,但是写入k8s里面nebula-operator的,集群不稳定,长时间写入后集群就报错,报错的信息也看不懂,

[INFO ][2021-06-16 15:29:48,784][com.sf.nebula.FileUtilsTest] :start
[INFO ][2021-06-16 15:29:57,001][com.sf.nebula.util.NebulaGraphUtil] :NebulaGraphUtil create appMode=k8s space=lineage_name3
[INFO ][2021-06-16 15:29:57,733][com.vesoft.nebula.client.graph.net.NebulaPool] :Get connection to 10.202.77.197:31337
[INFO ][2021-06-16 15:30:02,495][com.sf.nebula.FileUtilsTest] :handler data total :500
[INFO ][2021-06-16 15:30:08,729][com.sf.nebula.FileUtilsTest] :handler data total :1000
.
.
.
[INFO ][2021-06-16 19:05:54,391][com.sf.nebula.FileUtilsTest] :handler data total :245000
[INFO ][2021-06-16 19:06:07,004][com.sf.nebula.FileUtilsTest] :handler data total :245500
[INFO ][2021-06-16 19:07:02,387][com.sf.nebula.FileUtilsTest] :handler data total :246000
[INFO ][2021-06-16 19:07:12,193][com.sf.nebula.FileUtilsTest] :handler data total :246500
[INFO ][2021-06-16 19:07:21,558][com.sf.nebula.FileUtilsTest] :handler data total :247000
[INFO ][2021-06-16 19:08:02,881][com.sf.nebula.FileUtilsTest] :handler data total :247500
[INFO ][2021-06-16 19:08:29,550][com.sf.nebula.FileUtilsTest] :handler data total :248000
[INFO ][2021-06-16 19:09:26,345][com.sf.nebula.FileUtilsTest] :handler data total :248500
[ERROR][2021-06-16 19:10:00,174][com.sf.nebula.util.NebulaGraphUtil] :Expected protocol id ffffff82 but got 48
com.vesoft.nebula.client.graph.exception.IOErrorException: Expected protocol id ffffff82 but got 48
	at com.vesoft.nebula.client.graph.net.SyncConnection.execute(SyncConnection.java:74)
	at com.vesoft.nebula.client.graph.net.Session.execute(Session.java:56)
	at com.sf.nebula.util.NebulaGraphUtil.executeWith3Tries(NebulaGraphUtil.java:115)
	at com.sf.nebula.util.NebulaGraphUtil.executeWith3Tries(NebulaGraphUtil.java:134)
	at com.sf.nebula.handler.StatementHandler.buildNebulaStatement(StatementHandler.java:41)
	at com.sf.nebula.sink.NebulaSink.invoke(NebulaSink.java:93)
	at com.sf.nebula.FileUtilsTest.main(FileUtilsTest.java:49)
[ERROR][2021-06-16 19:10:00,177][com.sf.nebula.util.NebulaGraphUtil] :java.net.SocketException: Connection reset by peer: socket write error
com.vesoft.nebula.client.graph.exception.IOErrorException: java.net.SocketException: Connection reset by peer: socket write error
	at com.vesoft.nebula.client.graph.net.SyncConnection.execute(SyncConnection.java:74)
	at com.vesoft.nebula.client.graph.net.Session.execute(Session.java:46)
	at com.sf.nebula.util.NebulaGraphUtil.executeWith3Tries(NebulaGraphUtil.java:115)
	at com.sf.nebula.util.NebulaGraphUtil.executeWith3Tries(NebulaGraphUtil.java:134)
	at com.sf.nebula.handler.StatementHandler.buildNebulaStatement(StatementHandler.java:41)
	at com.sf.nebula.sink.NebulaSink.invoke(NebulaSink.java:93)
	at com.sf.nebula.FileUtilsTest.main(FileUtilsTest.java:49)
[ERROR][2021-06-16 19:10:00,177][com.sf.nebula.util.NebulaGraphUtil] :executeWith3Tries failed, msg=Storage Error: part: 15, error: E_RPC_FAILURE(-3)., nGql=DELETE VERTEX "bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3"; DELETE EDGE produce "bdp.dm_pcss.pcss_waybill_route_coustom_one_to_tj" -> "bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3"; DELETE EDGE contain "bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3" -> "bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3.actualweight"; DELETE VERTEX "bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3.actualweight";
com.vesoft.nebula.client.graph.exception.IOErrorException: java.net.SocketException: Connection reset by peer: socket write error
	at com.vesoft.nebula.client.graph.net.SyncConnection.execute(SyncConnection.java:74)
	at com.vesoft.nebula.client.graph.net.Session.execute(Session.java:46)
	at com.sf.nebula.util.NebulaGraphUtil.executeWith3Tries(NebulaGraphUtil.java:115)
	at com.sf.nebula.util.NebulaGraphUtil.executeWith3Tries(NebulaGraphUtil.java:134)
	at com.sf.nebula.handler.StatementHandler.buildNebulaStatement(StatementHandler.java:41)
	at com.sf.nebula.sink.NebulaSink.invoke(NebulaSink.java:93)
	at com.sf.nebula.FileUtilsTest.main(FileUtilsTest.java:49)
[ERROR][2021-06-16 19:10:00,179][com.sf.nebula.util.NebulaGraphUtil] :java.net.SocketException: Connection reset by peer: socket write error
com.vesoft.nebula.client.graph.exception.IOErrorException: java.net.SocketException: Connection reset by peer: socket write error
	at com.vesoft.nebula.client.graph.net.SyncConnection.execute(SyncConnection.java:74)
	at com.vesoft.nebula.client.graph.net.Session.execute(Session.java:46)
	at com.sf.nebula.util.NebulaGraphUtil.executeWith3Tries(NebulaGraphUtil.java:115)
	at com.sf.nebula.util.NebulaGraphUtil.executeWith3Tries(NebulaGraphUtil.java:134)
	at com.sf.nebula.handler.StatementHandler.buildNebulaStatement(StatementHandler.java:41)
	at com.sf.nebula.sink.NebulaSink.invoke(NebulaSink.java:93)
	at com.sf.nebula.FileUtilsTest.main(FileUtilsTest.java:49)

首先,请问你的客户端用的什么版本;
其次你如何使用session的,是否有多线程使用同个session;
最后你看下服务状态,是否有服务异常了。

1,客户端用的master分支代码(5月11号的)自行打包的
2,没有使用多线程,串行单线程

初始化session
NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig();
NebulaPool nebulaPool = new NebulaPool();
List<HostAddress> addresses = Arrays.asList(new HostAddress("10.202.77.197", 31337));
nebulaPool.init(addresses, nebulaPoolConfig);
Session session = nebulaPool.getSession(USER_NAME, PASSWORD, true);
session.execute("use " + space);

然后循环执行执行
try {
	resultSet = session.execute(nGql);
	boolean isSucceeded = resultSet.isSucceeded();
	if (isSucceeded) {
		return resultSet;
	}
} catch (Exception e) {
	log.error(e.getMessage(), e);
}

3,服务正常

上面报错的一般都是多线程使用同个连接才会,你说你那边没这样使用,你可以提供下你用的java-client的commit id吗?还有java client master的和2.0.1是不兼容的,你最好用回2.0.0的java client,用master的java client,服务端也是要用master

commit id是a11c1f2fe2d4913be4ecfbd1551807f97d1806d0
服务端用的是v2.0.1的镜像


启动了3个metad,3个graphd,3个storaged,1个graphd-nodeport

你是用docker-compose启动服务的吧,你docker-compose ps截图下

你用的java-client的版本还是可以用2.0.1的,看你上面日志显示是多线程同时出错,你给的实例代码只是被你简化的代码。你上面报错,多个线程是不同错误,第一个错误一般是多线程使用才会出现,第二个和第三个是服务连接断开了。

使用的nebula-operator

kubectl get pods -l app.kubernetes.io/instance=nebula 看下服务的状态

官网的这个命令不知道是不是写错了?改成kubectl get pods -l app.kubernetes.io/cluster=nebula
image

客户端的并发数是多少?

客户端的并发数是1,从始至终就只创建了一个session,然后串行的使用这个session 读取,写入数据
我的ngql执行的是多条,分号分隔,最多可能有500条,会产生并行的影响吗?
nGql=DELETE VERTEX “bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3”; DELETE EDGE produce “bdp.dm_pcss.pcss_waybill_route_coustom_one_to_tj” → “bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3”; DELETE EDGE contain “bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3” → “bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3.actualweight”; DELETE VERTEX “bdp.dm_pcss.pcss_waybill_route_coustom_one_temp3.actualweight”

你的query一下次执行500条删除命令呀,假如里面的点都有很多边,服务可能会oom吧,你看你上面截图,graph2已经重启过一次了。

session.execute(nGql) 这种方式里面的nGql执行语句 可以最多 512条呀,我之前测试过没问题的
那我试下吧这个条数 调低一点试试

你要看是什么query,插入是可以,删除的话就太大了

好的,那我改一下程序,把delete拧出来
那你们是否有考虑吧session.execute拆分一下咧,比如insert,query,delete,upsert,然后分别可以限制一下条数,因为有批量执行的需求

一直有个疑问,就是这个RoundRobinLoadBalancer 里面判断服务端状态的方式,使用的ping函数,但是
这个函数内部实现,我就算填一个不存的ip,或者端口瞎写一个,ping都返回的true,这里不需要真正的取判断ip+port的服务状态么

    public static void main(String[] args) {
        List<HostAddress> addresses = Arrays.asList(
                new HostAddress("10.82.232.121", 8081)
                , new HostAddress("10.82.232.1", 8081));
        RoundRobinLoadBalancer loadBalancer = new RoundRobinLoadBalancer(addresses, 0);
        loadBalancer.updateServersStatus();
    }

ip和端口不可达,ping不会为true的


image

环境中不存在10.82.232.1主机,在cmd中ping不通,但是程序内ping执行返回true,服务状态为0,也就是OK

你确定你java 程序运行的环境访问不了 10.82.232.1 这个ip,你的java 程序是在你的window上面运行吗?应该是你的java 程序的环境确实存在这样的端口和ip。
Screen Shot 2021-06-21 at 15.52.03

您好, 这个 ip 感觉是 Kubernetes 中的,你可以用如下命令看看是否存在

kubectl get svc,pod -owide