JanusGraph / JanusGraph/janusgraph

DNS resolution is not being updated with CQLStoreManger

Open
#2,464 2 comments 5 reactions 0 assignees View on GitHub
kind/bug/possible
Dominant language
Java
Stars
5.8k
Forks
1.2k
Avg merge
13h 53m
Merged PRs (30d)
6

Description

Hi everyone!

We were facing an issue with the connection between TheHive and Cassandra in a Kubernetes deployment. Every time the Cassandra deployment is restarted, the TheHive Jansugraph connector is not able to reconnect with Cassandra. After analyzing the network logs we discovered the problem was Janusgraph was trying to connect to the old Cassandra IP. The DNS records of KubeDNS pointed to the new IP but the Janusgraph connector was stucked with the old one.

I was checking the source code and I think I found where the issue is:

https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-cql/src/main/java/org/janusgraph/diskstorage/cql/CQLStoreManager.java

```
CqlSession initializeSession() throws PermanentBackendException {
final Configuration configuration = getStorageConfig();
final List contactPoints;
try {
contactPoints = Array.of(this.hostnames)
.map(hostName -> hostName.split(":"))
.map(array -> Tuple.of(array[0], array.length == 2 ? Integer.parseInt(array[1]) : this.port))
.map(tuple -> new InetSocketAddress(tuple._1, tuple._2))
.toJavaList();
}
```

According to the InetSocketAddress documentation (https://docs.oracle.com/javase/7/docs/api/java/net/InetSocketAddress.html), when `InetSocketAddress(tuple._1, tuple._2))`, is called with a Hostname, the DNS resolution is performed and the returned IP is mapped. If the IP changes and the DNS entry gets updated with the new IP it makes no effect, since the old IP is already mapped and no new DNS resolutions are being performed.

Contributor guide

Open the contributing guide

Research direction

Start with janusgraph-cql/src/main/java/org/janusgraph/diskstorage/cql/CQLStoreManager.java, especially initializeSession() and its InetSocketAddress construction. Investigate how hostname resolution behaves after Cassandra's Kubernetes address changes. Done means the connector can reconnect using the updated DNS result after Cassandra restarts, with coverage for that scenario if an appropriate test location is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
cassandra, java
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.