你是不是多个线程同时操作你定义的client
多线程操作应该怎么处理?每个线程单独一个client?现在我把客户端弄在ThreadLocal中的,里边的代码是这样就是为了避免多线程
@Override
protected GraphClient initialValue() {
GraphClient client = new GraphClientImpl(hostAndPorts, timeout, connectionRetry, executionRetry);
client.setUser(user);
client.setPassword(password);
set(client);
try {
prepare(space);
} catch (Exception e) {
logger.error("init graph fail. " + space, e);
}
return client;
}
@Override
public void remove() {
try {
get().close();
} catch (Exception e) {
logger.error("close client error. ",e);
}
super.remove();
}
/**
* 图空间准备
*/
public void prepare(String space) throws Exception {
int code = get().connect();
if (code != ErrorCode.SUCCEEDED) {
get().close();
throw new RuntimeException("Connection Failed");
}
int switchCode = get().switchSpace(space);
if (switchCode != ErrorCode.SUCCEEDED) {
get().close();
throw new RuntimeException("Switch Failed");
}
logger.info("Connection to " + space + " thread: " + Thread.currentThread().getName());
}
你这代码没有使用的地方,要看你外部怎么使用GraphClient
在构造函数中初始化
client = new NebulaThreadLocal(user, password, space, hostAndPorts, timeout, connectionRetry, executionRetry);
然后在query中查询
public List<Map<String, Object>> query(String nGql) {
List<Map<String, Object>> resultsList = new ArrayList<>();
try {
ResultSet resultSet = client.get().executeQuery(nGql);
// 没有查询到结果
List<ResultSet.Result> results = resultSet.getResults();
if (results == null || results.isEmpty()) {
return resultsList;
}
for (ResultSet.Result result : results) {
Map<String, Object> resultMap = new HashMap<>();
for (String column : resultSet.getColumns()) {
Object value = result.get(column).getFieldValue();
if (value instanceof byte[]) {
resultMap.put(column, result.getString(column));
} else {
resultMap.put(column, value);
}
}
resultsList.add(resultMap);
}
}
}
return resultsList;
}
这个查询操作有什么建议没有?查询后就关闭连接?
你用你的代码只发送一条请求,服务端会报这个错误吗?
只发送一条不会
出问题的时间不确定
那你认真检查你的代码,应该是你连接被多线程用了,导致服务端那边读到的数据乱掉了
好的,那数据库突然crash,有些什么比较好的定位方式?这边看了下 meta/graph/storage的日志都没有发现比较有用的信息。那个demp文件很大也不利于分析
有core文件吗?在安装目录下面
这个里边有日志?
这个 core.数字 的文件一个就是好几个G
![]()
是这个?
你把日志目录下面的stderr.log发出来
E0802 11:39:59.031564 178798 GeneratedCodeHelper.cpp:116] received invalid message from client: No version identifier… old protocol client in strict mode? sz=1195725856
E0802 11:39:59.045732 178798 GeneratedCodeHelper.cpp:73] invalid message from client in function process
E0802 17:48:35.297645 178868 ExecutionPlan.cpp:23] Do cmd fetch prop on family C863142001A5 yield C863142001A5 as familyId,family.name as name' failed: SyntaxError: syntax error near yield’
E0802 17:48:35.312392 178868 ExecutionPlan.cpp:80] Execute failed: SyntaxError: syntax error near `yield’
E0802 20:18:36.407011 88841 MetaClient.cpp:524] Send request to [], exceed retry limit
E0802 20:18:36.407783 88827 MetaClient.cpp:58] Heartbeat failed, status:RPC failure in MetaClient: N6apache6thrift9transport19TTransportExceptionE: AsyncSocketException: connect failed, type = Socket not open, errno = 111 (Connection refused): Connection refused
E0802 23:48:43.609401 127785 GeneratedCodeHelper.cpp:116] received invalid message from client: No version identifier… old protocol client in strict mode? sz=1195725856
E0802 23:48:43.610240 127785 GeneratedCodeHelper.cpp:73] invalid message from client in function process
E0802 23:48:59.038522 127787 GeneratedCodeHelper.cpp:73] Method name getLeader not found in function process
E0802 23:49:00.041999 127789 HeaderServerChannel.cpp:114] Received invalid request from client: N6apache6thrift9transport19TTransportExceptionE: Could not detect client transport type: magic 0x02030a84 (transport N6apache6thrift5async12TAsyncSocketE, address , port 52262)
E0802 23:50:27.176414 127793 GeneratedCodeHelper.cpp:116] received invalid message from client: No version identifier… old protocol client in strict mode? sz=1195725856
E0802 23:50:27.176524 127793 GeneratedCodeHelper.cpp:73] invalid message from client in function process
E0802 23:51:06.586977 127794 GeneratedCodeHelper.cpp:116] received invalid message from client: No version identifier… old protocol client in strict mode? sz=1195725856
E0802 23:51:06.587097 127794 GeneratedCodeHelper.cpp:73] invalid message from client in function process
E0802 23:51:21.665520 127795 GeneratedCodeHelper.cpp:116] received invalid message from client: No version identifier… old protocol client in strict mode? sz=1195725856
E0802 23:51:21.665642 127795 GeneratedCodeHelper.cpp:73] invalid message from client in function process
E0802 23:51:31.742843 127796 PeekingManager.h:100] Received SSL connection on non SSL port
file core.xxx 截图下

每个文件都执行 file core文件名截图
