Configuring dedicated Cassandra contact points now require a local DC

See original GitHub issue

We need to expose an additional property as the following is thrown when one wants to customize the contact points to use.

Caused by: java.lang.IllegalStateException: Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=/127.0.0.1:9042, hostId=3e9d107c-8fab-4458-b217-d84c4491b574, hashCode=22d286ac)=datacenter1. Current DCs in this cluster are: datacenter1
	at com.datastax.oss.driver.internal.core.loadbalancing.helper.MandatoryLocalDcHelper.discoverLocalDc(MandatoryLocalDcHelper.java:91) ~[java-driver-core-4.3.1.jar:na]
	at com.datastax.oss.driver.internal.core.loadbalancing.DefaultLoadBalancingPolicy.discoverLocalDc(DefaultLoadBalancingPolicy.java:73) ~[java-driver-core-4.3.1.jar:na]
	at com.datastax.oss.driver.internal.core.loadbalancing.BasicLoadBalancingPolicy.init(BasicLoadBalancingPolicy.java:126) ~[java-driver-core-4.3.1.jar:na]
	at com.datastax.oss.driver.internal.core.metadata.LoadBalancingPolicyWrapper.init(LoadBalancingPolicyWrapper.java:121) ~[java-driver-core-4.3.1.jar:na]
	at com.datastax.oss.driver.internal.core.session.DefaultSession$SingleThreaded.afterInitialSchemaRefresh(DefaultSession.java:419) ~[java-driver-core-4.3.1.jar:na]
	at com.datastax.oss.driver.internal.core.session.DefaultSession$SingleThreaded.lambda$afterInitialNodeListRefresh$5(DefaultSession.java:409) ~[java-driver-core-4.3.1.jar:na]
	at java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:670) ~[na:1.8.0_232]
	at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:646) ~[na:1.8.0_232]
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) ~[na:1.8.0_232]
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975) ~[na:1.8.0_232]
	at com.datastax.oss.driver.internal.core.metadata.MetadataManager$SingleThreaded.lambda$startSchemaRequest$2(MetadataManager.java:420) ~[java-driver-core-4.3.1.jar:na]
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774) ~[na:1.8.0_232]
	at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750) ~[na:1.8.0_232]
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) ~[na:1.8.0_232]
	at java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:575) ~[na:1.8.0_232]
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:594) ~[na:1.8.0_232]
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:456) ~[na:1.8.0_232]
	at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) ~[netty-transport-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050) ~[netty-common-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.43.Final.jar:4.1.43.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.43.Final.jar:4.1.43.Final]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_232]

At the moment this even happens by default (i.e. without changing anything) so that’s quite annoying.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

12reactions
jmooocommented, Jul 21, 2020

If anyone comes across this ticket googling the spring 2.3 local DC error, the spring config var you want is:

spring.data.cassandra.local-datacenter=datacenter1

(where datacenter1 is whatever you previously named your DC)

1reaction
adutracommented, Jul 21, 2020

When I specified multiple contact points, setLocalDatacenter set only the first one?

The local datacenter must be the same for all contact points.

It’s hard to tell without more context, but it does look like you are hitting JAVA-2835. It will be fixed in the next driver release, 4.8.0, due in the next few days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I deal with the error "the local DC must be explicitly set ...
Datastax 4+CqlSession ->error"the local DC must be explicitly set" when creating session specifying contactpoints -multiple datacenters?
Read more >
Cassandra Driver Configuration for improved performance ...
The driver accepts a “local-dc” and number of remote dcs to use as fallback. This basically allows only one data center as the...
Read more >
cassandra.yaml file configuration
Addresses of hosts that are deemed contact points. # Cassandra nodes use this list of hosts to find each other and learn #...
Read more >
Spring data Cassandra | local data-center is taking as null
Upon adding another node to the contact points(multiple nodes) as in ... as the local DC, but some contact points are from a...
Read more >
Spring Data for Apache Cassandra - Reference Documentation
It requires Cassandra 2.0 or later and Datastax driver 4.x. ... Provide a contact point to the configuration.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found