Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cannot open null host" log by com.vesoft.nebula.client.meta.MetaManager #409

Closed
iiibui opened this issue Dec 22, 2021 · 1 comment · Fixed by #502
Closed

"Cannot open null host" log by com.vesoft.nebula.client.meta.MetaManager #409

iiibui opened this issue Dec 22, 2021 · 1 comment · Fixed by #502
Labels
type/enhancement Type: make the code neat or more efficient

Comments

@iiibui
Copy link

iiibui commented Dec 22, 2021

It should be check if the leader address is empty when E_LEADER_CHANGED:

if (response.getCode() == ErrorCode.E_LEADER_CHANGED) {
freshClient(response.getLeader());
} else {

Also see:

private void freshClient(HostAddr leader)
throws TTransportException {
close();
try {
getClient(leader.getHost(), leader.getPort());
} catch (ClientServerIncompatibleException e) {
LOGGER.error(e.getMessage());
}
}

private void getClient(String host, int port)
throws TTransportException, ClientServerIncompatibleException {
if (enableSSL) {
SSLSocketFactory sslSocketFactory;
if (sslParam.getSignMode() == SSLParam.SignMode.CA_SIGNED) {
sslSocketFactory = SslUtil.getSSLSocketFactoryWithCA((CASignedSSLParam) sslParam);
} else {
sslSocketFactory =
SslUtil.getSSLSocketFactoryWithoutCA((SelfSignedSSLParam) sslParam);
}
try {
transport = new TSocket(sslSocketFactory.createSocket(host, port), timeout,
timeout);
} catch (IOException e) {
throw new TTransportException(IOErrorException.E_UNKNOWN, e);
}
} else {
transport = new TSocket(host, port, timeout, timeout);
transport.open();
}
protocol = new TCompactProtocol(transport);
client = new MetaService.Client(protocol);
// check if client version matches server version
VerifyClientVersionResp resp =
client.verifyClientVersion(new VerifyClientVersionReq());
if (resp.getCode() != ErrorCode.SUCCEEDED) {
client.getInputProtocol().getTransport().close();
throw new ClientServerIncompatibleException(new String(resp.getError_msg(),
Charsets.UTF_8));
}
}

It may be fine to process like C++ meta client: MetaClient.cpp#L701-L702, MetaClient.h#L689-L696, since metad should response empty leader address when it's role is CANDIDATE:RaftPart.cpp#L960-L972.

Response call stack: handleErrorCode->handleLeaderChanged->partLeader->getStoreAddr->getStoreAddrFromRaftAddr.

@iiibui
Copy link
Author

iiibui commented Dec 22, 2021

By the way, MetaManager should do some refactor since fillMetaInfo caught the TException then the caller like getSpace and so on know nothing about it. And the MetaClient stays in a strange state(transport has closed but the user know nothing about it) when getClient fail:

private void freshClient(HostAddr leader)
throws TTransportException {
close();
try {
getClient(leader.getHost(), leader.getPort());
} catch (ClientServerIncompatibleException e) {
LOGGER.error(e.getMessage());
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Type: make the code neat or more efficient
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants